Pārlūkot izejas kodu

添加显示切孔测量当前进度、修改切孔状态、线程停止

wb_han 5 gadi atpakaļ
vecāks
revīzija
0ec9e2525c

+ 1 - 1
HOZProject/FormHOZMain.Designer.cs

@@ -164,7 +164,7 @@
             // plPrarInfo
             // 
             this.plPrarInfo.BackColor = System.Drawing.Color.White;
-            this.plPrarInfo.Location = new System.Drawing.Point(1, 1);
+            this.plPrarInfo.Location = new System.Drawing.Point(0, 0);
             this.plPrarInfo.Name = "plPrarInfo";
             this.plPrarInfo.Size = new System.Drawing.Size(218, 100);
             this.plPrarInfo.TabIndex = 2;

+ 52 - 17
HOZProject/FormHOZMain.cs

@@ -20,7 +20,7 @@ namespace HOZProject
     public partial class FormHOZMain : Form
     {
         #region 成员变量
-        private BackgroundWorker m_BackgroundWorker;// 申明后台对象
+        public BackgroundWorker m_BackgroundWorker;// 申明后台对象
         /// <summary>
         /// 测量文件
         /// </summary>
@@ -127,6 +127,7 @@ namespace HOZProject
         void CompletedWork(object sender, RunWorkerCompletedEventArgs e)
         {
             //设置控件操作
+            MessageBox.Show("线程已完成!");
             SetWinControlMeasureState(true);
         }
         #endregion
@@ -206,7 +207,7 @@ namespace HOZProject
         /// 设置控件在线程过程中的编辑状态
         /// </summary>
         /// <param name="cState"></param>
-        private void SetWinControlMeasureState(bool cState)
+        public void SetWinControlMeasureState(bool cState)
         {
             pbNew.Enabled = cState;
             pbOpen.Enabled = cState;
@@ -455,14 +456,14 @@ namespace HOZProject
             }
         }
         #endregion
-        
+
         #region 修改切孔状态
         /// <summary>
         /// 修改切孔状态
         /// </summary>
         /// <param name="cutHoleCode"></param>
-        /// <param name="State"></param>
-        private void ChangeCutHoleState(string CutHoleName, int State)
+        /// <param name="States"></param>
+        private void ChangeCutHoleState(string CutHoleName, int States)
         {
             foreach (Control item in plLeftContent.Controls)
             {
@@ -472,26 +473,62 @@ namespace HOZProject
                     if (cutHole.CutHoleName == CutHoleName)
                     {
                         Button btnCutHole = (Button)cutHole.Controls.Find("btnCutHole", false)[0];
-                        switch (State)
+                        switch (States)
                         {
                             //开始运行
-                            case (int)ThreadState.InProcess:
+                            case (int)State.Unmeasured:
                                 btnCutHole.BackColor = Color.Yellow;
                                 break;
+                            //失败
+                            case (int)State.Failed:
+                                btnCutHole.BackColor = Color.Red;
+                                ChangeCutHoleMeasureState(CutHoleName, States);
+                                break;
                             //完成
-                            case (int)ThreadState.Success:
+                            case (int)State.Success:
                                 btnCutHole.BackColor = Color.GreenYellow;
-                                break;
-                            //错误
-                            case (int)ThreadState.Failed:
-                                btnCutHole.BackColor = Color.Red;
+                                //修改切孔状态
+                                ChangeCutHoleMeasureState(CutHoleName, States);
                                 break;
                         }
                         break;
                     }
                 }
             }
-        } 
+        }
+        #endregion
+
+        #region 修改切孔状态
+        protected void ChangeCutHoleMeasureState(string CutHoleName, int States)
+        {
+            if (plPrarInfo.Controls.Count > 0)
+            {
+                foreach (Control item in plPrarInfo.Controls)
+                {
+                    if (item is UserControl)
+                    {
+                        if (item.Name == CutHoleName)
+                        {
+                            UControl_ParaInfo uControl_ParaInfo = (UControl_ParaInfo)item;
+
+                            switch (States)
+                            {
+                                //完成
+                                case (int)State.Success:
+                                    //修改切孔状态
+                                    uControl_ParaInfo.lblShowState.Text = "完成";
+                                    break;
+                                //失败
+                                case (int)State.Failed:
+                                    uControl_ParaInfo.lblShowState.Text = "失败";
+                                    break;
+                            }
+                            break;
+                        }
+                    }
+                }
+            }
+        }
         #endregion
 
         #region 拖动无窗体的控件
@@ -541,10 +578,8 @@ namespace HOZProject
 
         private void pbStop_Click(object sender, EventArgs e)
         {
-            if (m_BackgroundWorker.IsBusy)
-            {
-                m_BackgroundWorker.CancelAsync();
-            }
+            //线程停止变量
+            m_Ms.key_stop = true;
         }
         #endregion
 

+ 13 - 18
HOZProject/MeasureMsgDispose/MeasureMsgManage.cs

@@ -25,24 +25,17 @@ namespace HOZProject
         /// <param name="args">消息对象</param>
         public static void ShowMsgContent(FormHOZMain formHOZ, ThreadStatusEventArgs args)
         {
-            #region 原方法判断,流程中的数据显示
-            //switch (args.Step_Code)
-            //{
-            //    case "1-3":
-            //        //设置图像
-            //        FileStream fileStream = new FileStream(args.Picture_Information.Picture_FullPath, FileMode.Open, FileAccess.Read);
-            //        formHOZ.pbImage.Image = Image.FromStream(fileStream);
-            //        fileStream.Close();
-            //        fileStream.Dispose();
-            //        //流程内容
-            //        string semParaContent = "电压:"+args.Picture_Information.Work_Voltage;
-            //        semParaContent += "  放大倍数:" + args.Picture_Information.Magnification;
-            //        semParaContent += "  工作距离:" + args.Picture_Information.Work_Distance;
-            //        formHOZ.lblFlowContent.Text = semParaContent;
-            //        break;
-            //    default:
-            //        break;
-            //} 
+            #region 判断线程是否停止
+            switch (args.Step_Code)
+            {
+                case "0-0":
+                    //停止线程
+                    if (formHOZ.m_BackgroundWorker.IsBusy)
+                    {
+                        formHOZ.m_BackgroundWorker.CancelAsync();
+                    }
+                    break;
+            }
             #endregion
             if (IsCutHolePhotoInfo(formHOZ, args))
             {
@@ -123,6 +116,8 @@ namespace HOZProject
                                     break;
                                 }
                             }
+                            //更新进度条
+                            uControl_ParaInfo.UpdateCurrentMeasureSchedule();
                             //重新绘制
                             uControl_ParaInfo.TimeLineInvalidate();
                             return true;

+ 9 - 8
HOZProject/UserControls/UControl_CutHole.cs

@@ -53,14 +53,15 @@ namespace HOZProject
         {
             //显示处理信息
             ShowParaControl(UControl_ParaInfo.Name);
-            if (FormHOZMainObject.plPrarInfo.Visible)
-            {
-                FormHOZMainObject.plPrarInfo.Visible = false;
-            }
-            else
-            {
-                FormHOZMainObject.plPrarInfo.Visible = true;
-            }
+            //if (FormHOZMainObject.plPrarInfo.Visible)
+            //{
+            //    FormHOZMainObject.plPrarInfo.Visible = false;
+            //}
+            //else
+            //{
+            //    FormHOZMainObject.plPrarInfo.Visible = true;
+            //}
+            FormHOZMainObject.plPrarInfo.Visible = true;
         }
 
         /// <summary>

+ 23 - 9
HOZProject/UserControls/UControl_ParaInfo.Designer.cs

@@ -59,9 +59,10 @@
             this.imageList1 = new System.Windows.Forms.ImageList(this.components);
             this.panel3 = new System.Windows.Forms.Panel();
             this.label1 = new System.Windows.Forms.Label();
-            this.progressBar1 = new System.Windows.Forms.ProgressBar();
+            this.pbMeasure = new System.Windows.Forms.ProgressBar();
             this.panel4 = new System.Windows.Forms.Panel();
             this.label8 = new System.Windows.Forms.Label();
+            this.lblCompletedAmount = new System.Windows.Forms.Label();
             this.panel1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.pbClose)).BeginInit();
             this.plMeasureFlow.SuspendLayout();
@@ -381,8 +382,9 @@
             // 
             this.panel3.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
             this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+            this.panel3.Controls.Add(this.lblCompletedAmount);
             this.panel3.Controls.Add(this.label1);
-            this.panel3.Controls.Add(this.progressBar1);
+            this.panel3.Controls.Add(this.pbMeasure);
             this.panel3.Dock = System.Windows.Forms.DockStyle.Bottom;
             this.panel3.Location = new System.Drawing.Point(0, 413);
             this.panel3.Name = "panel3";
@@ -400,12 +402,13 @@
             this.label1.TabIndex = 1;
             this.label1.Text = "检测总进度";
             // 
-            // progressBar1
+            // pbMeasure
             // 
-            this.progressBar1.Location = new System.Drawing.Point(88, 16);
-            this.progressBar1.Name = "progressBar1";
-            this.progressBar1.Size = new System.Drawing.Size(183, 14);
-            this.progressBar1.TabIndex = 0;
+            this.pbMeasure.Location = new System.Drawing.Point(88, 16);
+            this.pbMeasure.Name = "pbMeasure";
+            this.pbMeasure.Size = new System.Drawing.Size(212, 14);
+            this.pbMeasure.Step = 1;
+            this.pbMeasure.TabIndex = 0;
             // 
             // panel4
             // 
@@ -429,6 +432,16 @@
             this.label8.TabIndex = 3;
             this.label8.Text = "检测流程";
             // 
+            // lblCompletedAmount
+            // 
+            this.lblCompletedAmount.AutoSize = true;
+            this.lblCompletedAmount.ForeColor = System.Drawing.Color.White;
+            this.lblCompletedAmount.Location = new System.Drawing.Point(308, 18);
+            this.lblCompletedAmount.Name = "lblCompletedAmount";
+            this.lblCompletedAmount.Size = new System.Drawing.Size(17, 12);
+            this.lblCompletedAmount.TabIndex = 2;
+            this.lblCompletedAmount.Text = "0%";
+            // 
             // UControl_ParaInfo
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -482,7 +495,6 @@
         private System.Windows.Forms.Label lblX;
         private System.Windows.Forms.Label lblShowStartTime;
         private System.Windows.Forms.Label lblShowEndTime;
-        private System.Windows.Forms.Label lblShowState;
         private System.Windows.Forms.Label lblY;
         private System.Windows.Forms.Label lblZ;
         private System.Windows.Forms.Label lblM;
@@ -499,10 +511,12 @@
         private System.Windows.Forms.ImageList imageList1;
         private System.Windows.Forms.Panel panel3;
         private System.Windows.Forms.Label label1;
-        private System.Windows.Forms.ProgressBar progressBar1;
+        private System.Windows.Forms.ProgressBar pbMeasure;
         private System.Windows.Forms.Panel panel4;
         private System.Windows.Forms.Label label8;
         private System.Windows.Forms.PictureBox pbClose;
         private System.Windows.Forms.Panel plTimeLine;
+        public System.Windows.Forms.Label lblShowState;
+        private System.Windows.Forms.Label lblCompletedAmount;
     }
 }

+ 31 - 12
HOZProject/UserControls/UControl_ParaInfo.cs

@@ -55,28 +55,47 @@ namespace HOZProject
             ShowMeasureFlow();
         }
 
-        #region 关闭属性层
-        private void btnClose_Click(object sender, EventArgs e)
+        #region 当前进度
+        public void UpdateCurrentMeasureSchedule()
         {
-            foreach (Control item in FormHOZMainObject.plFill.Controls)
+            if (TlItem != null)
             {
-                if (item is Panel)
+                //完成状态数量
+                int finishCount = 0;
+                //未完成状态数量
+                int unFinishedCount = 0;
+                foreach (TimeLineItem item in TlItem)
                 {
-                    foreach (Control itemControl in item.Controls)
+                    if (item.State == (int)MeasureData.State.Success)
+                    {
+                        finishCount++;
+                    }
+                    if (item.State != (int)MeasureData.State.Success)
                     {
-                        if (itemControl.Name == this.Name)
-                        {
-                            item.Controls.Remove(this);
-                            this.Dispose();
-                            item.Visible = false;
-                            break;
-                        }
+                        unFinishedCount++;
                     }
                 }
+                try
+                {
+                    pbMeasure.Value = finishCount / unFinishedCount;
+                    lblCompletedAmount.Text = finishCount / unFinishedCount + "%";
+                }
+                catch (Exception)
+                {
+
+                    pbMeasure.Value = 0;
+                }
             }
         }
         #endregion
 
+        #region 隐藏属性层
+        private void btnClose_Click(object sender, EventArgs e)
+        {
+            FormHOZMainObject.plPrarInfo.Visible = false;
+        }
+        #endregion
+
         #region 重绘时间轴
         /// <summary>
         /// 重绘时间轴

+ 1 - 1
HOZProject/UserControls/UControl_ParaInfo.resx

@@ -125,7 +125,7 @@
         AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
         LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
         ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAS
-        GAAAAk1TRnQBSQFMAgEBBQEAAVABAAFQAQABIAEAASABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
+        GAAAAk1TRnQBSQFMAgEBBQEAAVgBAAFYAQABIAEAASABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
         AwABgAMAAUADAAEBAQABCAYAASAYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
         AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
         AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA