| | |
| | | using Bro.Common.Factory; |
| | | using Bro.Common.Helper; |
| | | using Bro.Common.PubSub; |
| | | using Bro.UI.Model.Winform; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | using WeifenLuo.WinFormsUI.Docking; |
| | | using static Bro.Common.Helper.EnumHelper; |
| | | |
| | | namespace Bro.UI.Config.MenuForms |
| | | { |
| | |
| | | public FrmOperation() |
| | | { |
| | | InitializeComponent(); |
| | | PubSubCenter.GetInstance().RemoveSubscribers(PubSubCenterMessageType.UpdateProductionCodes.ToString()); |
| | | PubSubCenter.GetInstance().Subscribe(PubSubCenterMessageType.UpdateProductionCodes.ToString(), OnUpdateProductionCodes); |
| | | |
| | | LoadProcessCode(); |
| | | LoadProductionCode(); |
| | |
| | | #region Load Codes |
| | | string _processCode = ""; |
| | | string _productionCode = ""; |
| | | |
| | | private object OnUpdateProductionCodes(ISubscriber arg1, object arg2, object arg3) |
| | | { |
| | | LoadProductionCode(); |
| | | return null; |
| | | } |
| | | |
| | | private void LoadProcessCode() |
| | | { |
| | |
| | | } |
| | | |
| | | 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) |
| | | { |
| | |
| | | |
| | | 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; |
| | |
| | | } |
| | | finally |
| | | { |
| | | //this.BeginInvoke(new Action(() => btnStart.Enabled = true)); |
| | | btnStart.Enabled = true; |
| | | } |
| | | //}); |
| | | } |
| | | |
| | | string _currentProcssCode = ""; |
| | |
| | | // } |
| | | //} |
| | | |
| | | 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; |
| | | //})); |
| | | } |
| | | } |
| | | } |