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)); } } }
public MainWindow() { InitializeComponent(); CreateHelpDictionary(); _commandPrompt = new WpfPrompt(); _commandPrompt.Prompt = "console demo>"; // Registers CommandProcess() with the ReadLine() event from the console. _commandPrompt.ReadLine += CommandProcess; //commandPrompt.LoadSettings(); // Loads the settings if they exist otherwise uses defaults. _commandPrompt.Show(); WindowState = WindowState.Minimized; }