From ee343916c292c741041167a1a77f4b59a95002c5 Mon Sep 17 00:00:00 2001 From: TheEdgeNK Date: Sun, 26 Aug 2018 14:15:03 -0400 Subject: Ability to change chatter username, also, terminal! --- PortEngine/ChatAPI.cs | 2 +- PortEngine/PortEngine.csproj | 1 + PortEngine/Properties/Settings.Designer.cs | 14 ++- PortEngine/Properties/Settings.settings | 3 + PortEngine/TerminalAPI.cs | 55 +++++++++++ PortEngine/app.config | 3 + Project Ports/About.Designer.cs | 78 ---------------- Project Ports/About.cs | 44 --------- Project Ports/About.resx | 138 ---------------------------- Project Ports/Programs/ChatApp.Designer.cs | 1 + Project Ports/Programs/ChatApp.cs | 11 ++- Project Ports/Programs/Terminal.Designer.cs | 45 ++++++--- Project Ports/Programs/Terminal.cs | 10 ++ Project Ports/Project Ports.csproj | 9 -- 14 files changed, 127 insertions(+), 287 deletions(-) create mode 100644 PortEngine/TerminalAPI.cs delete mode 100644 Project Ports/About.Designer.cs delete mode 100644 Project Ports/About.cs delete mode 100644 Project Ports/About.resx diff --git a/PortEngine/ChatAPI.cs b/PortEngine/ChatAPI.cs index 667a016..ae1f27b 100644 --- a/PortEngine/ChatAPI.cs +++ b/PortEngine/ChatAPI.cs @@ -12,7 +12,7 @@ namespace PortEngine { public static void SendMessage(TextBox txtPending, TextBox txtDestination) { - txtDestination.AppendText(" " + txtPending.Text + Environment.NewLine); + txtDestination.AppendText("<" + Properties.Settings.Default.userDisplayName + "> " + txtPending.Text + Environment.NewLine); txtPending.Clear(); } } diff --git a/PortEngine/PortEngine.csproj b/PortEngine/PortEngine.csproj index e5ff357..dbea034 100644 --- a/PortEngine/PortEngine.csproj +++ b/PortEngine/PortEngine.csproj @@ -49,6 +49,7 @@ True Settings.settings + Form diff --git a/PortEngine/Properties/Settings.Designer.cs b/PortEngine/Properties/Settings.Designer.cs index b3cd482..6462222 100644 --- a/PortEngine/Properties/Settings.Designer.cs +++ b/PortEngine/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace PortEngine.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -34,5 +34,17 @@ namespace PortEngine.Properties { this["graphicsFriendly"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Player")] + public string userDisplayName { + get { + return ((string)(this["userDisplayName"])); + } + set { + this["userDisplayName"] = value; + } + } } } diff --git a/PortEngine/Properties/Settings.settings b/PortEngine/Properties/Settings.settings index 66e581e..14e29c9 100644 --- a/PortEngine/Properties/Settings.settings +++ b/PortEngine/Properties/Settings.settings @@ -5,5 +5,8 @@ False + + Player + \ No newline at end of file diff --git a/PortEngine/TerminalAPI.cs b/PortEngine/TerminalAPI.cs new file mode 100644 index 0000000..4c09dad --- /dev/null +++ b/PortEngine/TerminalAPI.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PortEngine +{ + public class TerminalAPI + { + public static void RunCommand(TextBox txtConsoleInput, TextBox txtConsoleOutput) + { + bool LastCommandWasClear = false; + + + switch (txtConsoleInput.Text.ToLower()) + { + + + case "help": + txtConsoleOutput.AppendText("help - lists the commands\r\ntest - displays a test message\r\nclear - clears the terminal\r\nchangeusername - changes your username for use with the Chatter application\r\n example: changeusername --TheBestUser" + Environment.NewLine); + break; + case "clear": + txtConsoleOutput.Clear(); + LastCommandWasClear = true; + break; + case "test": + txtConsoleOutput.AppendText("This is a test!\r\nof the EBS!" + Environment.NewLine); + break; + default: + if (txtConsoleInput.Text.StartsWith("changeusername --")) + { + txtConsoleOutput.AppendText("You have changed your username to " + txtConsoleInput.Text.Substring(17)); + Properties.Settings.Default.userDisplayName = txtConsoleInput.Text.Substring(17); + } + else + { + txtConsoleOutput.AppendText("Bad command. Reference the command list for commands that exist." + Environment.NewLine); + } + break; + } + + if (LastCommandWasClear == true) + { + LastCommandWasClear = false; + } + else + { + txtConsoleOutput.AppendText(Environment.NewLine); + } + + } + } +} diff --git a/PortEngine/app.config b/PortEngine/app.config index e543569..cb6d547 100644 --- a/PortEngine/app.config +++ b/PortEngine/app.config @@ -10,6 +10,9 @@ False + + Player + \ No newline at end of file diff --git a/Project Ports/About.Designer.cs b/Project Ports/About.Designer.cs deleted file mode 100644 index 85a9a7d..0000000 --- a/Project Ports/About.Designer.cs +++ /dev/null @@ -1,78 +0,0 @@ -namespace Project_Ports -{ - partial class About - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(About)); - this.richTextBox1 = new System.Windows.Forms.RichTextBox(); - this.button1 = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // richTextBox1 - // - this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.richTextBox1.Enabled = false; - this.richTextBox1.Location = new System.Drawing.Point(12, 31); - this.richTextBox1.Name = "richTextBox1"; - this.richTextBox1.Size = new System.Drawing.Size(416, 311); - this.richTextBox1.TabIndex = 0; - this.richTextBox1.Text = resources.GetString("richTextBox1.Text"); - // - // button1 - // - this.button1.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.button1.Location = new System.Drawing.Point(165, 362); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(97, 44); - this.button1.TabIndex = 1; - this.button1.Text = "Close"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // About - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(440, 418); - this.ControlBox = false; - this.Controls.Add(this.button1); - this.Controls.Add(this.richTextBox1); - this.Name = "About"; - this.Text = "About"; - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.RichTextBox richTextBox1; - private System.Windows.Forms.Button button1; - } -} \ No newline at end of file diff --git a/Project Ports/About.cs b/Project Ports/About.cs deleted file mode 100644 index 3ab8ac1..0000000 --- a/Project Ports/About.cs +++ /dev/null @@ -1,44 +0,0 @@ -/************************************************************************ - * - * Project Ports - * Copyright (C) 2018 AleeCorp - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - **************************************************************************/ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace Project_Ports -{ - public partial class About : Form - { - public About() - { - InitializeComponent(); - } - - private void button1_Click(object sender, EventArgs e) - { - this.Close(); - } - } -} diff --git a/Project Ports/About.resx b/Project Ports/About.resx deleted file mode 100644 index f4b7cd6..0000000 --- a/Project Ports/About.resx +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - Project Ports - Copyright (C) 2018 AleeCorp - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <https://www.gnu.org/licenses/> - - \ No newline at end of file diff --git a/Project Ports/Programs/ChatApp.Designer.cs b/Project Ports/Programs/ChatApp.Designer.cs index c2200c1..f6a3dbd 100644 --- a/Project Ports/Programs/ChatApp.Designer.cs +++ b/Project Ports/Programs/ChatApp.Designer.cs @@ -57,6 +57,7 @@ this.txtMsgContents.Name = "txtMsgContents"; this.txtMsgContents.Size = new System.Drawing.Size(384, 18); this.txtMsgContents.TabIndex = 1; + this.txtMsgContents.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtMsgContents_KeyDown); // // listBox1 // diff --git a/Project Ports/Programs/ChatApp.cs b/Project Ports/Programs/ChatApp.cs index 593fa17..0e89077 100644 --- a/Project Ports/Programs/ChatApp.cs +++ b/Project Ports/Programs/ChatApp.cs @@ -21,7 +21,16 @@ namespace Project_Ports private void btnSendMSG_Click(object sender, EventArgs e) { - PortEngine.ChatAPI.SendMessage(txtMsgContents, txtSentMessages); + ChatAPI.SendMessage(txtMsgContents, txtSentMessages); + } + + private void txtMsgContents_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + ChatAPI.SendMessage(txtMsgContents, txtSentMessages); + e.SuppressKeyPress = true; + } } } } diff --git a/Project Ports/Programs/Terminal.Designer.cs b/Project Ports/Programs/Terminal.Designer.cs index 48e3ee4..c5c2807 100644 --- a/Project Ports/Programs/Terminal.Designer.cs +++ b/Project Ports/Programs/Terminal.Designer.cs @@ -28,30 +28,44 @@ /// private void InitializeComponent() { - this.textBox1 = new System.Windows.Forms.TextBox(); + this.txtConsole = new System.Windows.Forms.TextBox(); + this.txtInput = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // - // textBox1 + // txtConsole // - this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.txtConsole.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.textBox1.BackColor = System.Drawing.Color.Black; - this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.textBox1.Font = new System.Drawing.Font("Consolas", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox1.ForeColor = System.Drawing.Color.White; - this.textBox1.Location = new System.Drawing.Point(0, 0); - this.textBox1.Multiline = true; - this.textBox1.Name = "textBox1"; - this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBox1.Size = new System.Drawing.Size(456, 337); - this.textBox1.TabIndex = 0; + this.txtConsole.BackColor = System.Drawing.Color.Black; + this.txtConsole.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.txtConsole.Font = new System.Drawing.Font("Consolas", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txtConsole.ForeColor = System.Drawing.Color.White; + this.txtConsole.Location = new System.Drawing.Point(-3, 0); + this.txtConsole.Multiline = true; + this.txtConsole.Name = "txtConsole"; + this.txtConsole.ReadOnly = true; + this.txtConsole.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtConsole.Size = new System.Drawing.Size(456, 321); + this.txtConsole.TabIndex = 3; + // + // txtInput + // + this.txtInput.BackColor = System.Drawing.SystemColors.WindowText; + this.txtInput.Font = new System.Drawing.Font("Lucida Console", 8F); + this.txtInput.ForeColor = System.Drawing.SystemColors.Window; + this.txtInput.Location = new System.Drawing.Point(0, 319); + this.txtInput.Name = "txtInput"; + this.txtInput.Size = new System.Drawing.Size(456, 18); + this.txtInput.TabIndex = 4; + this.txtInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtInput_KeyDown); // // Terminal // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.textBox1); + this.Controls.Add(this.txtInput); + this.Controls.Add(this.txtConsole); this.Name = "Terminal"; this.Size = new System.Drawing.Size(456, 337); this.Load += new System.EventHandler(this.Terminal_Load); @@ -62,6 +76,7 @@ #endregion - private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox txtConsole; + public System.Windows.Forms.TextBox txtInput; } } diff --git a/Project Ports/Programs/Terminal.cs b/Project Ports/Programs/Terminal.cs index c878c32..55cf8ed 100644 --- a/Project Ports/Programs/Terminal.cs +++ b/Project Ports/Programs/Terminal.cs @@ -23,5 +23,15 @@ namespace Project_Ports { WindowManager wm = new WindowManager(); } + + private void txtInput_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + TerminalAPI.RunCommand(txtInput, txtConsole); + e.SuppressKeyPress = true; + txtInput.Clear(); + } + } } } diff --git a/Project Ports/Project Ports.csproj b/Project Ports/Project Ports.csproj index ee43be4..b33ed52 100644 --- a/Project Ports/Project Ports.csproj +++ b/Project Ports/Project Ports.csproj @@ -45,12 +45,6 @@ - - Form - - - About.cs - UserControl @@ -106,9 +100,6 @@ TestWindow.cs - - About.cs - AboutPorts.cs -- cgit v1.2.3