예제 #1
0
 private void CommandPromptOnOnCompleteCommand(object sender, CommandPromptEventArgs commandPromptEventArgs)
 {
     var completeItems = Console.CompleteCommandLine(commandPromptEventArgs.CommandLine);
     if (completeItems.Length == 0)
     {
         // do nothing
     }
     else if (completeItems.Length == 1)
     {
         // no arguments in command prompt
         if (commandPromptEventArgs.CommandLine.IndexOf(" ", StringComparison.OrdinalIgnoreCase) == -1)
         {
             // full command already entered. Add space at the end.
             if (completeItems[0].Length == commandPromptEventArgs.CommandLine.Length)
             {
                 UpdateCommandPrompt(completeItems[0] + " ");
             }
             else // otherwise just replace with commnad (might be different case)
             {
                 UpdateCommandPrompt(commandPrompt.text = completeItems[0]);
             }
         }
         else // arguments was in the prompt
         {
             // just add text. Command auto complete should decide what to return
             UpdateCommandPrompt(commandPrompt.text + completeItems[0]);
         }
     }
     else
     {
         output.text += string.Join("\n", completeItems);
         output.MoveCaretToEnd();
     }
 }
예제 #2
0
 protected static void OnMessageReceived(object sender, CommandPromptEventArgs e)
 {
     if (e.IsError)
     {
         string sendstring = "[ERROR] " + e.Message; writey.WriteLine(sendstring);
     }
     else
     {
         string sendstring = e.Message; writey.WriteLine(sendstring);
     }
 }
예제 #3
0
 /// <summary>
 /// 获取当前状态
 /// </summary>
 private void GetStatus()
 {
     if (EAction != null)
     {
         string ss = EAction.GetCommandStatus();
         if (Prompt != null)
         {
             CommandPromptEventArgs args = new CommandPromptEventArgs(ss);
             Prompt(args);
         }
     }
 }
예제 #4
0
 /// <summary>
 /// 当前绘制面板的操作提示
 /// </summary>
 /// <param name="cp"></param>
 private void DrawingKernel_Prompt(CommandPromptEventArgs cp)
 {
     this.DrawTipLab.Content = cp.Message;
 }
예제 #5
0
 private void CommandPromptOnOnExecuteCommand(object sender, CommandPromptEventArgs eventArgs)
 {
     try
     {
         Console.ExecuteCommandLine(eventArgs.CommandLine);
     }
     catch (ConsoleCommandNotRegistered ex)
     {
         output.text += "\n" + ex.CommandName + " is not registered";
     }
 }