?? frmsetrm.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Text.RegularExpressions;
namespace motorseries
{
/// <summary>
/// frmSetRM 的摘要說明。
/// </summary>
public class frmSetRM : System.Windows.Forms.Form
{
private frmMain objForm ;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox txtRMID;
private System.Windows.Forms.TextBox txtRMName;
private System.Windows.Forms.TextBox txtRMDes;
private System.Windows.Forms.TextBox txtRMUnit;
private System.Windows.Forms.TextBox txtRMMax;
private System.Windows.Forms.TextBox txtRMMin;
private System.Windows.Forms.TextBox txtRMCoef;
private System.Windows.Forms.TextBox txtRMExp;
private System.Windows.Forms.GroupBox grpRM;
private System.Windows.Forms.Button cmdOk;
private System.Windows.Forms.Button cmdCancel;
private System.Windows.Forms.Button cmdDetail;
private System.Windows.Forms.TextBox txtVal;
private System.Windows.Forms.Label lblPrompt;
/// <summary>
/// 必需的設計器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public frmSetRM(frmMain m_Form)
{
//
// Windows 窗體設計器支持所必需的
//
InitializeComponent();
this.objForm = m_Form ;
//
// TODO: 在 InitializeComponent 調(diào)用后添加任何構造函數(shù)代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設計器生成的代碼
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.txtVal = new System.Windows.Forms.TextBox();
this.cmdOk = new System.Windows.Forms.Button();
this.lblPrompt = new System.Windows.Forms.Label();
this.cmdCancel = new System.Windows.Forms.Button();
this.grpRM = new System.Windows.Forms.GroupBox();
this.txtRMExp = new System.Windows.Forms.TextBox();
this.txtRMMin = new System.Windows.Forms.TextBox();
this.txtRMMax = new System.Windows.Forms.TextBox();
this.txtRMCoef = new System.Windows.Forms.TextBox();
this.txtRMUnit = new System.Windows.Forms.TextBox();
this.txtRMDes = new System.Windows.Forms.TextBox();
this.txtRMName = new System.Windows.Forms.TextBox();
this.txtRMID = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.cmdDetail = new System.Windows.Forms.Button();
this.grpRM.SuspendLayout();
this.SuspendLayout();
//
// txtVal
//
this.txtVal.Font = new System.Drawing.Font("宋體", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.txtVal.Location = new System.Drawing.Point(144, 24);
this.txtVal.Name = "txtVal";
this.txtVal.Size = new System.Drawing.Size(160, 26);
this.txtVal.TabIndex = 0;
this.txtVal.Text = "";
//
// cmdOk
//
this.cmdOk.Location = new System.Drawing.Point(16, 120);
this.cmdOk.Name = "cmdOk";
this.cmdOk.Size = new System.Drawing.Size(88, 32);
this.cmdOk.TabIndex = 1;
this.cmdOk.Text = "確定";
this.cmdOk.Click += new System.EventHandler(this.button1_Click);
//
// lblPrompt
//
this.lblPrompt.Font = new System.Drawing.Font("宋體", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.lblPrompt.Location = new System.Drawing.Point(0, 24);
this.lblPrompt.Name = "lblPrompt";
this.lblPrompt.Size = new System.Drawing.Size(136, 23);
this.lblPrompt.TabIndex = 4;
this.lblPrompt.Text = "label1";
//
// cmdCancel
//
this.cmdCancel.Location = new System.Drawing.Point(136, 120);
this.cmdCancel.Name = "cmdCancel";
this.cmdCancel.Size = new System.Drawing.Size(75, 32);
this.cmdCancel.TabIndex = 5;
this.cmdCancel.Text = "取消";
this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click);
//
// grpRM
//
this.grpRM.Controls.Add(this.txtRMExp);
this.grpRM.Controls.Add(this.txtRMMin);
this.grpRM.Controls.Add(this.txtRMMax);
this.grpRM.Controls.Add(this.txtRMCoef);
this.grpRM.Controls.Add(this.txtRMUnit);
this.grpRM.Controls.Add(this.txtRMDes);
this.grpRM.Controls.Add(this.txtRMName);
this.grpRM.Controls.Add(this.txtRMID);
this.grpRM.Controls.Add(this.label8);
this.grpRM.Controls.Add(this.label7);
this.grpRM.Controls.Add(this.label6);
this.grpRM.Controls.Add(this.label1);
this.grpRM.Controls.Add(this.label5);
this.grpRM.Controls.Add(this.label4);
this.grpRM.Controls.Add(this.label3);
this.grpRM.Controls.Add(this.label2);
this.grpRM.Location = new System.Drawing.Point(0, 168);
this.grpRM.Name = "grpRM";
this.grpRM.Size = new System.Drawing.Size(248, 296);
this.grpRM.TabIndex = 6;
this.grpRM.TabStop = false;
this.grpRM.Text = "詳細信息";
//
// txtRMExp
//
this.txtRMExp.Location = new System.Drawing.Point(118, 260);
this.txtRMExp.Name = "txtRMExp";
this.txtRMExp.TabIndex = 15;
this.txtRMExp.Text = "";
//
// txtRMMin
//
this.txtRMMin.Location = new System.Drawing.Point(118, 228);
this.txtRMMin.Name = "txtRMMin";
this.txtRMMin.TabIndex = 14;
this.txtRMMin.Text = "";
//
// txtRMMax
//
this.txtRMMax.Location = new System.Drawing.Point(118, 196);
this.txtRMMax.Name = "txtRMMax";
this.txtRMMax.Size = new System.Drawing.Size(96, 21);
this.txtRMMax.TabIndex = 13;
this.txtRMMax.Text = "";
//
// txtRMCoef
//
this.txtRMCoef.Location = new System.Drawing.Point(118, 164);
this.txtRMCoef.Name = "txtRMCoef";
this.txtRMCoef.TabIndex = 12;
this.txtRMCoef.Text = "";
//
// txtRMUnit
//
this.txtRMUnit.Location = new System.Drawing.Point(118, 132);
this.txtRMUnit.Name = "txtRMUnit";
this.txtRMUnit.TabIndex = 11;
this.txtRMUnit.Text = "";
//
// txtRMDes
//
this.txtRMDes.Location = new System.Drawing.Point(118, 100);
this.txtRMDes.Name = "txtRMDes";
this.txtRMDes.TabIndex = 10;
this.txtRMDes.Text = "";
//
// txtRMName
//
this.txtRMName.Location = new System.Drawing.Point(118, 68);
this.txtRMName.Name = "txtRMName";
this.txtRMName.TabIndex = 9;
this.txtRMName.Text = "";
//
// txtRMID
//
this.txtRMID.Location = new System.Drawing.Point(118, 36);
this.txtRMID.Name = "txtRMID";
this.txtRMID.ReadOnly = true;
this.txtRMID.TabIndex = 8;
this.txtRMID.Text = "";
//
// label8
//
this.label8.Location = new System.Drawing.Point(16, 264);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(72, 23);
this.label8.TabIndex = 7;
this.label8.Text = "公式";
//
// label7
//
this.label7.Location = new System.Drawing.Point(16, 232);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(72, 23);
this.label7.TabIndex = 6;
this.label7.Text = "最小值";
//
// label6
//
this.label6.Location = new System.Drawing.Point(16, 200);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(72, 23);
this.label6.TabIndex = 5;
this.label6.Text = "最大值";
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 136);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 23);
this.label1.TabIndex = 4;
this.label1.Text = "單位";
//
// label5
//
this.label5.Location = new System.Drawing.Point(16, 104);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(72, 23);
this.label5.TabIndex = 3;
this.label5.Text = "說明";
//
// label4
//
this.label4.Location = new System.Drawing.Point(16, 72);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(72, 23);
this.label4.TabIndex = 2;
this.label4.Text = "名稱";
//
// label3
//
this.label3.Location = new System.Drawing.Point(16, 168);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 23);
this.label3.TabIndex = 1;
this.label3.Text = "系數(shù)";
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 23);
this.label2.TabIndex = 0;
this.label2.Text = "標識";
//
// cmdDetail
//
this.cmdDetail.Location = new System.Drawing.Point(232, 120);
this.cmdDetail.Name = "cmdDetail";
this.cmdDetail.Size = new System.Drawing.Size(75, 32);
this.cmdDetail.TabIndex = 7;
this.cmdDetail.Text = "詳細>>";
this.cmdDetail.Click += new System.EventHandler(this.cmdDetail_Click);
//
// frmSetRM
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(328, 493);
this.Controls.Add(this.cmdDetail);
this.Controls.Add(this.grpRM);
this.Controls.Add(this.cmdCancel);
this.Controls.Add(this.lblPrompt);
this.Controls.Add(this.cmdOk);
this.Controls.Add(this.txtVal);
this.Name = "frmSetRM";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "遙測參數(shù)設置";
this.Load += new System.EventHandler(this.frmSetParameter1_Load);
this.grpRM.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void frmSetParameter1_Load(object sender, System.EventArgs e)
{//窗體載入初始化
int i=objForm.iSelFocus;
txtVal.Text="" + objForm.objRM[i].Val;
txtRMID.Text="" + objForm.objRM[i].ID;
txtRMName.Text=objForm.objRM[i].strName;
txtRMDes.Text=objForm.objRM[i].strDes;
txtRMUnit.Text=objForm.objRM[i].strUnit;
txtRMCoef.Text="" + objForm.objRM[i].iCoef;
txtRMMax.Text="" + objForm.objRM[i].iMax;
txtRMMin.Text="" + objForm.objRM[i].iMin;
txtRMExp.Text="" + objForm.objRM[i].iExp;
lblPrompt.Text=objForm.objRM[i].strDes;
}
private void button1_Click(object sender, System.EventArgs e)
{//確定
int i=objForm.iSelFocus;
if(txtRMName.Text=="" || txtRMDes.Text=="" || txtRMUnit.Text=="" ||
txtRMCoef.Text=="" || txtRMMax.Text=="" || txtRMMin.Text=="" || txtRMExp.Text=="")
{
MessageBox.Show("輸入信息中不能為空!","錯誤",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
if(!Regex.Match(txtRMCoef.Text,@"\d$").Success)
{
MessageBox.Show("輸入系數(shù)應為整型數(shù)字量!","錯誤",MessageBoxButtons.OK,MessageBoxIcon.Error);
txtRMCoef.Focus();
return;
}
if(!Regex.Match(txtRMMax.Text,@"\d$").Success)
{
MessageBox.Show("輸入最大值應為整型數(shù)字量!","錯誤",MessageBoxButtons.OK,MessageBoxIcon.Error);
txtRMMax.Focus();
return;
}
if(!Regex.Match(txtRMMin.Text,@"\d$").Success)
{
MessageBox.Show("輸入最小值應為整型數(shù)字量!","錯誤",MessageBoxButtons.OK,MessageBoxIcon.Error);
txtRMMin.Focus();
return;
}
if(!Regex.Match(txtRMExp.Text,@"\d$").Success)
{
MessageBox.Show("輸入公式應為整型數(shù)字量!","錯誤",MessageBoxButtons.OK,MessageBoxIcon.Error);
txtRMExp.Focus();
return;
}
if(!Regex.Match(txtVal.Text,@"\d{1}$").Success)
{
MessageBox.Show("輸入值應為整型數(shù)字量!","錯誤",MessageBoxButtons.OK,MessageBoxIcon.Error);
txtRMExp.Focus();
return;
}
objForm.objRM[i].Val=Int32.Parse(txtVal.Text.Trim());
objForm.objRM[i].strName=txtRMName.Text;
objForm.objRM[i].strDes=txtRMDes.Text;
objForm.objRM[i].strUnit=txtRMUnit.Text;
objForm.objRM[i].iCoef=Int32.Parse(txtRMCoef.Text.Trim());
objForm.objRM[i].iMax=Int32.Parse(txtRMMax.Text.Trim());
objForm.objRM[i].iMin=Int32.Parse(txtRMMin.Text.Trim());
objForm.objRM[i].iExp=Int32.Parse(txtRMExp.Text.Trim());
objForm.RefreshRMData();
this.Close();
}
private void cmdCancel_Click(object sender, System.EventArgs e)
{//取消
this.Close();
}
private void cmdDetail_Click(object sender, System.EventArgs e)
{//詳細
this.Close();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -