/// <summary> /// 非标准键盘响应事件对应的方法 /// </summary> /// <param name="pType">数据类型</param> /// <param name="pData">数据(数据类型为命令时,pData为空。)</param> /// <param name="pCommand">键盘命令</param> void ikb_OnReceivedKeyData(KeyDataType pType, string pData, KeyCommand pCommand) { if (pType == KeyDataType.COMMAND)//表示命令 { bool isCloseForm = false; if (pCommand == KeyCommand.OK)//按了确定键 { isCloseForm = true; IsOk = true; } else if (pCommand == KeyCommand.CANCEL)//按了取消键 { isCloseForm = true; IsOk = false; } else if (pCommand == KeyCommand.CLEAR)//按了清空键 { this.businessNoTextBlock.Text = string.Empty; } else if (pCommand == KeyCommand.DELETE)//按了删除键 { if (this.businessNoTextBlock.Text.Trim().Length >= 2) { string curBusinessNo = this.businessNoTextBlock.Text.Trim(); this.businessNoTextBlock.Text = curBusinessNo.Substring(0, curBusinessNo.Length - 1); } else { this.businessNoTextBlock.Text = string.Empty; } } else if (pCommand == KeyCommand.HELP)//按了求助键 { isCloseForm = true; IsHelp = true; } if (isCloseForm) { ikb.Stop(); ikb.Close(); this.BussinessNo = this.businessNoTextBlock.Text.Trim(); System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { this.Close(); })); } } else if (pType == KeyDataType.DATA)//按了键盘中的数字键 { this.businessNoTextBlock.Text = this.businessNoTextBlock.Text.Trim() + pData; } }
void ikb_OnReceivedKeyData(KeyDataType pType, string pData, KeyCommand pCommand) { if (pType == KeyDataType.COMMAND)//表示命令 { ikb.Stop(); ikb.Close(); if (pCommand == KeyCommand.OK)//按了确定键 { IsOk = true; // this.Close(); } else { IsOk = false; // this.Close(); } System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { this.Close(); })); } else if (pType == KeyDataType.DATA)//按了取消键 { } }