Пример #1
0
 //输出数据触发器
 private void ReadCommadeText()
 {
     if (ReadCommandtEvent != null)
     {
         //记录指令
         if (!string.IsNullOrEmpty(CommandStr) && !commandList.Contains(CommandStr))
         {
             commandList.Add(CommandStr);
             ItemIndex++;
         }
         //执行指令,反馈执行结果内容
         string commandHandle = "命令" + CommandStr + "处理结果!";
         if (CommandStr.ToLower().Equals("cls"))
         {
             ReadCommandtEvent(this, ConsoleEditEventArgs.CreatEventArgs(CommandStr));
         }
         else
         {
             if (string.IsNullOrEmpty(CommandStr))
             {
                 return;
             }
             if (usbHid.CommandCheckInitPort())
             {
                 byte[] res = System.Text.ASCIIEncoding.Default.GetBytes(CommandStr);
                 usbHid.hidDevice.Write(res, 0, res.Length);
             }
             else
             {
                 commandHandle = "设备连接有误!";
                 ReadCommandtEvent(this, ConsoleEditEventArgs.CreatEventArgs(commandHandle));
             }
         }
     }
 }
Пример #2
0
 public void ReturnMessData(string commandHandle)
 {
     ReadCommandtEvent(this, ConsoleEditEventArgs.CreatEventArgs(commandHandle));
     this.MyCommand.Dispatcher.Invoke(new Action(delegate {
         InputLineNum = this.MyCommand.Text.Length - 1;
         this.Focus();
     }));
 }
Пример #3
0
 private void consoleTextBox1_ReadCommandtEvent(object sender, ConsoleEditEventArgs e)
 {
     if (e.Message.ToLower() == "cls")
     {
         this.MyCommandWindow.Clear();
     }
     else if (!string.IsNullOrEmpty(e.Message))
     {
         this.MyCommandWindow.Write(e.Message);
     }
     else
     {
         this.MyCommandWindow.Write("错误的输入");
     }
 }