Gotten rid of messages

This commit is contained in:
Lukasz Baldyga committed 2020-11-15 06:01:49 +00:00
1 parent 18196654b6
commit ecfb60eaeb
8 files changed
+172 -195

No files matched your search

@@ -29,7 +29,7 @@ namespace Advanced_Software_Engineering_Tests {
string obfuscatedInput = correctOutput; string obfuscatedInput = correctOutput;
obfuscatedInput = randomSpaces() + obfuscatedInput + randomSpaces(); obfuscatedInput = RandomSpaces() + obfuscatedInput + RandomSpaces();
Assert.AreEqual(correctOutput, SettingsAndHelperFunctions.Strip(obfuscatedInput)); Assert.AreEqual(correctOutput, SettingsAndHelperFunctions.Strip(obfuscatedInput));
} }
@@ -129,7 +129,7 @@ namespace Advanced_Software_Engineering_Tests {
Assert.AreEqual("4 5", commands["parameters"][2]); Assert.AreEqual("4 5", commands["parameters"][2]);
} }
private string randomSpaces() { private string RandomSpaces() {
string spaces = " "; string spaces = " ";
for (int i = 0; i < 50; i++) spaces += " "; for (int i = 0; i < 50; i++) spaces += " ";
return spaces; return spaces;
@@ -144,13 +144,13 @@ namespace Advanced_Software_Engineering_Tests {
for (int test = 0; test < 10000; test++) { for (int test = 0; test < 10000; test++) {
string command = randomCommands[rand.Next(randomCommands.Length)]; string command = randomCommands[rand.Next(randomCommands.Length)];
string input = randomSpaces() + command; string input = RandomSpaces() + command;
List<string> parameters = new List<string>(); List<string> parameters = new List<string>();
for (int parameterI = 0; parameterI < rand.Next(99) + 1; parameterI++) { for (int parameterI = 0; parameterI < rand.Next(99) + 1; parameterI++) {
string parameter = (rand.NextDouble() * rand.Next(-1000, 1000)).ToString(); string parameter = (rand.NextDouble() * rand.Next(-1000, 1000)).ToString();
parameters.Add(parameter); parameters.Add(parameter);
input += randomSpaces() + parameter + randomSpaces() + "," + randomSpaces(); input += RandomSpaces() + parameter + RandomSpaces() + "," + RandomSpaces();
} }
Dictionary<string, string[]> commands = SettingsAndHelperFunctions.CommandAndParameterParser(input); Dictionary<string, string[]> commands = SettingsAndHelperFunctions.CommandAndParameterParser(input);
@@ -26,8 +26,8 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ErrorWindow)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ErrorWindow));
this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button(); this.ExitButton = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button(); this.ShowDetailsButton = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
@@ -53,27 +53,27 @@
this.label1.TabIndex = 2; this.label1.TabIndex = 2;
this.label1.Text = "Error Name"; this.label1.Text = "Error Name";
// //
// button1 // ExitButton
// //
this.button1.Dock = System.Windows.Forms.DockStyle.Bottom; this.ExitButton.Dock = System.Windows.Forms.DockStyle.Bottom;
this.button1.Location = new System.Drawing.Point(0, 127); this.ExitButton.Location = new System.Drawing.Point(0, 127);
this.button1.Name = "button1"; this.ExitButton.Name = "ExitButton";
this.button1.Size = new System.Drawing.Size(336, 23); this.ExitButton.Size = new System.Drawing.Size(336, 23);
this.button1.TabIndex = 1; this.ExitButton.TabIndex = 1;
this.button1.Text = "Exit"; this.ExitButton.Text = "Exit";
this.button1.UseVisualStyleBackColor = true; this.ExitButton.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click); this.ExitButton.Click += new System.EventHandler(this.Exit_Click);
// //
// button2 // ShowDetailsButton
// //
this.button2.Dock = System.Windows.Forms.DockStyle.Bottom; this.ShowDetailsButton.Dock = System.Windows.Forms.DockStyle.Bottom;
this.button2.Location = new System.Drawing.Point(0, 104); this.ShowDetailsButton.Location = new System.Drawing.Point(0, 104);
this.button2.Name = "button2"; this.ShowDetailsButton.Name = "ShowDetailsButton";
this.button2.Size = new System.Drawing.Size(336, 23); this.ShowDetailsButton.Size = new System.Drawing.Size(336, 23);
this.button2.TabIndex = 5; this.ShowDetailsButton.TabIndex = 5;
this.button2.Text = "Show Details"; this.ShowDetailsButton.Text = "Show Details";
this.button2.UseVisualStyleBackColor = true; this.ShowDetailsButton.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click); this.ShowDetailsButton.Click += new System.EventHandler(this.ShowDescriptionButton_Click);
// //
// groupBox1 // groupBox1
// //
@@ -94,8 +94,8 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(336, 150); this.ClientSize = new System.Drawing.Size(336, 150);
this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button2); this.Controls.Add(this.ShowDetailsButton);
this.Controls.Add(this.button1); this.Controls.Add(this.ExitButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false; this.MaximizeBox = false;
@@ -114,9 +114,9 @@
//#endregion //#endregion
private System.Windows.Forms.PictureBox pictureBox1; 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.Label label1;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button ShowDetailsButton;
private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox1;
} }
} }
@@ -96,7 +96,7 @@ namespace Advanced_Software_Engineering {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void button1_Click(object sender, EventArgs e) { private void Exit_Click(object sender, EventArgs e) {
Close(); Close();
} }
@@ -105,7 +105,7 @@ namespace Advanced_Software_Engineering {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void button2_Click(object sender, EventArgs e) { private void ShowDescriptionButton_Click(object sender, EventArgs e) {
new DetailsWindow(desc).Show(); new DetailsWindow(desc).Show();
} }
@@ -32,47 +32,46 @@
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Menu)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Menu));
this.button1 = new System.Windows.Forms.Button(); this.InteractivePreviewButton = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button(); this.TextEditorButton = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button(); this.AboutButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.button4 = new System.Windows.Forms.Button(); this.ExitButton = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// button1 // InteractivePreviewButton
// //
this.button1.Dock = System.Windows.Forms.DockStyle.Top; this.InteractivePreviewButton.Dock = System.Windows.Forms.DockStyle.Top;
this.button1.Location = new System.Drawing.Point(0, 26); this.InteractivePreviewButton.Location = new System.Drawing.Point(0, 26);
this.button1.Name = "button1"; this.InteractivePreviewButton.Name = "InteractivePreviewButton";
this.button1.Size = new System.Drawing.Size(172, 23); this.InteractivePreviewButton.Size = new System.Drawing.Size(172, 23);
this.button1.TabIndex = 0; this.InteractivePreviewButton.TabIndex = 0;
this.button1.Text = "Interactive Preview"; this.InteractivePreviewButton.Text = "Interactive Preview";
this.button1.UseVisualStyleBackColor = true; this.InteractivePreviewButton.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click); this.InteractivePreviewButton.Click += new System.EventHandler(this.InteractivePreviewClick);
// //
// button2 // TextEditorButton
// //
this.button2.Dock = System.Windows.Forms.DockStyle.Top; this.TextEditorButton.Dock = System.Windows.Forms.DockStyle.Top;
this.button2.Location = new System.Drawing.Point(0, 49); this.TextEditorButton.Location = new System.Drawing.Point(0, 49);
this.button2.Name = "button2"; this.TextEditorButton.Name = "TextEditorButton";
this.button2.Size = new System.Drawing.Size(172, 23); this.TextEditorButton.Size = new System.Drawing.Size(172, 23);
this.button2.TabIndex = 0; this.TextEditorButton.TabIndex = 0;
this.button2.Text = "Text Editor"; this.TextEditorButton.Text = "Text Editor";
this.button2.UseVisualStyleBackColor = true; this.TextEditorButton.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click); this.TextEditorButton.Click += new System.EventHandler(this.TextEditorClick);
// //
// button3 // AboutButton
// //
this.button3.Dock = System.Windows.Forms.DockStyle.Top; this.AboutButton.Dock = System.Windows.Forms.DockStyle.Top;
this.button3.Location = new System.Drawing.Point(0, 72); this.AboutButton.Location = new System.Drawing.Point(0, 72);
this.button3.Name = "button3"; this.AboutButton.Name = "AboutButton";
this.button3.Size = new System.Drawing.Size(172, 23); this.AboutButton.Size = new System.Drawing.Size(172, 23);
this.button3.TabIndex = 0; this.AboutButton.TabIndex = 0;
this.button3.Text = "About"; this.AboutButton.Text = "About";
this.button3.UseVisualStyleBackColor = true; this.AboutButton.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click); this.AboutButton.Click += new System.EventHandler(this.AboutWindowClick);
// //
// label1 // label1
// //
@@ -94,38 +93,26 @@
this.label2.TabIndex = 2; this.label2.TabIndex = 2;
this.label2.Text = "Drawing Program"; this.label2.Text = "Drawing Program";
// //
// button4 // ExitButton
// //
this.button4.Dock = System.Windows.Forms.DockStyle.Top; this.ExitButton.Dock = System.Windows.Forms.DockStyle.Top;
this.button4.Location = new System.Drawing.Point(0, 95); this.ExitButton.Location = new System.Drawing.Point(0, 95);
this.button4.Name = "button4"; this.ExitButton.Name = "ExitButton";
this.button4.Size = new System.Drawing.Size(172, 23); this.ExitButton.Size = new System.Drawing.Size(172, 23);
this.button4.TabIndex = 0; this.ExitButton.TabIndex = 0;
this.button4.Text = "Exit"; this.ExitButton.Text = "Exit";
this.button4.UseVisualStyleBackColor = true; this.ExitButton.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click); this.ExitButton.Click += new System.EventHandler(this.ExitClick);
//
// 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);
// //
// Menu // Menu
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(172, 118); this.ClientSize = new System.Drawing.Size(172, 118);
this.Controls.Add(this.button5); this.Controls.Add(this.ExitButton);
this.Controls.Add(this.button4); this.Controls.Add(this.AboutButton);
this.Controls.Add(this.button3); this.Controls.Add(this.TextEditorButton);
this.Controls.Add(this.button2); this.Controls.Add(this.InteractivePreviewButton);
this.Controls.Add(this.button1);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
@@ -135,7 +122,6 @@
this.Name = "Menu"; this.Name = "Menu";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Menu"; this.Text = "Menu";
this.Load += new System.EventHandler(this.Menu_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -143,13 +129,12 @@
#endregion #endregion
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button InteractivePreviewButton;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button TextEditorButton;
private System.Windows.Forms.Button button3; private System.Windows.Forms.Button AboutButton;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button4; private System.Windows.Forms.Button ExitButton;
private System.Windows.Forms.Button button5;
} }
} }
@@ -15,31 +15,23 @@ namespace Advanced_Software_Engineering {
InitializeComponent(); InitializeComponent();
} }
private void button1_Click(object sender, EventArgs e) { private void InteractivePreviewClick(object sender, EventArgs e) {
new Draw_Preview().Show(); new Draw_Preview().Show();
this.Hide(); this.Hide();
} }
private void button2_Click(object sender, EventArgs e) { private void TextEditorClick(object sender, EventArgs e) {
new Text_Editor().Show(); new TextEditor().Show();
this.Hide(); this.Hide();
} }
private void button3_Click(object sender, EventArgs e) { private void AboutWindowClick(object sender, EventArgs e) {
new About_Window().Show(); new About_Window().Show();
this.Hide(); this.Hide();
} }
private void button4_Click(object sender, EventArgs e) { private void ExitClick(object sender, EventArgs e) {
this.Close(); 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();
}
} }
} }
@@ -5,7 +5,7 @@ namespace Advanced_Software_Engineering
/// <summary> /// <summary>
/// Auto generated code /// Auto generated code
/// </summary> /// </summary>
partial class Text_Editor partial class TextEditor
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -34,8 +34,8 @@ namespace Advanced_Software_Engineering
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Text_Editor)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TextEditor));
this.textBox1 = new System.Windows.Forms.TextBox(); this.TextBox = new System.Windows.Forms.TextBox();
this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newFileToolStripMenuItem = 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.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.label1 = new System.Windows.Forms.Label(); 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.menuStrip1.SuspendLayout();
this.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.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.TextBox.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.TextBox.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.TextBox.Location = new System.Drawing.Point(0, 23);
this.textBox1.Multiline = true; this.TextBox.Multiline = true;
this.textBox1.Name = "textBox1"; this.TextBox.Name = "TextBox";
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.TextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.textBox1.Size = new System.Drawing.Size(602, 509); this.TextBox.Size = new System.Drawing.Size(602, 509);
this.textBox1.TabIndex = 0; this.TextBox.TabIndex = 0;
this.textBox1.WordWrap = false; this.TextBox.WordWrap = false;
this.textBox1.Click += new System.EventHandler(this.textBox1_Click); this.TextBox.Click += new System.EventHandler(this.TextBoxClick);
this.textBox1.TextChanged += new System.EventHandler(this.handleKeypress); this.TextBox.TextChanged += new System.EventHandler(this.HandleKeypress);
this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Text_Editor_PreviewKeyDown); this.TextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Text_Editor_PreviewKeyDown);
this.textBox1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyUp); this.TextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.TextBox_KeyUp);
// //
// menuStrip1 // menuStrip1
// //
@@ -104,56 +104,56 @@ namespace Advanced_Software_Engineering
this.newFileToolStripMenuItem.Name = "newFileToolStripMenuItem"; this.newFileToolStripMenuItem.Name = "newFileToolStripMenuItem";
this.newFileToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.newFileToolStripMenuItem.Size = new System.Drawing.Size(202, 22);
this.newFileToolStripMenuItem.Text = "New File (Ctrl + N)"; 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 // openToolStripMenuItem
// //
this.openToolStripMenuItem.Name = "openToolStripMenuItem"; this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.openToolStripMenuItem.Size = new System.Drawing.Size(202, 22);
this.openToolStripMenuItem.Text = "Open (Ctrl + O)"; 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 // saveToolStripMenuItem
// //
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.saveToolStripMenuItem.Size = new System.Drawing.Size(202, 22);
this.saveToolStripMenuItem.Text = "Save (Ctrl + S)"; 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 // saveAsToolStripMenuItem
// //
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(202, 22);
this.saveAsToolStripMenuItem.Text = "Save As (Ctrl + Shift + S)"; 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 // exitToolStripMenuItem
// //
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(202, 22); this.exitToolStripMenuItem.Size = new System.Drawing.Size(202, 22);
this.exitToolStripMenuItem.Text = "Exit (Alt + F4)"; 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 // runToolStripMenuItem
// //
this.runToolStripMenuItem.Name = "runToolStripMenuItem"; this.runToolStripMenuItem.Name = "runToolStripMenuItem";
this.runToolStripMenuItem.Size = new System.Drawing.Size(63, 20); this.runToolStripMenuItem.Size = new System.Drawing.Size(63, 20);
this.runToolStripMenuItem.Text = "Run (F5)"; this.runToolStripMenuItem.Text = "Run (F5)";
this.runToolStripMenuItem.Click += new System.EventHandler(this.runToolStripMenuItem_Click); this.runToolStripMenuItem.Click += new System.EventHandler(this.RunToolStripMenuItem_Click);
// //
// checkSyntaxToolStripMenuItem // checkSyntaxToolStripMenuItem
// //
this.checkSyntaxToolStripMenuItem.Name = "checkSyntaxToolStripMenuItem"; this.checkSyntaxToolStripMenuItem.Name = "checkSyntaxToolStripMenuItem";
this.checkSyntaxToolStripMenuItem.Size = new System.Drawing.Size(151, 20); this.checkSyntaxToolStripMenuItem.Size = new System.Drawing.Size(151, 20);
this.checkSyntaxToolStripMenuItem.Text = "Check Syntax (Shift + F5)"; 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 // describeToolStripMenuItem
// //
this.describeToolStripMenuItem.Name = "describeToolStripMenuItem"; this.describeToolStripMenuItem.Name = "describeToolStripMenuItem";
this.describeToolStripMenuItem.Size = new System.Drawing.Size(125, 20); this.describeToolStripMenuItem.Size = new System.Drawing.Size(125, 20);
this.describeToolStripMenuItem.Text = "Describe (Shift + F1)"; 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 // helpToolStripMenuItem
// //
@@ -169,14 +169,14 @@ namespace Advanced_Software_Engineering
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(107, 22); this.aboutToolStripMenuItem.Size = new System.Drawing.Size(107, 22);
this.aboutToolStripMenuItem.Text = "About"; this.aboutToolStripMenuItem.Text = "About";
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); this.aboutToolStripMenuItem.Click += new System.EventHandler(this.AboutToolStripMenuItem_Click);
// //
// helpToolStripMenuItem1 // helpToolStripMenuItem1
// //
this.helpToolStripMenuItem1.Name = "helpToolStripMenuItem1"; this.helpToolStripMenuItem1.Name = "helpToolStripMenuItem1";
this.helpToolStripMenuItem1.Size = new System.Drawing.Size(107, 22); this.helpToolStripMenuItem1.Size = new System.Drawing.Size(107, 22);
this.helpToolStripMenuItem1.Text = "Help"; this.helpToolStripMenuItem1.Text = "Help";
this.helpToolStripMenuItem1.Click += new System.EventHandler(this.helpToolStripMenuItem1_Click); this.helpToolStripMenuItem1.Click += new System.EventHandler(this.HelpToolStripMenuItem1_Click);
// //
// label1 // label1
// //
@@ -187,23 +187,23 @@ namespace Advanced_Software_Engineering
this.label1.Size = new System.Drawing.Size(0, 13); this.label1.Size = new System.Drawing.Size(0, 13);
this.label1.TabIndex = 2; this.label1.TabIndex = 2;
// //
// timer1 // SavedLabelTimer
// //
this.timer1.Interval = 1000; this.SavedLabelTimer.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick); this.SavedLabelTimer.Tick += new System.EventHandler(this.SavedLableTimerTick);
// //
// Text_Editor // TextEditor
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(602, 548); this.ClientSize = new System.Drawing.Size(602, 548);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1); this.Controls.Add(this.TextBox);
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.KeyPreview = true; this.KeyPreview = true;
this.MainMenuStrip = this.menuStrip1; this.MainMenuStrip = this.menuStrip1;
this.Name = "Text_Editor"; this.Name = "TextEditor";
this.Text = "Advanced Software Engineering - Text Editor"; this.Text = "Advanced Software Engineering - Text Editor";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Text_Editor_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Text_Editor_FormClosing);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Console_FormClosed); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Console_FormClosed);
@@ -217,7 +217,7 @@ namespace Advanced_Software_Engineering
#endregion #endregion
private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox TextBox;
private MenuStrip menuStrip1; private MenuStrip menuStrip1;
private ToolStripMenuItem fileToolStripMenuItem; private ToolStripMenuItem fileToolStripMenuItem;
private ToolStripMenuItem newFileToolStripMenuItem; private ToolStripMenuItem newFileToolStripMenuItem;
@@ -231,7 +231,7 @@ namespace Advanced_Software_Engineering
private ToolStripMenuItem saveAsToolStripMenuItem; private ToolStripMenuItem saveAsToolStripMenuItem;
private ToolStripMenuItem checkSyntaxToolStripMenuItem; private ToolStripMenuItem checkSyntaxToolStripMenuItem;
private Label label1; private Label label1;
private Timer timer1; private Timer SavedLabelTimer;
private ToolStripMenuItem describeToolStripMenuItem; private ToolStripMenuItem describeToolStripMenuItem;
} }
} }
@@ -4,7 +4,7 @@ using System.Windows.Forms;
namespace Advanced_Software_Engineering { namespace Advanced_Software_Engineering {
public partial class Text_Editor : Form { public partial class TextEditor : Form {
private const string DefaultTitleString = "ASE - Text Editor"; private const string DefaultTitleString = "ASE - Text Editor";
private Draw_Preview DisplayForm = null; private Draw_Preview DisplayForm = null;
@@ -16,7 +16,7 @@ namespace Advanced_Software_Engineering {
/// <summary> /// <summary>
/// The text editor is the main window that the user will be using for writing code. /// The text editor is the main window that the user will be using for writing code.
/// </summary> /// </summary>
public Text_Editor() { public TextEditor() {
SettingsAndHelperFunctions.NumberOfWindows++; SettingsAndHelperFunctions.NumberOfWindows++;
InitializeComponent(); InitializeComponent();
UpdateTitle(); 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. /// The text editor is the main window that the user will be using for writing code.
/// </summary> /// </summary>
/// <param name="openFile">File dialog which points to the file to open</param> /// <param name="openFile">File dialog which points to the file to open</param>
public Text_Editor(OpenFileDialog openFile) { public TextEditor(OpenFileDialog openFile) {
SettingsAndHelperFunctions.NumberOfWindows++; SettingsAndHelperFunctions.NumberOfWindows++;
InitializeComponent(); InitializeComponent();
StreamReader fileStream = new StreamReader(openFile.OpenFile()); StreamReader fileStream = new StreamReader(openFile.OpenFile());
textBox1.Text = fileStream.ReadToEnd(); TextBox.Text = fileStream.ReadToEnd();
unsavedChanges = false; unsavedChanges = false;
newWindow = false; newWindow = false;
okToOverwrite = true; okToOverwrite = true;
@@ -50,14 +50,14 @@ namespace Advanced_Software_Engineering {
if (unsavedChanges) this.Text = "* " + this.Text + " *"; if (unsavedChanges) this.Text = "* " + this.Text + " *";
} }
private void saveFile() { private void SaveFile() {
if (!okToOverwrite) saveFileAs(); if (!okToOverwrite) SaveFileAs();
else { else {
try { try {
StreamWriter fileStream = new StreamWriter(fileName); StreamWriter fileStream = new StreamWriter(fileName);
fileStream.Write(textBox1.Text); fileStream.Write(TextBox.Text);
unsavedChanges = false; unsavedChanges = false;
showSavedMessage(); ShowSavedMessage();
fileStream.Close(); fileStream.Close();
} catch (Exception e) { } catch (Exception e) {
new ErrorWindow("Write Failed!", "The program failed to write the file.", e.Message + "\n" + e.StackTrace, ErrorWindow.ERROR_MESSAGE).Show(); 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 { SaveFileDialog saveFileDialog = new SaveFileDialog {
OverwritePrompt = true, OverwritePrompt = true,
DefaultExt = ".txt" DefaultExt = ".txt"
@@ -79,11 +79,11 @@ namespace Advanced_Software_Engineering {
if (dialogResult == DialogResult.OK) { if (dialogResult == DialogResult.OK) {
StreamWriter fileStream = new StreamWriter(saveFileDialog.OpenFile()); StreamWriter fileStream = new StreamWriter(saveFileDialog.OpenFile());
try { try {
fileStream.Write(textBox1.Text); fileStream.Write(TextBox.Text);
unsavedChanges = false; unsavedChanges = false;
okToOverwrite = true; okToOverwrite = true;
fileName = saveFileDialog.FileName; fileName = saveFileDialog.FileName;
showSavedMessage(); ShowSavedMessage();
} catch (Exception e) { } catch (Exception e) {
new ErrorWindow("Write Failed!", "The program failed to write the file.", e.Message + "\n" + e.StackTrace, ErrorWindow.ERROR_MESSAGE).Show(); new ErrorWindow("Write Failed!", "The program failed to write the file.", e.Message + "\n" + e.StackTrace, ErrorWindow.ERROR_MESSAGE).Show();
} finally { } finally {
@@ -93,55 +93,55 @@ namespace Advanced_Software_Engineering {
} }
} }
private void showSavedMessage() { private void ShowSavedMessage() {
label1.Text = "File saved"; label1.Text = "File saved";
timer1.Start(); SavedLabelTimer.Start();
} }
private void updateRowCol() { private void UpdateRowsAndColumnsPreview() {
int line = textBox1.GetLineFromCharIndex(textBox1.SelectionStart); int line = TextBox.GetLineFromCharIndex(TextBox.SelectionStart);
int column = textBox1.SelectionStart - textBox1.GetFirstCharIndexFromLine(line); int column = TextBox.SelectionStart - TextBox.GetFirstCharIndexFromLine(line);
line++; line++;
column++; column++;
label1.Text = "row: " + line.ToString() + " col: " + column.ToString(); label1.Text = "row: " + line.ToString() + " col: " + column.ToString();
} }
private void handleKeypress() { private void HandleKeypress() {
if (newWindow) newWindow = false; if (newWindow) newWindow = false;
updateSaveStatus(); UpdateSaveStatus();
updateRowCol(); UpdateRowsAndColumnsPreview();
} }
private void updateSaveStatus() { private void UpdateSaveStatus() {
if (!unsavedChanges) { if (!unsavedChanges) {
unsavedChanges = true; unsavedChanges = true;
UpdateTitle(); UpdateTitle();
} }
} }
private void openFile() { private void OpenFile() {
OpenFileDialog openFileDialog = new OpenFileDialog(); OpenFileDialog openFileDialog = new OpenFileDialog();
if (openFileDialog.ShowDialog() == DialogResult.OK) { if (openFileDialog.ShowDialog() == DialogResult.OK) {
if (newWindow) { if (newWindow) {
StreamReader fileStream = new StreamReader(openFileDialog.OpenFile()); StreamReader fileStream = new StreamReader(openFileDialog.OpenFile());
textBox1.Text = fileStream.ReadToEnd(); TextBox.Text = fileStream.ReadToEnd();
unsavedChanges = false; unsavedChanges = false;
okToOverwrite = true; okToOverwrite = true;
newWindow = false; newWindow = false;
UpdateTitle(openFileDialog.FileName); UpdateTitle(openFileDialog.FileName);
fileStream.Close(); fileStream.Close();
} else new Text_Editor(openFileDialog).Show(); } else new TextEditor(openFileDialog).Show();
} }
} }
private void RunCode() { private void RunCode() {
if (DisplayForm == null || DisplayForm.IsDisposed) { if (DisplayForm == null || DisplayForm.IsDisposed) {
DisplayForm = new Draw_Preview(textBox1.Text); DisplayForm = new Draw_Preview(TextBox.Text);
} else { } else {
Console.WriteLine("Removed all commands"); Console.WriteLine("Removed all commands");
DisplayForm.RemoveAllCommands(); DisplayForm.RemoveAllCommands();
DisplayForm.SubmitCommands(textBox1.Text); DisplayForm.SubmitCommands(TextBox.Text);
} }
if (DisplayForm.IsSuccess()) { if (DisplayForm.IsSuccess()) {
@@ -156,14 +156,14 @@ namespace Advanced_Software_Engineering {
public void CheckCode() { public void CheckCode() {
Draw_Preview tmpDrawPreview = new Draw_Preview(); Draw_Preview tmpDrawPreview = new Draw_Preview();
tmpDrawPreview.Hide(); 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(); 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(); tmpDrawPreview.Close();
SettingsAndHelperFunctions.WindowClosed(); SettingsAndHelperFunctions.WindowClosed();
tmpDrawPreview.Dispose(); tmpDrawPreview.Dispose();
} }
private void handleExit(FormClosingEventArgs e) { private void HandleExit(FormClosingEventArgs e) {
if (unsavedChanges) { if (unsavedChanges) {
DialogResult dialogResult = MessageBox.Show("You have unsaved work. Would you like to discard your work?", "Unsaved work!", MessageBoxButtons.YesNo, MessageBoxIcon.None); 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; if (e != null) e.Cancel = dialogResult != DialogResult.Yes;
@@ -173,7 +173,7 @@ namespace Advanced_Software_Engineering {
private void DescribeCode() { private void DescribeCode() {
Draw_Preview tmpDrawPreview = new Draw_Preview(); Draw_Preview tmpDrawPreview = new Draw_Preview();
tmpDrawPreview.Hide(); tmpDrawPreview.Hide();
tmpDrawPreview.SubmitCommands(textBox1.Text); tmpDrawPreview.SubmitCommands(TextBox.Text);
string commandDesc = tmpDrawPreview.DescribeAllCommands(); string commandDesc = tmpDrawPreview.DescribeAllCommands();
Console.WriteLine(commandDesc); Console.WriteLine(commandDesc);
@@ -191,41 +191,41 @@ namespace Advanced_Software_Engineering {
Dispose(); 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) { private void Text_Editor_PreviewKeyDown(object sender, KeyEventArgs e) {
//New window //New window
if (e.Control && e.KeyCode == Keys.N) { if (e.Control && e.KeyCode == Keys.N) {
createNewInstance(); CreateNewInstance();
e.Handled = true; e.Handled = true;
} else if (e.Control && e.KeyCode == Keys.S) { } else if (e.Control && e.KeyCode == Keys.S) {
saveFile(); SaveFile();
e.Handled = true; e.Handled = true;
} else if (e.Control && e.Shift && e.KeyCode == Keys.S) { } else if (e.Control && e.Shift && e.KeyCode == Keys.S) {
saveFileAs(); SaveFileAs();
e.Handled = true; e.Handled = true;
} else if (e.Control && e.KeyCode == Keys.O) { } else if (e.Control && e.KeyCode == Keys.O) {
openFile(); OpenFile();
e.Handled = true; e.Handled = true;
} else if (e.KeyCode == Keys.F5) { } else if (e.KeyCode == Keys.F5) {
RunCode(); RunCode();
@@ -237,21 +237,21 @@ namespace Advanced_Software_Engineering {
DescribeCode(); DescribeCode();
e.Handled = true; e.Handled = true;
} else { } 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) { private void SavedLableTimerTick(object sender, EventArgs e) {
updateRowCol(); UpdateRowsAndColumnsPreview();
timer1.Stop(); 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();
} }
} }
@@ -120,7 +120,7 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="SavedLabelTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>132, 17</value> <value>132, 17</value>
</metadata> </metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">