private void TextBoxTerminalInput_KeyDown(object sender, KeyEventArgs e) { string RawInput = ""; string Input = ""; if (e.KeyCode == Keys.Enter) { TextBoxTerminal.AppendText("> " + TextBoxTerminalInput.Text + "\r\n"); RawInput = TextBoxTerminalInput.Text; Input = RawInput.Trim().ToLower(); TextBoxTerminalInput.Text = ""; if (Input == "help" | Input == "?") { TextBoxTerminal.AppendText("╔════════════════════════════╗\r\n║ VisionClient Terminal Help ║\r\n╚════════════════════════════╝\r\n\r\nCommands:\r\n\r\nclear\t\tClear the display.\r\nconnect\t\tAttempt to connect to the server, or ping the server if already connected.\r\ndisconnect\tDisconnect from the server.\r\nexit\t\tClose the VisionClient program. (Synonyms: \"bye\", \"quit\")\r\nhelp\t\tDisplay this menu. (Synonyms: \"?\")\r\nmagic\t\tAbracadabra!\r\nsend\t\tAttempt to send the entered data to the server. Syntax is: \"send <data>\". The server will listen for the following strings: \"C\", \"C0\", \"C1\", \"C2\", \"C3\", \"C4\", \"T\", \"T0\", \"T1\", \"T2\".\r\n"); } else if (Input == "magic") { TextBoxTerminal.AppendText(" ██████╗ ██╗ ██╗███████╗███████╗██████╗ ███████╗███████╗ █████╗ ██████╗ ███████╗\r\n██╔═████╗╚██╗██╔╝██╔════╝██╔════╝╚════██╗╚════██║██╔════╝██╔══██╗██╔══██╗██╔════╝\r\n██║██╔██║ ╚███╔╝ ███████╗█████╗ █████╔╝ ██╔╝███████╗╚██████║██║ ██║█████╗ \r\n████╔╝██║ ██╔██╗ ╚════██║██╔══╝ ╚═══██╗ ██╔╝ ╚════██║ ╚═══██║██║ ██║██╔══╝ \r\n╚██████╔╝██╔╝ ██╗███████║██║ ██████╔╝ ██║ ███████║ █████╔╝██████╔╝██║ \r\n ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚══════╝ ╚════╝ ╚═════╝ ╚═╝\r\n"); } else if (Input == "clear") { TextBoxTerminal.Text = ""; } else if (Input == "connect") { if (m_Comm.IsConnected()) { m_Comm.SendData("1"); LabelStatus.Text = "Current connection status: ONLINE."; } else { m_Comm.Run(); } } else if (Input == "disconnect") { m_Comm.Stop(); TextBoxTerminal.AppendText("Disconnected. Please note that you will not be able to reconnect for several minutes, due to underlying networking protocols.\r\n"); } else if (Input == "quit" | Input == "bye" | Input == "exit") { Application.Exit(); } else if (Input.Length >= 4 && Input.Substring(0, 4) == "send") { m_Comm.SendData(RawInput.Substring(5, Input.Length - 5)); } else { TextBoxTerminal.AppendText("ERROR: Command \"" + RawInput + "\" not found.\r\n"); } } }
private void Log(string message) { TextBoxTerminal.AppendText(message + "\r\n"); File.WriteAllText("outlog.txt", message + "\r\n"); }
private void AddDataMethod_terminal(string s) { TextBoxTerminal.AppendText(s); }