private void CommandProcess(object sender, ConsoleReadLineEventArgs eventArgs) { var command = new string[eventArgs.Commands.Length]; for (var i = 0; i < eventArgs.Commands.Length; i++) { command[i] = eventArgs.Commands[i].ToLower(); } if (command.Length > 0) { try { switch (command[0]) { case "clear": ProcessClear(command); break; case "demo": ProcessParagraph(command); break; case "exit": _commandPrompt.Close(); _commandPrompt = null; Close(); break; case "get": ProcessGet(command); break; case "help": ProcessHelp(command); break; case "list": ProcessList(command); break; case "load": ProcessLoad(command); break; case "reset": ProcessReset(command); break; case "save": ProcessSave(command); break; case "set": ProcessSet(command); break; default: WriteToConsole( new ConsoleWriteLineEventArgs("Command not recognized: " + command[0] + " (Type 'help' for a list of commands)")); break; } } catch (Exception ex) { WriteToConsole(new ConsoleWriteLineEventArgs("Console Error: \r" + ex.Message)); } } }
/// <summary> /// Called on a console read line update event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="WPFCommandPrompt.ConsoleReadLineEventArgs" /> instance containing the event data.</param> public void OnConsoleReadEvent(object sender, ConsoleReadLineEventArgs e) { if (ConsoleReadLine != null) { ConsoleReadLine(this, e); } }
/// <summary> /// Called on a console read line upate event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="WPFCommandPrompt.ConsoleReadLineEventArgs" /> instance containing the event data.</param> public void OnConsoleReadEvent(object sender, ConsoleReadLineEventArgs e) { if (ReadLine != null) { ReadLine(this, e); } }