Example #1
0
 /// <summary>
 /// 打开键盘
 /// </summary>
 static void OpenKeyBoard()
 {
     usbLib.OnDataReceivedEvent += (s, e) =>
     {
         Console.Write(e.ScanCode);
         if (Form.ActiveForm != null && Form.ActiveForm is BaseForm)
         {
             BaseForm frm     = Form.ActiveForm as BaseForm;
             string   appCode = frm.KeyCode.GetKeyCode(e.ScanCode);
             Console.Write("\t" + appCode);
             //frm.DoWithKeyCode(keyCode);
             frm.BeginInvoke(new DoWithAppCodeHander(frm.DoWithAppCode), new object[] { appCode });
         }
         Console.WriteLine();
     };
     usbLib.OnUsbGlobalErrorEvent += (s, e) =>
     {
         try
         {
             IsNeedRestart = true;
             if (Form.ActiveForm != null && Form.ActiveForm is BaseForm)
             {
                 BaseForm frm = Form.ActiveForm as BaseForm;
                 frm.BeginInvoke(new DoWithAppCodeHander(frm.ThrowException), new object[] { e.ToString() });
             }
             //记录按键使用频率功能。
             MedicalSystem.Anes.Core.Log.LogHelper.WriteErrLog(e.ToString(), new Exception());
         }
         catch { }
     };
     usbLib.OpenDevice();
 }