From d511823e84953e616da9a24484d730c49c457c08 Mon Sep 17 00:00:00 2001
From: xcd <834800634@qq.com>
Date: 星期二, 14 七月 2020 08:54:16 +0800
Subject: [PATCH] 更改M071主界面按钮鼠标样式

---
 src/Bro.UI.Config/MenuForms/FrmOperation.cs |   65 ++++++++++++++++++++++++--------
 1 files changed, 49 insertions(+), 16 deletions(-)

diff --git a/src/Bro.UI.Config/MenuForms/FrmOperation.cs b/src/Bro.UI.Config/MenuForms/FrmOperation.cs
index 74ba196..455f1aa 100644
--- a/src/Bro.UI.Config/MenuForms/FrmOperation.cs
+++ b/src/Bro.UI.Config/MenuForms/FrmOperation.cs
@@ -1,5 +1,6 @@
 锘縰sing Bro.Common.Factory;
 using Bro.Common.Helper;
+using Bro.Common.PubSub;
 using Bro.UI.Model.Winform;
 using System;
 using System.Collections.Generic;
@@ -9,6 +10,7 @@
 using System.Threading.Tasks;
 using System.Windows.Forms;
 using WeifenLuo.WinFormsUI.Docking;
+using static Bro.Common.Helper.EnumHelper;
 
 namespace Bro.UI.Config.MenuForms
 {
@@ -20,25 +22,38 @@
         public FrmOperation()
         {
             InitializeComponent();
+            PubSubCenter.GetInstance().RemoveSubscribers(PubSubCenterMessageType.UpdateProductionCodes.ToString());
+            PubSubCenter.GetInstance().Subscribe(PubSubCenterMessageType.UpdateProductionCodes.ToString(), OnUpdateProductionCodes);
 
             LoadProcessCode();
             LoadProductionCode();
 
-            Task.Run(() =>
-            {
-                Thread.Sleep(1000);
+            //Task.Run(() =>
+            //{
+            //    Thread.Sleep(1000);
 
-                if ((!plProcess.Visible) && (!plProduct.Visible) && _isFirstLoad)
-                {
-                    LoadProcess();
-                    _isFirstLoad = false;
-                }
-            });
+            //    if ((!plProcess.Visible) && (!plProduct.Visible) && _isFirstLoad)
+            //    {
+            //        LoadProcess();
+            //        _isFirstLoad = false;
+            //    }
+            //});
+            //if ((!plProcess.Visible) && (!plProduct.Visible) && _isFirstLoad)
+            //{
+            //    LoadProcess();
+            //    _isFirstLoad = false;
+            //}
         }
 
         #region Load Codes
         string _processCode = "";
         string _productionCode = "";
+
+        private object OnUpdateProductionCodes(ISubscriber arg1, object arg2, object arg3)
+        {
+            LoadProductionCode();
+            return null;
+        }
 
         private void LoadProcessCode()
         {
@@ -118,6 +133,12 @@
 
         private void FrmOperation_Load(object sender, System.EventArgs e)
         {
+            //if ((!plProcess.Visible) && (!plProduct.Visible) && _isFirstLoad)
+            //{
+            //    LoadProcess();
+            //    _isFirstLoad = false;
+            //}
+
             btnStart.Enabled = true;
         }
 
@@ -130,7 +151,7 @@
         }
 
         bool isStart = true;
-        private void btnStart_Click(object sender, System.EventArgs e)
+        private async void btnStart_Click(object sender, System.EventArgs e)
         {
             if (Process == null)
             {
@@ -140,16 +161,18 @@
 
             btnStart.Enabled = false;
 
+            //Task.Run(() =>
+            //{
             try
             {
                 //if (Process.ProcessState != EnumHelper.DeviceState.DSOpen)
-                if(isStart)
+                if (isStart)
                 {
-                    ProcessOperation(true);
+                    await ProcessOperation(true);
                 }
                 else
                 {
-                    ProcessOperation(false);
+                    await ProcessOperation(false);
                 }
 
                 isStart = !isStart;
@@ -160,8 +183,10 @@
             }
             finally
             {
+                //this.BeginInvoke(new Action(() => btnStart.Enabled = true));
                 btnStart.Enabled = true;
             }
+            //});
         }
 
         string _currentProcssCode = "";
@@ -180,6 +205,7 @@
                 }
 
                 //Process.OnProcessStateChanged += Process_OnProcessStateChanged;
+                Process.OnLog -= Process_OnLog;
                 Process.OnLog += Process_OnLog;
 
                 _currentProcssCode = _processCode;
@@ -242,27 +268,34 @@
         //    }
         //}
 
-        private void ProcessOperation(bool isStart)
+        private async Task ProcessOperation(bool isStart)
         {
             if (isStart)
             {
-                Process.Open();
+                await Task.Run(() => Process.Open());
 
+                //this.BeginInvoke(new Action(() =>
+                //{
                 btnStart.Text = "  鍋�  姝�";
                 btnStart.ImageIndex = 1;
                 btnStart.BackColor = Color.FromArgb(0x7f, Color.LimeGreen);
 
                 btnLoad.Enabled = false;
+                //}));
+
             }
             else
             {
-                Process.Close();
+                await Task.Run(() => Process.Close());
 
+                //this.BeginInvoke(new Action(() =>
+                //{
                 btnStart.Text = "  鍚�  鍔�";
                 btnStart.ImageIndex = 0;
                 btnStart.BackColor = SystemColors.Control;
 
                 btnLoad.Enabled = true;
+                //}));
             }
         }
     }

--
Gitblit v1.8.0