patrick.xu
2021-11-22 220f43bdfb1e1d1544c892697304f99e967103a4
MainForm.cs
@@ -137,6 +137,8 @@
            this.KeyPreview = true;
            this.KeyPress += MainForm_KeyPress;
            Trace.TraceInformation("键盘事件已加载");
            hcXyView.Focus();
        }
@@ -144,16 +146,28 @@
        CarrierBarcodeCtrl cBarcodeCtrl = null;
        private void MainForm_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 27)
            try
            {
                hcXyView.Focus();
            }
            else
            {
                if (allowBarcodeFlag)
                if (e.KeyChar == 27)
                {
                    cBarcodeCtrl.AddChar(e.KeyChar);
                    hcXyView.Focus();
                }
                else
                {
                    if (allowBarcodeFlag)
                    {
                        Trace.TraceInformation($"键盘输入:{e.KeyChar}");
                        cBarcodeCtrl.AddChar(e.KeyChar);
                    }
                    else
                    {
                        Trace.TraceInformation($"当前不允许按键输入:{e.KeyChar}");
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError($"键盘事件异常:{ex.Message}");
            }
        }
        #endregion
@@ -946,7 +960,6 @@
                    if ((bool)item.value)
                    {
                        //opc.Write(OPCInputTag.UnloadTrayReady, false);
                        allowBarcodeFlag = false;
                    }
                    break;