From ecfb60eaeb34692d5428ed10ba7a8afc168dcb25 Mon Sep 17 00:00:00 2001 From: Lukasz Baldyga Date: Sun, 15 Nov 2020 06:01:49 +0000 Subject: [PATCH] Gotten rid of messages --- .../SettingsAndHelperFunctionsTester.cs | 8 +- .../Windows/ErrorWindow.Designer.cs | 48 ++++---- .../Windows/ErrorWindow.cs | 4 +- .../Windows/Menu.Designer.cs | 111 ++++++++---------- .../Windows/Menu.cs | 18 +-- .../Windows/TextEditor.Designer.cs | 74 ++++++------ .../Windows/TextEditor.cs | 102 ++++++++-------- .../Windows/TextEditor.resx | 2 +- 8 files changed, 172 insertions(+), 195 deletions(-) diff --git a/Advanced Software Engineering/Advanced Software Engineering Tests/SettingsAndHelperFunctionsTester.cs b/Advanced Software Engineering/Advanced Software Engineering Tests/SettingsAndHelperFunctionsTester.cs index 837ebf6..2f015a3 100644 --- a/Advanced Software Engineering/Advanced Software Engineering Tests/SettingsAndHelperFunctionsTester.cs +++ b/Advanced Software Engineering/Advanced Software Engineering Tests/SettingsAndHelperFunctionsTester.cs @@ -29,7 +29,7 @@ namespace Advanced_Software_Engineering_Tests { string obfuscatedInput = correctOutput; - obfuscatedInput = randomSpaces() + obfuscatedInput + randomSpaces(); + obfuscatedInput = RandomSpaces() + obfuscatedInput + RandomSpaces(); Assert.AreEqual(correctOutput, SettingsAndHelperFunctions.Strip(obfuscatedInput)); } @@ -129,7 +129,7 @@ namespace Advanced_Software_Engineering_Tests { Assert.AreEqual("4 5", commands["parameters"][2]); } - private string randomSpaces() { + private string RandomSpaces() { string spaces = " "; for (int i = 0; i < 50; i++) spaces += " "; return spaces; @@ -144,13 +144,13 @@ namespace Advanced_Software_Engineering_Tests { for (int test = 0; test < 10000; test++) { string command = randomCommands[rand.Next(randomCommands.Length)]; - string input = randomSpaces() + command; + string input = RandomSpaces() + command; List parameters = new List(); for (int parameterI = 0; parameterI < rand.Next(99) + 1; parameterI++) { string parameter = (rand.NextDouble() * rand.Next(-1000, 1000)).ToString(); parameters.Add(parameter); - input += randomSpaces() + parameter + randomSpaces() + "," + randomSpaces(); + input += RandomSpaces() + parameter + RandomSpaces() + "," + RandomSpaces(); } Dictionary commands = SettingsAndHelperFunctions.CommandAndParameterParser(input); diff --git a/Advanced Software Engineering/Advanced Software Engineering/Windows/ErrorWindow.Designer.cs b/Advanced Software Engineering/Advanced Software Engineering/Windows/ErrorWindow.Designer.cs index 9dd3125..db5bdc5 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Windows/ErrorWindow.Designer.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Windows/ErrorWindow.Designer.cs @@ -26,8 +26,8 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ErrorWindow)); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.label1 = new System.Windows.Forms.Label(); - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); + this.ExitButton = new System.Windows.Forms.Button(); + this.ShowDetailsButton = new System.Windows.Forms.Button(); this.groupBox1 = new System.Windows.Forms.GroupBox(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.groupBox1.SuspendLayout(); @@ -53,27 +53,27 @@ this.label1.TabIndex = 2; this.label1.Text = "Error Name"; // - // button1 + // ExitButton // - this.button1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.button1.Location = new System.Drawing.Point(0, 127); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(336, 23); - this.button1.TabIndex = 1; - this.button1.Text = "Exit"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); + this.ExitButton.Dock = System.Windows.Forms.DockStyle.Bottom; + this.ExitButton.Location = new System.Drawing.Point(0, 127); + this.ExitButton.Name = "ExitButton"; + this.ExitButton.Size = new System.Drawing.Size(336, 23); + this.ExitButton.TabIndex = 1; + this.ExitButton.Text = "Exit"; + this.ExitButton.UseVisualStyleBackColor = true; + this.ExitButton.Click += new System.EventHandler(this.Exit_Click); // - // button2 + // ShowDetailsButton // - this.button2.Dock = System.Windows.Forms.DockStyle.Bottom; - this.button2.Location = new System.Drawing.Point(0, 104); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(336, 23); - this.button2.TabIndex = 5; - this.button2.Text = "Show Details"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); + this.ShowDetailsButton.Dock = System.Windows.Forms.DockStyle.Bottom; + this.ShowDetailsButton.Location = new System.Drawing.Point(0, 104); + this.ShowDetailsButton.Name = "ShowDetailsButton"; + this.ShowDetailsButton.Size = new System.Drawing.Size(336, 23); + this.ShowDetailsButton.TabIndex = 5; + this.ShowDetailsButton.Text = "Show Details"; + this.ShowDetailsButton.UseVisualStyleBackColor = true; + this.ShowDetailsButton.Click += new System.EventHandler(this.ShowDescriptionButton_Click); // // groupBox1 // @@ -94,8 +94,8 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(336, 150); this.Controls.Add(this.groupBox1); - this.Controls.Add(this.button2); - this.Controls.Add(this.button1); + this.Controls.Add(this.ShowDetailsButton); + this.Controls.Add(this.ExitButton); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; @@ -114,9 +114,9 @@ //#endregion private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button ExitButton; private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button ShowDetailsButton; private System.Windows.Forms.GroupBox groupBox1; } } \ No newline at end of file diff --git a/Advanced Software Engineering/Advanced Software Engineering/Windows/ErrorWindow.cs b/Advanced Software Engineering/Advanced Software Engineering/Windows/ErrorWindow.cs index f7ac61e..a41d654 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Windows/ErrorWindow.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Windows/ErrorWindow.cs @@ -96,7 +96,7 @@ namespace Advanced_Software_Engineering { /// /// /// - private void button1_Click(object sender, EventArgs e) { + private void Exit_Click(object sender, EventArgs e) { Close(); } @@ -105,7 +105,7 @@ namespace Advanced_Software_Engineering { /// /// /// - private void button2_Click(object sender, EventArgs e) { + private void ShowDescriptionButton_Click(object sender, EventArgs e) { new DetailsWindow(desc).Show(); } diff --git a/Advanced Software Engineering/Advanced Software Engineering/Windows/Menu.Designer.cs b/Advanced Software Engineering/Advanced Software Engineering/Windows/Menu.Designer.cs index f7863c6..e813ded 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Windows/Menu.Designer.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Windows/Menu.Designer.cs @@ -32,47 +32,46 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Menu)); - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.button3 = new System.Windows.Forms.Button(); + this.InteractivePreviewButton = new System.Windows.Forms.Button(); + this.TextEditorButton = new System.Windows.Forms.Button(); + this.AboutButton = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); - this.button4 = new System.Windows.Forms.Button(); - this.button5 = new System.Windows.Forms.Button(); + this.ExitButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // - // button1 + // InteractivePreviewButton // - this.button1.Dock = System.Windows.Forms.DockStyle.Top; - this.button1.Location = new System.Drawing.Point(0, 26); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(172, 23); - this.button1.TabIndex = 0; - this.button1.Text = "Interactive Preview"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); + this.InteractivePreviewButton.Dock = System.Windows.Forms.DockStyle.Top; + this.InteractivePreviewButton.Location = new System.Drawing.Point(0, 26); + this.InteractivePreviewButton.Name = "InteractivePreviewButton"; + this.InteractivePreviewButton.Size = new System.Drawing.Size(172, 23); + this.InteractivePreviewButton.TabIndex = 0; + this.InteractivePreviewButton.Text = "Interactive Preview"; + this.InteractivePreviewButton.UseVisualStyleBackColor = true; + this.InteractivePreviewButton.Click += new System.EventHandler(this.InteractivePreviewClick); // - // button2 + // TextEditorButton // - this.button2.Dock = System.Windows.Forms.DockStyle.Top; - this.button2.Location = new System.Drawing.Point(0, 49); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(172, 23); - this.button2.TabIndex = 0; - this.button2.Text = "Text Editor"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); + this.TextEditorButton.Dock = System.Windows.Forms.DockStyle.Top; + this.TextEditorButton.Location = new System.Drawing.Point(0, 49); + this.TextEditorButton.Name = "TextEditorButton"; + this.TextEditorButton.Size = new System.Drawing.Size(172, 23); + this.TextEditorButton.TabIndex = 0; + this.TextEditorButton.Text = "Text Editor"; + this.TextEditorButton.UseVisualStyleBackColor = true; + this.TextEditorButton.Click += new System.EventHandler(this.TextEditorClick); // - // button3 + // AboutButton // - this.button3.Dock = System.Windows.Forms.DockStyle.Top; - this.button3.Location = new System.Drawing.Point(0, 72); - this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(172, 23); - this.button3.TabIndex = 0; - this.button3.Text = "About"; - this.button3.UseVisualStyleBackColor = true; - this.button3.Click += new System.EventHandler(this.button3_Click); + this.AboutButton.Dock = System.Windows.Forms.DockStyle.Top; + this.AboutButton.Location = new System.Drawing.Point(0, 72); + this.AboutButton.Name = "AboutButton"; + this.AboutButton.Size = new System.Drawing.Size(172, 23); + this.AboutButton.TabIndex = 0; + this.AboutButton.Text = "About"; + this.AboutButton.UseVisualStyleBackColor = true; + this.AboutButton.Click += new System.EventHandler(this.AboutWindowClick); // // label1 // @@ -94,38 +93,26 @@ this.label2.TabIndex = 2; this.label2.Text = "Drawing Program"; // - // button4 + // ExitButton // - this.button4.Dock = System.Windows.Forms.DockStyle.Top; - this.button4.Location = new System.Drawing.Point(0, 95); - this.button4.Name = "button4"; - this.button4.Size = new System.Drawing.Size(172, 23); - this.button4.TabIndex = 0; - this.button4.Text = "Exit"; - this.button4.UseVisualStyleBackColor = true; - this.button4.Click += new System.EventHandler(this.button4_Click); - // - // button5 - // - this.button5.Dock = System.Windows.Forms.DockStyle.Top; - this.button5.Location = new System.Drawing.Point(0, 118); - this.button5.Name = "button5"; - this.button5.Size = new System.Drawing.Size(172, 23); - this.button5.TabIndex = 3; - this.button5.Text = "Simple Error Box Test"; - this.button5.UseVisualStyleBackColor = true; - this.button5.Click += new System.EventHandler(this.button5_Click); + this.ExitButton.Dock = System.Windows.Forms.DockStyle.Top; + this.ExitButton.Location = new System.Drawing.Point(0, 95); + this.ExitButton.Name = "ExitButton"; + this.ExitButton.Size = new System.Drawing.Size(172, 23); + this.ExitButton.TabIndex = 0; + this.ExitButton.Text = "Exit"; + this.ExitButton.UseVisualStyleBackColor = true; + this.ExitButton.Click += new System.EventHandler(this.ExitClick); // // Menu // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(172, 118); - this.Controls.Add(this.button5); - this.Controls.Add(this.button4); - this.Controls.Add(this.button3); - this.Controls.Add(this.button2); - this.Controls.Add(this.button1); + this.Controls.Add(this.ExitButton); + this.Controls.Add(this.AboutButton); + this.Controls.Add(this.TextEditorButton); + this.Controls.Add(this.InteractivePreviewButton); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; @@ -135,7 +122,6 @@ this.Name = "Menu"; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.Text = "Menu"; - this.Load += new System.EventHandler(this.Menu_Load); this.ResumeLayout(false); this.PerformLayout(); @@ -143,13 +129,12 @@ #endregion - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Button button2; - private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button InteractivePreviewButton; + private System.Windows.Forms.Button TextEditorButton; + private System.Windows.Forms.Button AboutButton; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; - private System.Windows.Forms.Button button4; - private System.Windows.Forms.Button button5; + private System.Windows.Forms.Button ExitButton; } } diff --git a/Advanced Software Engineering/Advanced Software Engineering/Windows/Menu.cs b/Advanced Software Engineering/Advanced Software Engineering/Windows/Menu.cs index 2789536..51e9d5a 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Windows/Menu.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Windows/Menu.cs @@ -15,31 +15,23 @@ namespace Advanced_Software_Engineering { InitializeComponent(); } - private void button1_Click(object sender, EventArgs e) { + private void InteractivePreviewClick(object sender, EventArgs e) { new Draw_Preview().Show(); this.Hide(); } - private void button2_Click(object sender, EventArgs e) { - new Text_Editor().Show(); + private void TextEditorClick(object sender, EventArgs e) { + new TextEditor().Show(); this.Hide(); } - private void button3_Click(object sender, EventArgs e) { + private void AboutWindowClick(object sender, EventArgs e) { new About_Window().Show(); this.Hide(); } - private void button4_Click(object sender, EventArgs e) { + private void ExitClick(object sender, EventArgs e) { this.Close(); } - - private void Menu_Load(object sender, EventArgs e) { - //Do things on load - } - - private void button5_Click(object sender, EventArgs e) { - new ErrorWindow().Show(); - } } } \ No newline at end of file diff --git a/Advanced Software Engineering/Advanced Software Engineering/Windows/TextEditor.Designer.cs b/Advanced Software Engineering/Advanced Software Engineering/Windows/TextEditor.Designer.cs index 292f902..5f86a27 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Windows/TextEditor.Designer.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Windows/TextEditor.Designer.cs @@ -5,7 +5,7 @@ namespace Advanced_Software_Engineering /// /// Auto generated code /// - partial class Text_Editor + partial class TextEditor { /// /// Required designer variable. @@ -34,8 +34,8 @@ namespace Advanced_Software_Engineering private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Text_Editor)); - this.textBox1 = new System.Windows.Forms.TextBox(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TextEditor)); + this.TextBox = new System.Windows.Forms.TextBox(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.newFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -50,28 +50,28 @@ namespace Advanced_Software_Engineering this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.label1 = new System.Windows.Forms.Label(); - this.timer1 = new System.Windows.Forms.Timer(this.components); + this.SavedLabelTimer = new System.Windows.Forms.Timer(this.components); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // - // textBox1 + // TextBox // - this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.TextBox.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.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.textBox1.Font = new System.Drawing.Font("Lucida Console", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox1.Location = new System.Drawing.Point(0, 23); - this.textBox1.Multiline = true; - this.textBox1.Name = "textBox1"; - this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBox1.Size = new System.Drawing.Size(602, 509); - this.textBox1.TabIndex = 0; - this.textBox1.WordWrap = false; - this.textBox1.Click += new System.EventHandler(this.textBox1_Click); - this.textBox1.TextChanged += new System.EventHandler(this.handleKeypress); - this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Text_Editor_PreviewKeyDown); - this.textBox1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyUp); + this.TextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.TextBox.Font = new System.Drawing.Font("Lucida Console", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.TextBox.Location = new System.Drawing.Point(0, 23); + this.TextBox.Multiline = true; + this.TextBox.Name = "TextBox"; + this.TextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.TextBox.Size = new System.Drawing.Size(602, 509); + this.TextBox.TabIndex = 0; + this.TextBox.WordWrap = false; + this.TextBox.Click += new System.EventHandler(this.TextBoxClick); + this.TextBox.TextChanged += new System.EventHandler(this.HandleKeypress); + this.TextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Text_Editor_PreviewKeyDown); + this.TextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.TextBox_KeyUp); // // menuStrip1 // @@ -104,56 +104,56 @@ namespace Advanced_Software_Engineering this.newFileToolStripMenuItem.Name = "newFileToolStripMenuItem"; this.newFileToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.newFileToolStripMenuItem.Text = "New File (Ctrl + N)"; - this.newFileToolStripMenuItem.Click += new System.EventHandler(this.newFileToolStripMenuItem_Click); + this.newFileToolStripMenuItem.Click += new System.EventHandler(this.NewFileToolStripMenuItem_Click); // // openToolStripMenuItem // this.openToolStripMenuItem.Name = "openToolStripMenuItem"; this.openToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.openToolStripMenuItem.Text = "Open (Ctrl + O)"; - this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); + this.openToolStripMenuItem.Click += new System.EventHandler(this.OpenToolStripMenuItem_Click); // // saveToolStripMenuItem // this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; this.saveToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.saveToolStripMenuItem.Text = "Save (Ctrl + S)"; - this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); + this.saveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click); // // saveAsToolStripMenuItem // this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.saveAsToolStripMenuItem.Text = "Save As (Ctrl + Shift + S)"; - this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click); + this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.SaveAsToolStripMenuItem_Click); // // exitToolStripMenuItem // this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; this.exitToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.exitToolStripMenuItem.Text = "Exit (Alt + F4)"; - this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); + this.exitToolStripMenuItem.Click += new System.EventHandler(this.ExitToolStripMenuItem_Click); // // runToolStripMenuItem // this.runToolStripMenuItem.Name = "runToolStripMenuItem"; this.runToolStripMenuItem.Size = new System.Drawing.Size(63, 20); this.runToolStripMenuItem.Text = "Run (F5)"; - this.runToolStripMenuItem.Click += new System.EventHandler(this.runToolStripMenuItem_Click); + this.runToolStripMenuItem.Click += new System.EventHandler(this.RunToolStripMenuItem_Click); // // checkSyntaxToolStripMenuItem // this.checkSyntaxToolStripMenuItem.Name = "checkSyntaxToolStripMenuItem"; this.checkSyntaxToolStripMenuItem.Size = new System.Drawing.Size(151, 20); this.checkSyntaxToolStripMenuItem.Text = "Check Syntax (Shift + F5)"; - this.checkSyntaxToolStripMenuItem.Click += new System.EventHandler(this.checkSyntaxToolStripMenuItem_Click); + this.checkSyntaxToolStripMenuItem.Click += new System.EventHandler(this.CheckSyntaxToolStripMenuItem_Click); // // describeToolStripMenuItem // this.describeToolStripMenuItem.Name = "describeToolStripMenuItem"; this.describeToolStripMenuItem.Size = new System.Drawing.Size(125, 20); this.describeToolStripMenuItem.Text = "Describe (Shift + F1)"; - this.describeToolStripMenuItem.Click += new System.EventHandler(this.describeToolStripMenuItem_Click); + this.describeToolStripMenuItem.Click += new System.EventHandler(this.DescribeToolStripMenuItem_Click); // // helpToolStripMenuItem // @@ -169,14 +169,14 @@ namespace Advanced_Software_Engineering this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; this.aboutToolStripMenuItem.Size = new System.Drawing.Size(107, 22); this.aboutToolStripMenuItem.Text = "About"; - this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); + this.aboutToolStripMenuItem.Click += new System.EventHandler(this.AboutToolStripMenuItem_Click); // // helpToolStripMenuItem1 // this.helpToolStripMenuItem1.Name = "helpToolStripMenuItem1"; this.helpToolStripMenuItem1.Size = new System.Drawing.Size(107, 22); this.helpToolStripMenuItem1.Text = "Help"; - this.helpToolStripMenuItem1.Click += new System.EventHandler(this.helpToolStripMenuItem1_Click); + this.helpToolStripMenuItem1.Click += new System.EventHandler(this.HelpToolStripMenuItem1_Click); // // label1 // @@ -187,23 +187,23 @@ namespace Advanced_Software_Engineering this.label1.Size = new System.Drawing.Size(0, 13); this.label1.TabIndex = 2; // - // timer1 + // SavedLabelTimer // - this.timer1.Interval = 1000; - this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + this.SavedLabelTimer.Interval = 1000; + this.SavedLabelTimer.Tick += new System.EventHandler(this.SavedLableTimerTick); // - // Text_Editor + // TextEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(602, 548); this.Controls.Add(this.label1); - this.Controls.Add(this.textBox1); + this.Controls.Add(this.TextBox); this.Controls.Add(this.menuStrip1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.KeyPreview = true; this.MainMenuStrip = this.menuStrip1; - this.Name = "Text_Editor"; + this.Name = "TextEditor"; this.Text = "Advanced Software Engineering - Text Editor"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Text_Editor_FormClosing); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Console_FormClosed); @@ -217,7 +217,7 @@ namespace Advanced_Software_Engineering #endregion - private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox TextBox; private MenuStrip menuStrip1; private ToolStripMenuItem fileToolStripMenuItem; private ToolStripMenuItem newFileToolStripMenuItem; @@ -231,7 +231,7 @@ namespace Advanced_Software_Engineering private ToolStripMenuItem saveAsToolStripMenuItem; private ToolStripMenuItem checkSyntaxToolStripMenuItem; private Label label1; - private Timer timer1; + private Timer SavedLabelTimer; private ToolStripMenuItem describeToolStripMenuItem; } } \ No newline at end of file diff --git a/Advanced Software Engineering/Advanced Software Engineering/Windows/TextEditor.cs b/Advanced Software Engineering/Advanced Software Engineering/Windows/TextEditor.cs index 15b8932..e5f4dda 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Windows/TextEditor.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Windows/TextEditor.cs @@ -4,7 +4,7 @@ using System.Windows.Forms; namespace Advanced_Software_Engineering { - public partial class Text_Editor : Form { + public partial class TextEditor : Form { private const string DefaultTitleString = "ASE - Text Editor"; private Draw_Preview DisplayForm = null; @@ -16,7 +16,7 @@ namespace Advanced_Software_Engineering { /// /// The text editor is the main window that the user will be using for writing code. /// - public Text_Editor() { + public TextEditor() { SettingsAndHelperFunctions.NumberOfWindows++; InitializeComponent(); UpdateTitle(); @@ -26,12 +26,12 @@ namespace Advanced_Software_Engineering { /// The text editor is the main window that the user will be using for writing code. /// /// File dialog which points to the file to open - public Text_Editor(OpenFileDialog openFile) { + public TextEditor(OpenFileDialog openFile) { SettingsAndHelperFunctions.NumberOfWindows++; InitializeComponent(); StreamReader fileStream = new StreamReader(openFile.OpenFile()); - textBox1.Text = fileStream.ReadToEnd(); + TextBox.Text = fileStream.ReadToEnd(); unsavedChanges = false; newWindow = false; okToOverwrite = true; @@ -50,14 +50,14 @@ namespace Advanced_Software_Engineering { if (unsavedChanges) this.Text = "* " + this.Text + " *"; } - private void saveFile() { - if (!okToOverwrite) saveFileAs(); + private void SaveFile() { + if (!okToOverwrite) SaveFileAs(); else { try { StreamWriter fileStream = new StreamWriter(fileName); - fileStream.Write(textBox1.Text); + fileStream.Write(TextBox.Text); unsavedChanges = false; - showSavedMessage(); + ShowSavedMessage(); fileStream.Close(); } catch (Exception e) { new ErrorWindow("Write Failed!", "The program failed to write the file.", e.Message + "\n" + e.StackTrace, ErrorWindow.ERROR_MESSAGE).Show(); @@ -67,7 +67,7 @@ namespace Advanced_Software_Engineering { } } - private void saveFileAs() { + private void SaveFileAs() { SaveFileDialog saveFileDialog = new SaveFileDialog { OverwritePrompt = true, DefaultExt = ".txt" @@ -79,11 +79,11 @@ namespace Advanced_Software_Engineering { if (dialogResult == DialogResult.OK) { StreamWriter fileStream = new StreamWriter(saveFileDialog.OpenFile()); try { - fileStream.Write(textBox1.Text); + fileStream.Write(TextBox.Text); unsavedChanges = false; okToOverwrite = true; fileName = saveFileDialog.FileName; - showSavedMessage(); + ShowSavedMessage(); } catch (Exception e) { new ErrorWindow("Write Failed!", "The program failed to write the file.", e.Message + "\n" + e.StackTrace, ErrorWindow.ERROR_MESSAGE).Show(); } finally { @@ -93,55 +93,55 @@ namespace Advanced_Software_Engineering { } } - private void showSavedMessage() { + private void ShowSavedMessage() { label1.Text = "File saved"; - timer1.Start(); + SavedLabelTimer.Start(); } - private void updateRowCol() { - int line = textBox1.GetLineFromCharIndex(textBox1.SelectionStart); - int column = textBox1.SelectionStart - textBox1.GetFirstCharIndexFromLine(line); + private void UpdateRowsAndColumnsPreview() { + int line = TextBox.GetLineFromCharIndex(TextBox.SelectionStart); + int column = TextBox.SelectionStart - TextBox.GetFirstCharIndexFromLine(line); line++; column++; label1.Text = "row: " + line.ToString() + " col: " + column.ToString(); } - private void handleKeypress() { + private void HandleKeypress() { if (newWindow) newWindow = false; - updateSaveStatus(); - updateRowCol(); + UpdateSaveStatus(); + UpdateRowsAndColumnsPreview(); } - private void updateSaveStatus() { + private void UpdateSaveStatus() { if (!unsavedChanges) { unsavedChanges = true; UpdateTitle(); } } - private void openFile() { + private void OpenFile() { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == DialogResult.OK) { if (newWindow) { StreamReader fileStream = new StreamReader(openFileDialog.OpenFile()); - textBox1.Text = fileStream.ReadToEnd(); + TextBox.Text = fileStream.ReadToEnd(); unsavedChanges = false; okToOverwrite = true; newWindow = false; UpdateTitle(openFileDialog.FileName); fileStream.Close(); - } else new Text_Editor(openFileDialog).Show(); + } else new TextEditor(openFileDialog).Show(); } } private void RunCode() { if (DisplayForm == null || DisplayForm.IsDisposed) { - DisplayForm = new Draw_Preview(textBox1.Text); + DisplayForm = new Draw_Preview(TextBox.Text); } else { Console.WriteLine("Removed all commands"); DisplayForm.RemoveAllCommands(); - DisplayForm.SubmitCommands(textBox1.Text); + DisplayForm.SubmitCommands(TextBox.Text); } if (DisplayForm.IsSuccess()) { @@ -156,14 +156,14 @@ namespace Advanced_Software_Engineering { public void CheckCode() { Draw_Preview tmpDrawPreview = new Draw_Preview(); tmpDrawPreview.Hide(); - tmpDrawPreview.SubmitCommands(textBox1.Text); + tmpDrawPreview.SubmitCommands(TextBox.Text); if (tmpDrawPreview.IsSuccess()) new ErrorWindow("No errors", "No errors found in the program", "There have been no errors found", ErrorWindow.INFO_MESSAGE).Show(); tmpDrawPreview.Close(); SettingsAndHelperFunctions.WindowClosed(); tmpDrawPreview.Dispose(); } - private void handleExit(FormClosingEventArgs e) { + private void HandleExit(FormClosingEventArgs e) { if (unsavedChanges) { DialogResult dialogResult = MessageBox.Show("You have unsaved work. Would you like to discard your work?", "Unsaved work!", MessageBoxButtons.YesNo, MessageBoxIcon.None); if (e != null) e.Cancel = dialogResult != DialogResult.Yes; @@ -173,7 +173,7 @@ namespace Advanced_Software_Engineering { private void DescribeCode() { Draw_Preview tmpDrawPreview = new Draw_Preview(); tmpDrawPreview.Hide(); - tmpDrawPreview.SubmitCommands(textBox1.Text); + tmpDrawPreview.SubmitCommands(TextBox.Text); string commandDesc = tmpDrawPreview.DescribeAllCommands(); Console.WriteLine(commandDesc); @@ -191,41 +191,41 @@ namespace Advanced_Software_Engineering { Dispose(); } - private void runToolStripMenuItem_Click(object sender, EventArgs e) => RunCode(); + private void RunToolStripMenuItem_Click(object sender, EventArgs e) => RunCode(); - private void createNewInstance() => new Text_Editor().Show(); + private void CreateNewInstance() => new TextEditor().Show(); - private void handleKeypress(object sender, EventArgs e) => handleKeypress(); + private void HandleKeypress(object sender, EventArgs e) => HandleKeypress(); - private void textBox1_Click(object sender, EventArgs e) => updateRowCol(); + private void TextBoxClick(object sender, EventArgs e) => UpdateRowsAndColumnsPreview(); - private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) => saveFileAs(); + private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e) => SaveFileAs(); - private void saveToolStripMenuItem_Click(object sender, EventArgs e) => saveFile(); + private void SaveToolStripMenuItem_Click(object sender, EventArgs e) => SaveFile(); - private void newFileToolStripMenuItem_Click(object sender, EventArgs e) => createNewInstance(); + private void NewFileToolStripMenuItem_Click(object sender, EventArgs e) => CreateNewInstance(); - private void aboutToolStripMenuItem_Click(object sender, EventArgs e) => new About_Window().Show(); + private void AboutToolStripMenuItem_Click(object sender, EventArgs e) => new About_Window().Show(); - private void Text_Editor_FormClosing(object sender, FormClosingEventArgs e) => handleExit(e); + private void Text_Editor_FormClosing(object sender, FormClosingEventArgs e) => HandleExit(e); - private void exitToolStripMenuItem_Click(object sender, EventArgs e) => Close(); + private void ExitToolStripMenuItem_Click(object sender, EventArgs e) => Close(); - private void openToolStripMenuItem_Click(object sender, EventArgs e) => openFile(); + private void OpenToolStripMenuItem_Click(object sender, EventArgs e) => OpenFile(); private void Text_Editor_PreviewKeyDown(object sender, KeyEventArgs e) { //New window if (e.Control && e.KeyCode == Keys.N) { - createNewInstance(); + CreateNewInstance(); e.Handled = true; } else if (e.Control && e.KeyCode == Keys.S) { - saveFile(); + SaveFile(); e.Handled = true; } else if (e.Control && e.Shift && e.KeyCode == Keys.S) { - saveFileAs(); + SaveFileAs(); e.Handled = true; } else if (e.Control && e.KeyCode == Keys.O) { - openFile(); + OpenFile(); e.Handled = true; } else if (e.KeyCode == Keys.F5) { RunCode(); @@ -237,21 +237,21 @@ namespace Advanced_Software_Engineering { DescribeCode(); e.Handled = true; } else { - updateRowCol(); + UpdateRowsAndColumnsPreview(); } } - private void checkSyntaxToolStripMenuItem_Click(object sender, EventArgs e) => CheckCode(); + private void CheckSyntaxToolStripMenuItem_Click(object sender, EventArgs e) => CheckCode(); - private void describeToolStripMenuItem_Click(object sender, EventArgs e) => DescribeCode(); + private void DescribeToolStripMenuItem_Click(object sender, EventArgs e) => DescribeCode(); - private void timer1_Tick(object sender, EventArgs e) { - updateRowCol(); - timer1.Stop(); + private void SavedLableTimerTick(object sender, EventArgs e) { + UpdateRowsAndColumnsPreview(); + SavedLabelTimer.Stop(); } - private void textBox1_KeyUp(object sender, KeyEventArgs e) => updateRowCol(); + private void TextBox_KeyUp(object sender, KeyEventArgs e) => UpdateRowsAndColumnsPreview(); - private void helpToolStripMenuItem1_Click(object sender, EventArgs e) => new CommandHelp().Show(); + private void HelpToolStripMenuItem1_Click(object sender, EventArgs e) => new CommandHelp().Show(); } } \ No newline at end of file diff --git a/Advanced Software Engineering/Advanced Software Engineering/Windows/TextEditor.resx b/Advanced Software Engineering/Advanced Software Engineering/Windows/TextEditor.resx index 46b0629..1d5b7f9 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Windows/TextEditor.resx +++ b/Advanced Software Engineering/Advanced Software Engineering/Windows/TextEditor.resx @@ -120,7 +120,7 @@ 17, 17 - + 132, 17