Private
Public Access
CodeMaid Cleanup for main project
This commit is contained in:
1 parent
08f0a0f998
commit
31aea2831f
31 files changed
+173
-308
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||||
</startup>
|
</startup>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -1,19 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering {
|
namespace Advanced_Software_Engineering {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The commander class takes care of commands. It also takes control of the drawer.
|
/// The commander class takes care of commands. It also takes control of the drawer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Commander {
|
public class Commander {
|
||||||
|
private Graphics graphics;
|
||||||
Graphics graphics;
|
private List<Verb> commands = new List<Verb>();
|
||||||
List<Verb> commands = new List<Verb>();
|
private Drawer drawer;
|
||||||
Drawer drawer;
|
private bool commands_ok = true;
|
||||||
bool commands_ok = true;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This command updates the graphics element (usually) when the page repaints.
|
/// This command updates the graphics element (usually) when the page repaints.
|
||||||
@@ -58,6 +56,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
this.ProcessCommands(rawCommands);
|
this.ProcessCommands(rawCommands);
|
||||||
drawer.ResetDrawer();
|
drawer.ResetDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a verb to the command list to be executed.
|
/// Adds a verb to the command list to be executed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -71,7 +70,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rawCommands">Processes commands seperated by \n or \r\n</param>
|
/// <param name="rawCommands">Processes commands seperated by \n or \r\n</param>
|
||||||
/// <param name="pardonCommands">If the command is wrong, don't remove all of the commands</param>
|
/// <param name="pardonCommands">If the command is wrong, don't remove all of the commands</param>
|
||||||
public void ProcessCommands(string rawCommands, bool pardonCommands=false) {
|
public void ProcessCommands(string rawCommands, bool pardonCommands = false) {
|
||||||
//ignore case
|
//ignore case
|
||||||
rawCommands = rawCommands.ToLower();
|
rawCommands = rawCommands.ToLower();
|
||||||
Console.WriteLine("Processing:\n" + rawCommands);
|
Console.WriteLine("Processing:\n" + rawCommands);
|
||||||
@@ -101,7 +100,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (failed) {
|
if (failed) {
|
||||||
if(!pardonCommands) RemoveAllCommands();
|
if (!pardonCommands) RemoveAllCommands();
|
||||||
commands_ok = false;
|
commands_ok = false;
|
||||||
} else {
|
} else {
|
||||||
commands_ok = true;
|
commands_ok = true;
|
||||||
@@ -112,7 +111,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
foreach (Verb verb in this.commands) {
|
foreach (Verb verb in this.commands) {
|
||||||
Console.WriteLine(verb.GetDescription());
|
Console.WriteLine(verb.GetDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -157,5 +155,4 @@ namespace Advanced_Software_Engineering {
|
|||||||
return commands_ok;
|
return commands_ok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -1,24 +1,25 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering {
|
namespace Advanced_Software_Engineering {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The drawer is responsible for drawing on the graphics object.
|
/// The drawer is responsible for drawing on the graphics object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Drawer {
|
public class Drawer {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The starting color of the pen / brush
|
/// The starting color of the pen / brush
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected static Color defaultColor = Color.Black;
|
protected static Color defaultColor = Color.Black;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The deafult width of the pen
|
/// The deafult width of the pen
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected static float defaultWidth = 1f;
|
protected static float defaultWidth = 1f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Weather enclosed spaces will have fill.
|
/// Weather enclosed spaces will have fill.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -28,6 +29,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// The Brush object
|
/// The Brush object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected SolidBrush brush;
|
protected SolidBrush brush;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Pen object
|
/// The Pen object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -37,6 +39,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// The current position of the pen.
|
/// The current position of the pen.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected Point penPosition;
|
protected Point penPosition;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The graphics object
|
/// The graphics object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -73,6 +76,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="point">Position to move the pen to</param>
|
/// <param name="point">Position to move the pen to</param>
|
||||||
public void MovePen(Point point) => penPosition = point;
|
public void MovePen(Point point) => penPosition = point;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the current pen position
|
/// Returns the current pen position
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -84,14 +88,17 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>current fill satus</returns>
|
/// <returns>current fill satus</returns>
|
||||||
public bool GetFill() => fill;
|
public bool GetFill() => fill;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allows the filling of objects.
|
/// Allows the filling of objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void EnableFill() => fill = true;
|
public void EnableFill() => fill = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disables the filling of objects.
|
/// Disables the filling of objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void DisableFill() => fill = false;
|
public void DisableFill() => fill = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the filling of objects
|
/// Set the filling of objects
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -103,6 +110,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">Pen color</param>
|
/// <param name="color">Pen color</param>
|
||||||
public void SetPenColor(Color color) => pen.Color = color;
|
public void SetPenColor(Color color) => pen.Color = color;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the width of the pen
|
/// Set the width of the pen
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -129,7 +137,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="points">Points to draw to</param>
|
/// <param name="points">Points to draw to</param>
|
||||||
public void DrawLines(Point[] points) {
|
public void DrawLines(Point[] points) {
|
||||||
|
|
||||||
if (points.Length < 2) {
|
if (points.Length < 2) {
|
||||||
throw new Exception("Cannot have less than two points in a line");
|
throw new Exception("Cannot have less than two points in a line");
|
||||||
}
|
}
|
||||||
@@ -139,7 +146,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
|
|
||||||
path.AddLines(points);
|
path.AddLines(points);
|
||||||
path.AddLine(points[0], points.Last()); //Add final line
|
path.AddLine(points[0], points.Last()); //Add final line
|
||||||
|
|
||||||
DrawLines(path);
|
DrawLines(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,4 +183,4 @@ namespace Advanced_Software_Engineering {
|
|||||||
graphics.FillRectangle(new SolidBrush(pen.Color), penPosition.X, penPosition.Y, 1, 1);
|
graphics.FillRectangle(new SolidBrush(pen.Color), penPosition.X, penPosition.Y, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,16 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering
|
namespace Advanced_Software_Engineering {
|
||||||
{
|
|
||||||
static class Program
|
internal static class Program {
|
||||||
{
|
|
||||||
public static Form MainMenu;
|
public static Form MainMenu;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
private static void Main() {
|
||||||
{
|
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|
||||||
@@ -23,4 +18,4 @@ namespace Advanced_Software_Engineering
|
|||||||
Application.Run(MainMenu);
|
Application.Run(MainMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -1,5 +1,4 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
@@ -33,4 +32,4 @@ using System.Runtime.InteropServices;
|
|||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
+5
-7
@@ -1,14 +1,13 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Security.Policy;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering {
|
namespace Advanced_Software_Engineering {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This class simply provides settings and some functions that are used across many components.
|
/// This class simply provides settings and some functions that are used across many components.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SettingsAndHelperFunctions {
|
public class SettingsAndHelperFunctions {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The variable simply keep track of the windows that are currently shown (excluding <see cref="MainMenu"/>).
|
/// The variable simply keep track of the windows that are currently shown (excluding <see cref="MainMenu"/>).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -23,8 +22,8 @@ namespace Advanced_Software_Engineering {
|
|||||||
System.Console.WriteLine("Showing MainMenu");
|
System.Console.WriteLine("Showing MainMenu");
|
||||||
Program.MainMenu.Show();
|
Program.MainMenu.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This function removes spaces from the start and the end of the text. This should be unit tested.
|
/// This function removes spaces from the start and the end of the text. This should be unit tested.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -71,7 +70,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
//Console.WriteLine("Result: " + result);
|
//Console.WriteLine("Result: " + result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -135,4 +133,4 @@ namespace Advanced_Software_Engineering {
|
|||||||
return commandAndParameters;
|
return commandAndParameters;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-9
@@ -1,16 +1,11 @@
|
|||||||
using System;
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Circle Verb class.
|
/// Circle Verb class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Circle : Verb {
|
public class Circle : Verb {
|
||||||
Drawer drawer;
|
private Drawer drawer;
|
||||||
double scale;
|
private double scale;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Circle constructor creates the Circle verb.
|
/// Circle constructor creates the Circle verb.
|
||||||
@@ -37,4 +32,4 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
return "Draws a circle radius " + scale.ToString() + ", with origin of the pen";
|
return "Draws a circle radius " + scale.ToString() + ", with origin of the pen";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-9
@@ -1,15 +1,10 @@
|
|||||||
using System;
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Clear Verb class.
|
/// The Clear Verb class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Clear : Verb {
|
public class Clear : Verb {
|
||||||
Drawer drawer;
|
private Drawer drawer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create the clear Verb
|
/// Create the clear Verb
|
||||||
@@ -31,6 +26,5 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
public string GetDescription() {
|
public string GetDescription() {
|
||||||
return "Clears the canvas";
|
return "Clears the canvas";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-8
@@ -1,15 +1,10 @@
|
|||||||
using System;
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Dot Verb class
|
/// The Dot Verb class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Dot : Verb {
|
public class Dot : Verb {
|
||||||
Drawer drawer;
|
private Drawer drawer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the Dot Verb
|
/// Creates the Dot Verb
|
||||||
@@ -34,4 +29,4 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
return "Places a dot where the pen currently is";
|
return "Places a dot where the pen currently is";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-11
@@ -1,20 +1,16 @@
|
|||||||
using System;
|
using System.Drawing;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DrawLines Verb class
|
/// DrawLines Verb class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DrawLines : Verb {
|
public class DrawLines : Verb {
|
||||||
Drawer drawer;
|
private Drawer drawer;
|
||||||
Point[] points;
|
private Point[] points;
|
||||||
|
|
||||||
bool descCreated = false;
|
private bool descCreated = false;
|
||||||
string desc;
|
private string desc;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DrawLines constructor
|
/// DrawLines constructor
|
||||||
@@ -48,4 +44,4 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-10
@@ -1,18 +1,13 @@
|
|||||||
using System;
|
using System.Drawing;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DrawTo Verb class
|
/// DrawTo Verb class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DrawTo : Verb {
|
public class DrawTo : Verb {
|
||||||
|
private Drawer drawer;
|
||||||
Drawer drawer;
|
private Point moveToPoint;
|
||||||
Point moveToPoint;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the DrawTo intstance
|
/// Creates the DrawTo intstance
|
||||||
@@ -40,4 +35,4 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
return "Draw line " + moveToPoint.X + ", " + moveToPoint.Y;
|
return "Draw line " + moveToPoint.X + ", " + moveToPoint.Y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-9
@@ -1,16 +1,11 @@
|
|||||||
using System;
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fill Verb class
|
/// Fill Verb class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Fill : Verb {
|
public class Fill : Verb {
|
||||||
Drawer drawer;
|
private Drawer drawer;
|
||||||
bool enable;
|
private bool enable;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fill enables or disables the fill insider drawer
|
/// Fill enables or disables the fill insider drawer
|
||||||
@@ -39,4 +34,4 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
else return "Disable fill";
|
else return "Disable fill";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-12
@@ -1,19 +1,13 @@
|
|||||||
using System;
|
using System.Drawing;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The FillColor Verb class
|
/// The FillColor Verb class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FillColor : Verb {
|
public class FillColor : Verb {
|
||||||
|
private Drawer drawer;
|
||||||
Drawer drawer;
|
private Color color;
|
||||||
Color color;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create the FillColor instance
|
/// Create the FillColor instance
|
||||||
@@ -39,6 +33,5 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
public string GetDescription() {
|
public string GetDescription() {
|
||||||
return "Set fill color to: " + color.ToString();
|
return "Set fill color to: " + color.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-11
@@ -1,18 +1,13 @@
|
|||||||
using System;
|
using System.Drawing;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// MoveTo Verb class
|
/// MoveTo Verb class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MoveTo : Verb {
|
public class MoveTo : Verb {
|
||||||
|
private Drawer drawer;
|
||||||
Drawer drawer;
|
private Point moveToPoint;
|
||||||
Point moveToPoint;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a MoveTo instance
|
/// Creates a MoveTo instance
|
||||||
@@ -49,6 +44,5 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
public string GetDescription() {
|
public string GetDescription() {
|
||||||
return "Move origin to " + moveToPoint.X + ", " + moveToPoint.Y;
|
return "Move origin to " + moveToPoint.X + ", " + moveToPoint.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-10
@@ -1,18 +1,13 @@
|
|||||||
using System;
|
using System.Drawing;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The PenColor Verb class
|
/// The PenColor Verb class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PenColor : Verb {
|
public class PenColor : Verb {
|
||||||
|
private Drawer drawer;
|
||||||
Drawer drawer;
|
private Color color;
|
||||||
Color color;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a PenColor instance
|
/// Creates a PenColor instance
|
||||||
@@ -39,4 +34,4 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
return "Set pen color to: " + color.ToString();
|
return "Set pen color to: " + color.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-8
@@ -1,16 +1,12 @@
|
|||||||
using System;
|
using System.Drawing;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Quadrilateral Verb class
|
/// The Quadrilateral Verb class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Quadrilateral : Verb {
|
public class Quadrilateral : Verb {
|
||||||
Verb verb;
|
private Verb verb;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a Quadrilateral instances
|
/// Creates a Quadrilateral instances
|
||||||
@@ -35,4 +31,4 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
/// <returns>Description of the quadrilateral points</returns>
|
/// <returns>Description of the quadrilateral points</returns>
|
||||||
public string GetDescription() => verb.GetDescription();
|
public string GetDescription() => verb.GetDescription();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-12
@@ -1,12 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms.VisualStyles;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rectangle Verb class
|
/// Rectangle Verb class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -14,11 +11,11 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
/// Correct
|
/// Correct
|
||||||
/// </todo>
|
/// </todo>
|
||||||
public class Rectangle : Verb {
|
public class Rectangle : Verb {
|
||||||
Drawer drawer;
|
private Drawer drawer;
|
||||||
PointF[] points;
|
private PointF[] points;
|
||||||
|
|
||||||
double width;
|
private double width;
|
||||||
double height;
|
private double height;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a rectangle instance. Makes sure that
|
/// Create a rectangle instance. Makes sure that
|
||||||
@@ -29,7 +26,7 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
public Rectangle(Drawer drawer, double width, double height) {
|
public Rectangle(Drawer drawer, double width, double height) {
|
||||||
this.drawer = drawer;
|
this.drawer = drawer;
|
||||||
|
|
||||||
float root2 = (float) Math.Sqrt(2) / 2;
|
float root2 = (float)Math.Sqrt(2) / 2;
|
||||||
|
|
||||||
points = new PointF[]
|
points = new PointF[]
|
||||||
{
|
{
|
||||||
@@ -43,7 +40,6 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
this.height = height;
|
this.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the description from the rectangle
|
/// Gets the description from the rectangle
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -67,6 +63,5 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
|
|
||||||
drawer.DrawLines(morePoints.ToArray());
|
drawer.DrawLines(morePoints.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-9
@@ -1,20 +1,18 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A class that generates a RegularPolygon verb.
|
/// A class that generates a RegularPolygon verb.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RegularPolygon : Verb {
|
public class RegularPolygon : Verb {
|
||||||
Drawer drawer;
|
private Drawer drawer;
|
||||||
int sides;
|
private int sides;
|
||||||
double scale;
|
private double scale;
|
||||||
double offset;
|
private double offset;
|
||||||
List<Point> points;
|
private List<Point> points;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Draws a regular polygon.
|
/// Draws a regular polygon.
|
||||||
@@ -66,4 +64,4 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
return "Draws a " + sides + " sided regular polygon, with rotation of " + offset + " radians, with inner radius of " + scale;
|
return "Draws a " + sides + " sided regular polygon, with rotation of " + offset + " radians, with inner radius of " + scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-9
@@ -1,15 +1,10 @@
|
|||||||
using System;
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Setsets the pen to the initial position.
|
/// Setsets the pen to the initial position.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ResetPen : Verb {
|
public class ResetPen : Verb {
|
||||||
Drawer drawer;
|
private Drawer drawer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the ResetPen verb
|
/// Creates the ResetPen verb
|
||||||
@@ -31,6 +26,5 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
public string GetDescription() {
|
public string GetDescription() {
|
||||||
return "Moves pen to the start (0, 0)";
|
return "Moves pen to the start (0, 0)";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-8
@@ -1,16 +1,11 @@
|
|||||||
using System;
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Square Verb class
|
/// The Square Verb class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Square : Verb {
|
public class Square : Verb {
|
||||||
|
private Verb verb;
|
||||||
|
|
||||||
Verb verb;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A new Squre instance. Draws squares using <see cref="RegularPolygon"/>
|
/// A new Squre instance. Draws squares using <see cref="RegularPolygon"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -41,4 +36,4 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetDescription() => verb.GetDescription();
|
public string GetDescription() => verb.GetDescription();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-8
@@ -1,16 +1,12 @@
|
|||||||
using System;
|
using System.Drawing;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Triangle Verb class
|
/// The Triangle Verb class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Triangle : Verb {
|
public class Triangle : Verb {
|
||||||
Verb verb;
|
private Verb verb;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new Triangle instance using <see cref="RegularPolygon"/>.
|
/// Creates a new Triangle instance using <see cref="RegularPolygon"/>.
|
||||||
@@ -53,4 +49,4 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
|||||||
/// <returns>Description of how the triangle will be drawn</returns>
|
/// <returns>Description of how the triangle will be drawn</returns>
|
||||||
public string GetDescription() => verb.GetDescription();
|
public string GetDescription() => verb.GetDescription();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs {
|
namespace Advanced_Software_Engineering.Verbs {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This class contains a large amount of useful conversions
|
/// This class contains a large amount of useful conversions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ValueHelper {
|
public class ValueHelper {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts string to int (if possible)
|
/// Converts string to int (if possible)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -74,7 +72,6 @@ namespace Advanced_Software_Engineering.Verbs {
|
|||||||
if (text.StartsWith("#"))
|
if (text.StartsWith("#"))
|
||||||
text = text.Substring(1);
|
text = text.Substring(1);
|
||||||
|
|
||||||
|
|
||||||
switch (text.Length) {
|
switch (text.Length) {
|
||||||
case 6:
|
case 6:
|
||||||
return Color.FromArgb(
|
return Color.FromArgb(
|
||||||
@@ -106,4 +103,4 @@ namespace Advanced_Software_Engineering.Verbs {
|
|||||||
return Color.FromArgb(a, r, g, b);
|
return Color.FromArgb(a, r, g, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,19 @@
|
|||||||
using System;
|
namespace Advanced_Software_Engineering {
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering {
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verb is an interface for executing and getting the descriptions of Verbs. Some Verbs draw lines, some verbs will assign
|
/// Verb is an interface for executing and getting the descriptions of Verbs. Some Verbs draw lines, some verbs will assign
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface Verb {
|
public interface Verb {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This executes the verb to the drawer inside it.
|
/// This executes the verb to the drawer inside it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void ExecuteVerb();
|
void ExecuteVerb();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The description of what the Verb will do.
|
/// The description of what the Verb will do.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A string description of what the Verb will do</returns>
|
/// <returns>A string description of what the Verb will do</returns>
|
||||||
string GetDescription();
|
string GetDescription();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,16 @@
|
|||||||
using System;
|
|
||||||
using System.CodeDom;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Windows.Forms.VisualStyles;
|
|
||||||
using Advanced_Software_Engineering.Verbs;
|
using Advanced_Software_Engineering.Verbs;
|
||||||
using Advanced_Software_Engineering.Verbs.DrawingVerbs;
|
using Advanced_Software_Engineering.Verbs.DrawingVerbs;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering {
|
namespace Advanced_Software_Engineering {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This class is responsible for creating Verbs.
|
/// This class is responsible for creating Verbs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class VerbFactory {
|
public class VerbFactory {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This function returns a Verb from a command and drawer.
|
/// This function returns a Verb from a command and drawer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -23,7 +21,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// <param name="fullCommand">The command as a string</param>
|
/// <param name="fullCommand">The command as a string</param>
|
||||||
/// <returns>A verb that maches the command</returns>
|
/// <returns>A verb that maches the command</returns>
|
||||||
public static Verb MakeVerb(Drawer drawer, string fullCommand) {
|
public static Verb MakeVerb(Drawer drawer, string fullCommand) {
|
||||||
|
|
||||||
Dictionary<string, string[]> commandAndParameters = SettingsAndHelperFunctions.CommandAndParameterParser(fullCommand);
|
Dictionary<string, string[]> commandAndParameters = SettingsAndHelperFunctions.CommandAndParameterParser(fullCommand);
|
||||||
|
|
||||||
if (!commandAndParameters.Keys.Contains("command")) throw new Exception("There is no command to process");
|
if (!commandAndParameters.Keys.Contains("command")) throw new Exception("There is no command to process");
|
||||||
@@ -41,7 +38,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
return new MoveTo(drawer,
|
return new MoveTo(drawer,
|
||||||
ValueHelper.ConvertToInt(parameters[0]),
|
ValueHelper.ConvertToInt(parameters[0]),
|
||||||
ValueHelper.ConvertToInt(parameters[1]));
|
ValueHelper.ConvertToInt(parameters[1]));
|
||||||
|
|
||||||
} else throw new Exception(command + " has an incorrect number of parameters");
|
} else throw new Exception(command + " has an incorrect number of parameters");
|
||||||
|
|
||||||
case "drawto":
|
case "drawto":
|
||||||
@@ -142,7 +138,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
return new Dot(drawer);
|
return new Dot(drawer);
|
||||||
} else throw new Exception(command + " doesn't take parameters");
|
} else throw new Exception(command + " doesn't take parameters");
|
||||||
|
|
||||||
|
|
||||||
case "clear":
|
case "clear":
|
||||||
if (parameterLength == 0) {
|
if (parameterLength == 0) {
|
||||||
return new Clear(drawer);
|
return new Clear(drawer);
|
||||||
@@ -210,7 +205,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
default:
|
default:
|
||||||
throw new Exception("Unknown command");
|
throw new Exception("Unknown command");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,13 @@
|
|||||||
using System;
|
using System.Windows.Forms;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
namespace Advanced_Software_Engineering {
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
public partial class About_Window : Form {
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering
|
|
||||||
{
|
|
||||||
public partial class About_Window : Form
|
|
||||||
{
|
|
||||||
///<summary>
|
///<summary>
|
||||||
///Creates an About Window which shows details about the program.
|
///Creates an About Window which shows details about the program.
|
||||||
///</summary>
|
///</summary>
|
||||||
public About_Window()
|
public About_Window() {
|
||||||
{
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
SettingsAndHelperFunctions.NumberOfWindows++;
|
SettingsAndHelperFunctions.NumberOfWindows++;
|
||||||
}
|
}
|
||||||
@@ -26,9 +17,8 @@ namespace Advanced_Software_Engineering
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void About_Window_FormClosed(object sender, FormClosedEventArgs e)
|
private void About_Window_FormClosed(object sender, FormClosedEventArgs e) {
|
||||||
{
|
|
||||||
SettingsAndHelperFunctions.WindowClosed();
|
SettingsAndHelperFunctions.WindowClosed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering {
|
namespace Advanced_Software_Engineering {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This class is resposible for the command help window. The command help window shows help for the commands.
|
/// This class is resposible for the command help window. The command help window shows help for the commands.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class CommandHelp : Form {
|
public partial class CommandHelp : Form {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initilize CommandHelp.
|
/// Initilize CommandHelp.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -12,4 +14,4 @@ namespace Advanced_Software_Engineering {
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-1
@@ -1,10 +1,12 @@
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering {
|
namespace Advanced_Software_Engineering {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This form is reponsible for showing details. It is essentially a textbox in a form.
|
/// This form is reponsible for showing details. It is essentially a textbox in a form.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class DetailsWindow : Form {
|
public partial class DetailsWindow : Form {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A details window dedicated to showing details.
|
/// A details window dedicated to showing details.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -25,4 +27,4 @@ namespace Advanced_Software_Engineering {
|
|||||||
Text = title;
|
Text = title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+10
-22
@@ -1,21 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering
|
namespace Advanced_Software_Engineering {
|
||||||
{
|
|
||||||
public partial class Draw_Preview : Form
|
|
||||||
{
|
|
||||||
|
|
||||||
Graphics graphics;
|
public partial class Draw_Preview : Form {
|
||||||
Commander commander;
|
private Graphics graphics;
|
||||||
bool pardonCommands;
|
private Commander commander;
|
||||||
|
private bool pardonCommands;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The draw preview window. Spawns the basic DrawPreview.
|
/// The draw preview window. Spawns the basic DrawPreview.
|
||||||
@@ -23,8 +15,7 @@ namespace Advanced_Software_Engineering
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This window is responsible for showing what has been drawn.
|
/// This window is responsible for showing what has been drawn.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public Draw_Preview()
|
public Draw_Preview() {
|
||||||
{
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
SettingsAndHelperFunctions.NumberOfWindows++;
|
SettingsAndHelperFunctions.NumberOfWindows++;
|
||||||
graphics = panel1.CreateGraphics();
|
graphics = panel1.CreateGraphics();
|
||||||
@@ -51,8 +42,7 @@ namespace Advanced_Software_Engineering
|
|||||||
button1.Enabled = false;
|
button1.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawPreview_FormClosed(object sender, FormClosedEventArgs e)
|
private void DrawPreview_FormClosed(object sender, FormClosedEventArgs e) {
|
||||||
{
|
|
||||||
SettingsAndHelperFunctions.WindowClosed();
|
SettingsAndHelperFunctions.WindowClosed();
|
||||||
Dispose();
|
Dispose();
|
||||||
}
|
}
|
||||||
@@ -61,14 +51,12 @@ namespace Advanced_Software_Engineering
|
|||||||
DrawPreviewPane_Paint(sender, null);
|
DrawPreviewPane_Paint(sender, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawPreviewPane_Paint(object sender, PaintEventArgs e)
|
private void DrawPreviewPane_Paint(object sender, PaintEventArgs e) {
|
||||||
{
|
|
||||||
graphics = panel1.CreateGraphics();
|
graphics = panel1.CreateGraphics();
|
||||||
commander.DrawAllCommands(graphics);
|
commander.DrawAllCommands(graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SubmitCommand(object sender, EventArgs e)
|
private void SubmitCommand(object sender, EventArgs e) {
|
||||||
{
|
|
||||||
commander.ProcessCommandsAndExecute(textBox1.Text, pardonCommands);
|
commander.ProcessCommandsAndExecute(textBox1.Text, pardonCommands);
|
||||||
textBox1.Text = "";
|
textBox1.Text = "";
|
||||||
}
|
}
|
||||||
@@ -124,4 +112,4 @@ namespace Advanced_Software_Engineering
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,27 +1,26 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering {
|
namespace Advanced_Software_Engineering {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The error window that can show errors, warnings and messages.
|
/// The error window that can show errors, warnings and messages.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ErrorWindow : Form {
|
public partial class ErrorWindow : Form {
|
||||||
string desc;
|
private string desc;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The error message type.
|
/// The error message type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int ERROR_MESSAGE = 0;
|
public const int ERROR_MESSAGE = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The warning message type
|
/// The warning message type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int WARNING_MESSAGE = 1;
|
public const int WARNING_MESSAGE = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The info message type
|
/// The info message type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -67,7 +66,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
SetPicture(type);
|
SetPicture(type);
|
||||||
|
|
||||||
Focus();
|
Focus();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -78,7 +76,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
pictureBox1.Image = IMAGEDIR[type];
|
pictureBox1.Image = IMAGEDIR[type];
|
||||||
pictureBox1.Refresh();
|
pictureBox1.Refresh();
|
||||||
|
|
||||||
switch(type) {
|
switch (type) {
|
||||||
case ERROR_MESSAGE:
|
case ERROR_MESSAGE:
|
||||||
groupBox1.Text = "Error";
|
groupBox1.Text = "Error";
|
||||||
break;
|
break;
|
||||||
@@ -112,7 +110,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ErrorWindow_Load(object sender, EventArgs e) {
|
private void ErrorWindow_Load(object sender, EventArgs e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,53 +1,40 @@
|
|||||||
using System;
|
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;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering
|
namespace Advanced_Software_Engineering {
|
||||||
{
|
|
||||||
public partial class Menu : Form
|
public partial class Menu : Form {
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This creates the main menu window you see when launching the program.
|
/// This creates the main menu window you see when launching the program.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This program window is only meant to show at launch and when all of the other windows are closed. It launches all windows independently of each other, so a theoretically unlimited number of windows can exist.
|
/// This program window is only meant to show at launch and when all of the other windows are closed. It launches all windows independently of each other, so a theoretically unlimited number of windows can exist.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public Menu()
|
public Menu() {
|
||||||
{
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void button1_Click(object sender, EventArgs e)
|
private void button1_Click(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 button2_Click(object sender, EventArgs e) {
|
||||||
{
|
|
||||||
new Text_Editor().Show();
|
new Text_Editor().Show();
|
||||||
this.Hide();
|
this.Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void button3_Click(object sender, EventArgs e)
|
private void button3_Click(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 button4_Click(object sender, EventArgs e) {
|
||||||
{
|
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Menu_Load(object sender, EventArgs e)
|
private void Menu_Load(object sender, EventArgs e) {
|
||||||
{
|
|
||||||
//Do things on load
|
//Do things on load
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,4 +42,4 @@ namespace Advanced_Software_Engineering
|
|||||||
new ErrorWindow().Show();
|
new ErrorWindow().Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Diagnostics.Eventing.Reader;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering {
|
namespace Advanced_Software_Engineering {
|
||||||
public partial class Text_Editor : Form {
|
|
||||||
const string DefaultTitleString = "ASE - Text Editor";
|
|
||||||
|
|
||||||
Draw_Preview DisplayForm = null;
|
public partial class Text_Editor : Form {
|
||||||
bool unsavedChanges = false;
|
private const string DefaultTitleString = "ASE - Text Editor";
|
||||||
bool newWindow = true;
|
|
||||||
bool okToOverwrite = false;
|
private Draw_Preview DisplayForm = null;
|
||||||
string fileName = "";
|
private bool unsavedChanges = false;
|
||||||
|
private bool newWindow = true;
|
||||||
|
private bool okToOverwrite = false;
|
||||||
|
private string fileName = "";
|
||||||
|
|
||||||
/// <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.
|
||||||
@@ -46,12 +39,12 @@ namespace Advanced_Software_Engineering {
|
|||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateTitle(string fileName) {
|
private void UpdateTitle(string fileName) {
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
UpdateTitle();
|
UpdateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateTitle() {
|
private void UpdateTitle() {
|
||||||
if (fileName != "") this.Text = DefaultTitleString + " - " + fileName;
|
if (fileName != "") this.Text = DefaultTitleString + " - " + fileName;
|
||||||
else this.Text = DefaultTitleString;
|
else this.Text = DefaultTitleString;
|
||||||
if (unsavedChanges) this.Text = "* " + this.Text + " *";
|
if (unsavedChanges) this.Text = "* " + this.Text + " *";
|
||||||
@@ -126,11 +119,9 @@ namespace Advanced_Software_Engineering {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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();
|
textBox1.Text = fileStream.ReadToEnd();
|
||||||
@@ -141,7 +132,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
} else new Text_Editor(openFileDialog).Show();
|
} else new Text_Editor(openFileDialog).Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunCode() {
|
private void RunCode() {
|
||||||
@@ -202,7 +192,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
|
|
||||||
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 Text_Editor().Show();
|
||||||
|
|
||||||
private void handleKeypress(object sender, EventArgs e) => handleKeypress();
|
private void handleKeypress(object sender, EventArgs e) => handleKeypress();
|
||||||
@@ -210,12 +199,15 @@ namespace Advanced_Software_Engineering {
|
|||||||
private void textBox1_Click(object sender, EventArgs e) => updateRowCol();
|
private void textBox1_Click(object sender, EventArgs e) => updateRowCol();
|
||||||
|
|
||||||
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();
|
||||||
@@ -260,8 +252,5 @@ namespace Advanced_Software_Engineering {
|
|||||||
private void textBox1_KeyUp(object sender, KeyEventArgs e) => updateRowCol();
|
private void textBox1_KeyUp(object sender, KeyEventArgs e) => updateRowCol();
|
||||||
|
|
||||||
private void helpToolStripMenuItem1_Click(object sender, EventArgs e) => new CommandHelp().Show();
|
private void helpToolStripMenuItem1_Click(object sender, EventArgs e) => new CommandHelp().Show();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user