领胜LDS 键盘AOI检测项目
src/Bro.M071.Process/UI/M071_MainForm.cs
@@ -1,13 +1,16 @@
using Bro.Common.Base;
using Bro.Common.Helper;
using Bro.UI.Model.Winform;
using Bro.UI.Model.Winform.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using static Bro.Common.Helper.EnumHelper;
@@ -44,6 +47,8 @@
                   timer1.Enabled = true;
                   btnReset.Text = $"复位(长按{Config.FullResetRequiredDuration}秒大复位)";
                   lblCT.Text = tsslError.Text = "";
               };
        }
@@ -90,6 +95,8 @@
                           item.Tag = u.Id;
                           lvMeasures.Items.Add(item);
                       });
                       lblOperator.Text = string.IsNullOrWhiteSpace(Process_M071.OperatorCode) ? "NotLogin" : Process_M071.OperatorCode;
                   }));
            }
            catch (Exception ex)
@@ -112,11 +119,25 @@
            Process_M071.OnFullResetDone -= Process_M071_FullResetDone;
            Process_M071.OnFullResetDone += Process_M071_FullResetDone;
            Process_M071.OnResetDone -= Process_M071_ResetDone;
            Process_M071.OnResetDone += Process_M071_ResetDone;
            Config.PropertyChanged -= Config_PropertyChanged;
            Config.PropertyChanged += Config_PropertyChanged;
            Process_M071.OnElementUpdated -= Process_M071_OnElementUpdated;
            Process_M071.OnElementUpdated += Process_M071_OnElementUpdated;
            Process_M071.OnCheckHintUpload = OnCheckHintUpload;
            Process_M071.OnOperatorLogin = OnOperatorLogin;
        }
        private void Process_M071_ResetDone()
        {
            lblCT.BeginInvoke(new Action(() =>
            {
                lblCT.Text = "";
            }));
        }
        private void Config_PropertyChanged(object sender, PropertyChangedEventArgs e)
@@ -309,10 +330,14 @@
            {
                _barcode += keyStr.Substring(1).ToUpper();
            }
            else if (keyStr.StartsWith("NumPad"))
            {
                _barcode += keyStr.Replace("NumPad", "");
            }
            if (e.KeyValue == 13)
            {
                txtBarcode.Text = _barcode;
                Process_M071.BarCode = txtBarcode.Text = _barcode;
                _barcode = "";
            }
@@ -324,7 +349,7 @@
        private void txtBarcode_TextChanged(object sender, EventArgs e)
        {
            Process_M071.BarCode = txtBarcode.Text.Trim();
            //Process_M071.BarCode = txtBarcode.Text.Trim();
        }
        private void M071_MainForm_OnClearBarcode()
@@ -409,11 +434,17 @@
                    lblProductionState.ForeColor = Color.White;
                    lblProductionState.Text = "OK";
                }
                else
                else if (result == 0)
                {
                    lblProductionState.BackColor = Color.Red;
                    lblProductionState.ForeColor = Color.White;
                    lblProductionState.Text = "NG";
                }
                else
                {
                    lblProductionState.BackColor = Color.White;
                    lblProductionState.ForeColor = Color.Red;
                    lblProductionState.Text = "NA";
                }
                //btnStartMeasure.Text = "开始测量";
@@ -504,5 +535,44 @@
        {
            cvImage.Refresh();
        }
        private void lblOperator_DoubleClick(object sender, EventArgs e)
        {
            InputWindow inputFrm = new InputWindow("请输入操作员工号");
            if (inputFrm.ShowDialog() == DialogResult.OK)
            {
                Process_M071.OperatorCode = inputFrm.Input;
            }
        }
        private void OnOperatorLogin(string operatorCode)
        {
            this.Invoke(new Action(() =>
            {
                lblOperator.Text = operatorCode;
            }));
        }
        private async void OnCheckHintUpload(string hintMsg, bool isAlarm)
        {
            await Task.Run(() =>
            {
                this.Invoke(new Action(() =>
                {
                    if (!string.IsNullOrWhiteSpace(hintMsg))
                    {
                        stStripHint.Visible = true;
                        tsslError.Text = hintMsg;
                        tsslError.BackColor = isAlarm ? Color.Red : Color.Green;
                    }
                    else
                    {
                        stStripHint.Visible = false;
                        tsslError.Text = "";
                    }
                }));
            });
        }
    }
}