Browse Source

添加切孔委托消息

wb_han 5 years ago
parent
commit
133d6557f9

+ 11 - 11
HOZProject/FormHOZMain.Designer.cs

@@ -31,6 +31,7 @@
             this.plMain = new System.Windows.Forms.Panel();
             this.plFill = new System.Windows.Forms.Panel();
             this.plProcess = new System.Windows.Forms.Panel();
+            this.listmsg = new System.Windows.Forms.ListBox();
             this.plLeft = new System.Windows.Forms.Panel();
             this.label1 = new System.Windows.Forms.Label();
             this.plLeftContent = new System.Windows.Forms.Panel();
@@ -46,7 +47,6 @@
             this.pbSave = new System.Windows.Forms.PictureBox();
             this.pbNew = new System.Windows.Forms.PictureBox();
             this.pbOpen = new System.Windows.Forms.PictureBox();
-            this.listmsg = new System.Windows.Forms.ListBox();
             this.plMain.SuspendLayout();
             this.plFill.SuspendLayout();
             this.plLeft.SuspendLayout();
@@ -100,6 +100,16 @@
             this.plProcess.TabIndex = 2;
             this.plProcess.Visible = false;
             // 
+            // listmsg
+            // 
+            this.listmsg.FormattingEnabled = true;
+            this.listmsg.ItemHeight = 12;
+            this.listmsg.Location = new System.Drawing.Point(0, 1);
+            this.listmsg.Margin = new System.Windows.Forms.Padding(2);
+            this.listmsg.Name = "listmsg";
+            this.listmsg.Size = new System.Drawing.Size(524, 484);
+            this.listmsg.TabIndex = 18;
+            // 
             // plLeft
             // 
             this.plLeft.BackColor = System.Drawing.Color.Black;
@@ -289,16 +299,6 @@
             this.pbOpen.TabStop = false;
             this.pbOpen.Click += new System.EventHandler(this.pbOpen_Click);
             // 
-            // listmsg
-            // 
-            this.listmsg.FormattingEnabled = true;
-            this.listmsg.ItemHeight = 12;
-            this.listmsg.Location = new System.Drawing.Point(0, 1);
-            this.listmsg.Margin = new System.Windows.Forms.Padding(2);
-            this.listmsg.Name = "listmsg";
-            this.listmsg.Size = new System.Drawing.Size(524, 484);
-            this.listmsg.TabIndex = 18;
-            // 
             // FormHOZMain
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

+ 55 - 7
HOZProject/FormHOZMain.cs

@@ -47,7 +47,7 @@ namespace HOZProject
             m_Ms = new Measure();
             m_Ms.InitMeas(m_MeasureFile);
             m_Ms.SendThreadStatus += new ThreadStatusHandler(displayMessage); //注册事件
-
+            m_Ms.SendCutHolesStatus += new CutHolesStatusHandler(displayCutHoleMessage); //注册事件
             //自动测量的全过程
             m_Ms.DoMeasure();
             //定位
@@ -64,6 +64,14 @@ namespace HOZProject
                 this.listmsg.Items.Add(e.Time.ToString() + e.State);
             });
         }
+        public void displayCutHoleMessage(object sender, CutHolesStatusEventArgs e)
+        {
+            //主界面显示内容
+            this.BeginInvoke((Action)delegate
+            {
+                this.listmsg.Items.Add(e.HoleName.ToString() + e.State);
+            });
+        }
 
         void UpdateProgress(object sender, ProgressChangedEventArgs e)
         {
@@ -75,24 +83,25 @@ namespace HOZProject
         
         private void FormHOZMain_Load(object sender, EventArgs e)
         {
-            //CreateCutHoleList(5);
             //加载控件的点击事件
             this.Click += new EventHandler(FormHOZMain_Click);
             plFill.Click += new EventHandler(FormHOZMain_Click);
             plTop.Click += new EventHandler(FormHOZMain_Click);
             plLeft.Click += new EventHandler(FormHOZMain_Click);
             plLeftContent.Click += new EventHandler(FormHOZMain_Click);
+            //新建
+            NewCreate();
         }
 
-        public void CreateCutHoleList(int cutHoleCount)
+        public void CreateCutHoleList(List<CutHole> ListCutHole)
         {
             //清空左侧Panel中的切孔控件
             plLeftContent.Controls.Clear();
-            for (int i = 0; i < cutHoleCount; i++)
+            for (int i = ListCutHole.Count-1;i>=0; i--)
             {
                 UControl_CutHole ucCutHole = new UControl_CutHole(this);
                 ucCutHole.Dock = DockStyle.Top;
-                ucCutHole.CutHoleName = "切孔" + (i + 1);
+                ucCutHole.CutHoleName = ListCutHole[i].HoleName;
                 plLeftContent.Controls.Add(ucCutHole);
             }
         }
@@ -104,6 +113,39 @@ namespace HOZProject
                 plProcess.Visible = false;
             }
         }
+
+        /// <summary>
+        /// 修改切孔状态
+        /// </summary>
+        /// <param name="cutHoleCode"></param>
+        /// <param name="State"></param>
+        private void ChangeCutHoleState(string CutHoleName, int State)
+        {
+            foreach (Control item in plLeftContent.Controls)
+            {
+                if (item is UserControl)
+                {
+                    UControl_CutHole cutHole = (UControl_CutHole)item;
+                    if (cutHole.CutHoleName == CutHoleName)
+                    {
+                        Button btnCutHole = (Button)cutHole.Controls.Find("btnCutHole", false)[0];
+                        switch (State)
+                        {
+                            case 1:
+                                btnCutHole.BackColor = Color.Red;
+                                break;
+                            case 2:
+                                btnCutHole.BackColor = Color.Green;
+                                break;
+                            case 3:
+                                btnCutHole.BackColor = Color.Yellow;
+                                break;
+                        }
+                        break;
+                    }
+                }
+            }
+        }
         
         #region 窗体 最大化 最小化 关闭 按钮事件
         private void pbMin_MouseEnter(object sender, EventArgs e)
@@ -153,6 +195,11 @@ namespace HOZProject
 
         #region 新建、保存、打开、初始化、查看日志
         private void pbNew_Click(object sender, EventArgs e)
+        {
+            NewCreate();
+        }
+
+        private void NewCreate()
         {
             m_MeasureFile = new MeasureFile();
             if (!m_MeasureFile.New())
@@ -161,7 +208,7 @@ namespace HOZProject
             }
             else
             {
-                MessageBox.Show("新建测量文件成功。");
+                //MessageBox.Show("新建测量文件成功。");
             }
         }
 
@@ -232,7 +279,8 @@ namespace HOZProject
             {
                 m_BackgroundWorker.CancelAsync();
             }
-        } 
+        }
         #endregion
+        
     }
 }

+ 12 - 12
HOZProject/UserControls/UControl_Init.Designer.cs

@@ -33,7 +33,7 @@
             this.panel1 = new System.Windows.Forms.Panel();
             this.tbCutHoleFilePath = new System.Windows.Forms.TextBox();
             this.tBFIBTemp = new System.Windows.Forms.TextBox();
-            this.label2 = new System.Windows.Forms.Label();
+            this.lblCutHoleCount = new System.Windows.Forms.Label();
             this.label3 = new System.Windows.Forms.Label();
             this.label4 = new System.Windows.Forms.Label();
             this.tBSampleName = new System.Windows.Forms.TextBox();
@@ -100,16 +100,16 @@
             this.tBFIBTemp.Size = new System.Drawing.Size(214, 23);
             this.tBFIBTemp.TabIndex = 7;
             // 
-            // label2
+            // lblCutHoleCount
             // 
-            this.label2.AutoSize = true;
-            this.label2.Font = new System.Drawing.Font("宋体", 10F);
-            this.label2.ForeColor = System.Drawing.Color.LightGray;
-            this.label2.Location = new System.Drawing.Point(77, 73);
-            this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(112, 14);
-            this.label2.TabIndex = 8;
-            this.label2.Text = "成功导入0个切孔";
+            this.lblCutHoleCount.AutoSize = true;
+            this.lblCutHoleCount.Font = new System.Drawing.Font("宋体", 10F);
+            this.lblCutHoleCount.ForeColor = System.Drawing.Color.LightGray;
+            this.lblCutHoleCount.Location = new System.Drawing.Point(77, 73);
+            this.lblCutHoleCount.Name = "lblCutHoleCount";
+            this.lblCutHoleCount.Size = new System.Drawing.Size(112, 14);
+            this.lblCutHoleCount.TabIndex = 8;
+            this.lblCutHoleCount.Text = "成功导入0个切孔";
             // 
             // label3
             // 
@@ -234,7 +234,7 @@
             this.Controls.Add(this.tBSampleName);
             this.Controls.Add(this.label4);
             this.Controls.Add(this.label3);
-            this.Controls.Add(this.label2);
+            this.Controls.Add(this.lblCutHoleCount);
             this.Controls.Add(this.tBFIBTemp);
             this.Controls.Add(this.pbTemplateFile);
             this.Controls.Add(this.tbCutHoleFilePath);
@@ -260,7 +260,7 @@
         private System.Windows.Forms.TextBox tbCutHoleFilePath;
         private System.Windows.Forms.TextBox tBFIBTemp;
         private System.Windows.Forms.PictureBox pbTemplateFile;
-        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label lblCutHoleCount;
         private System.Windows.Forms.Label label3;
         private System.Windows.Forms.Label label4;
         private System.Windows.Forms.TextBox tBSampleName;

+ 5 - 2
HOZProject/UserControls/UControl_Init.cs

@@ -7,6 +7,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
+using MeasureData;
 
 namespace HOZProject
 {
@@ -40,8 +41,10 @@ namespace HOZProject
                 }
                 else
                 {
-                    int cutHoleCount = FormHOZMainObject.m_MeasureFile.ListCutHole.Count;
-                    FormHOZMainObject.CreateCutHoleList(cutHoleCount);
+                    List<CutHole> ListCutHole = FormHOZMainObject.m_MeasureFile.ListCutHole;
+                    FormHOZMainObject.CreateCutHoleList(ListCutHole);
+                    //显示导入的切孔数量
+                    lblCutHoleCount.Text = string.Format("成功导入{0}个切孔",ListCutHole.Count);
                 }
                 //this.CutHoleGridView.Rows.Clear();
                 //List<CutHole> listHoles = m_MeasureFile.ListCutHole;

+ 9 - 2
MeasureThread/Measure.cs

@@ -47,7 +47,6 @@ namespace MeasureThread
         {
             this.m_state = a_State;
         }
-
     }
     public class CutHolesStatusEventArgs
     {
@@ -186,7 +185,13 @@ namespace MeasureThread
             arg.Time = DateTime.Now;
             SendThreadStatus(this, arg);
         }
-
+        public void SendCutHoleMsg(string a_state, string a_holeName)
+        {
+            CutHolesStatusEventArgs arg = new CutHolesStatusEventArgs(a_state, a_holeName);
+            arg.HoleName = "";
+            arg.State = "";
+            SendCutHolesStatus(this, arg);
+        }
         //测量流程
         public void DoMeasure()
         {
@@ -227,6 +232,7 @@ namespace MeasureThread
                 if (i == 0)
                 {
                     SendMsg("第一个切孔开始测量");
+                    SendCutHoleMsg("1", m_cutHoles[i].HoleName);
                     firstPosition = iSEM.GetStagePosition();
                     //第一个孔的测试
                     FirstHole();
@@ -235,6 +241,7 @@ namespace MeasureThread
                 {
                     //非第一个孔的测试
                     SendMsg("第" + i.ToString() + "个切孔开始测量");
+                    SendCutHoleMsg("1", m_cutHoles[i].HoleName);
                     OtherHole();
                 }
             }