Private
Public Access
CodeMaid Cleanup for main project
This commit is contained in:
1 parent
08f0a0f998
commit
31aea2831f
30 files changed
+136
-271
No files matched your search
@@ -1,19 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
|
||||
namespace Advanced_Software_Engineering {
|
||||
|
||||
/// <summary>
|
||||
/// The commander class takes care of commands. It also takes control of the drawer.
|
||||
/// </summary>
|
||||
public class Commander {
|
||||
|
||||
Graphics graphics;
|
||||
List<Verb> commands = new List<Verb>();
|
||||
Drawer drawer;
|
||||
bool commands_ok = true;
|
||||
private Graphics graphics;
|
||||
private List<Verb> commands = new List<Verb>();
|
||||
private Drawer drawer;
|
||||
private bool commands_ok = true;
|
||||
|
||||
/// <summary>
|
||||
/// This command updates the graphics element (usually) when the page repaints.
|
||||
@@ -58,6 +56,7 @@ namespace Advanced_Software_Engineering {
|
||||
this.ProcessCommands(rawCommands);
|
||||
drawer.ResetDrawer();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a verb to the command list to be executed.
|
||||
/// </summary>
|
||||
@@ -112,7 +111,6 @@ namespace Advanced_Software_Engineering {
|
||||
foreach (Verb verb in this.commands) {
|
||||
Console.WriteLine(verb.GetDescription());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -157,5 +155,4 @@ namespace Advanced_Software_Engineering {
|
||||
return commands_ok;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +1,25 @@
|
||||
using System;
|
||||
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 {
|
||||
|
||||
/// <summary>
|
||||
/// The drawer is responsible for drawing on the graphics object.
|
||||
/// </summary>
|
||||
public class Drawer {
|
||||
|
||||
/// <summary>
|
||||
/// The starting color of the pen / brush
|
||||
/// </summary>
|
||||
protected static Color defaultColor = Color.Black;
|
||||
|
||||
/// <summary>
|
||||
/// The deafult width of the pen
|
||||
/// </summary>
|
||||
protected static float defaultWidth = 1f;
|
||||
|
||||
/// <summary>
|
||||
/// Weather enclosed spaces will have fill.
|
||||
/// </summary>
|
||||
@@ -28,6 +29,7 @@ namespace Advanced_Software_Engineering {
|
||||
/// The Brush object
|
||||
/// </summary>
|
||||
protected SolidBrush brush;
|
||||
|
||||
/// <summary>
|
||||
/// The Pen object
|
||||
/// </summary>
|
||||
@@ -37,6 +39,7 @@ namespace Advanced_Software_Engineering {
|
||||
/// The current position of the pen.
|
||||
/// </summary>
|
||||
protected Point penPosition;
|
||||
|
||||
/// <summary>
|
||||
/// The graphics object
|
||||
/// </summary>
|
||||
@@ -73,6 +76,7 @@ namespace Advanced_Software_Engineering {
|
||||
/// </summary>
|
||||
/// <param name="point">Position to move the pen to</param>
|
||||
public void MovePen(Point point) => penPosition = point;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current pen position
|
||||
/// </summary>
|
||||
@@ -84,14 +88,17 @@ namespace Advanced_Software_Engineering {
|
||||
/// </summary>
|
||||
/// <returns>current fill satus</returns>
|
||||
public bool GetFill() => fill;
|
||||
|
||||
/// <summary>
|
||||
/// Allows the filling of objects.
|
||||
/// </summary>
|
||||
public void EnableFill() => fill = true;
|
||||
|
||||
/// <summary>
|
||||
/// Disables the filling of objects.
|
||||
/// </summary>
|
||||
public void DisableFill() => fill = false;
|
||||
|
||||
/// <summary>
|
||||
/// Set the filling of objects
|
||||
/// </summary>
|
||||
@@ -103,6 +110,7 @@ namespace Advanced_Software_Engineering {
|
||||
/// </summary>
|
||||
/// <param name="color">Pen color</param>
|
||||
public void SetPenColor(Color color) => pen.Color = color;
|
||||
|
||||
/// <summary>
|
||||
/// Set the width of the pen
|
||||
/// </summary>
|
||||
@@ -129,7 +137,6 @@ namespace Advanced_Software_Engineering {
|
||||
/// </summary>
|
||||
/// <param name="points">Points to draw to</param>
|
||||
public void DrawLines(Point[] points) {
|
||||
|
||||
if (points.Length < 2) {
|
||||
throw new Exception("Cannot have less than two points in a line");
|
||||
}
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Advanced_Software_Engineering
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
namespace Advanced_Software_Engineering {
|
||||
|
||||
internal static class Program {
|
||||
public static Form MainMenu;
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
private static void Main() {
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
|
||||
+4
-6
@@ -1,14 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Security.Policy;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Advanced_Software_Engineering {
|
||||
|
||||
/// <summary>
|
||||
/// This class simply provides settings and some functions that are used across many components.
|
||||
/// </summary>
|
||||
public class SettingsAndHelperFunctions {
|
||||
|
||||
/// <summary>
|
||||
/// The variable simply keep track of the windows that are currently shown (excluding <see cref="MainMenu"/>).
|
||||
/// </summary>
|
||||
@@ -23,8 +22,8 @@ namespace Advanced_Software_Engineering {
|
||||
System.Console.WriteLine("Showing MainMenu");
|
||||
Program.MainMenu.Show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function removes spaces from the start and the end of the text. This should be unit tested.
|
||||
/// </summary>
|
||||
@@ -71,7 +70,6 @@ namespace Advanced_Software_Engineering {
|
||||
//Console.WriteLine("Result: " + result);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+3
-8
@@ -1,16 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
/// <summary>
|
||||
/// Circle Verb class.
|
||||
/// </summary>
|
||||
public class Circle : Verb {
|
||||
Drawer drawer;
|
||||
double scale;
|
||||
private Drawer drawer;
|
||||
private double scale;
|
||||
|
||||
/// <summary>
|
||||
/// Circle constructor creates the Circle verb.
|
||||
|
||||
+2
-8
@@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
/// <summary>
|
||||
/// The Clear Verb class.
|
||||
/// </summary>
|
||||
public class Clear : Verb {
|
||||
Drawer drawer;
|
||||
private Drawer drawer;
|
||||
|
||||
/// <summary>
|
||||
/// Create the clear Verb
|
||||
@@ -31,6 +26,5 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
public string GetDescription() {
|
||||
return "Clears the canvas";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+2
-7
@@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
/// <summary>
|
||||
/// The Dot Verb class
|
||||
/// </summary>
|
||||
public class Dot : Verb {
|
||||
Drawer drawer;
|
||||
private Drawer drawer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates the Dot Verb
|
||||
|
||||
+6
-10
@@ -1,20 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
/// <summary>
|
||||
/// DrawLines Verb class
|
||||
/// </summary>
|
||||
public class DrawLines : Verb {
|
||||
Drawer drawer;
|
||||
Point[] points;
|
||||
private Drawer drawer;
|
||||
private Point[] points;
|
||||
|
||||
bool descCreated = false;
|
||||
string desc;
|
||||
private bool descCreated = false;
|
||||
private string desc;
|
||||
|
||||
/// <summary>
|
||||
/// DrawLines constructor
|
||||
|
||||
+4
-9
@@ -1,18 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
/// <summary>
|
||||
/// DrawTo Verb class
|
||||
/// </summary>
|
||||
public class DrawTo : Verb {
|
||||
|
||||
Drawer drawer;
|
||||
Point moveToPoint;
|
||||
private Drawer drawer;
|
||||
private Point moveToPoint;
|
||||
|
||||
/// <summary>
|
||||
/// Creates the DrawTo intstance
|
||||
|
||||
+3
-8
@@ -1,16 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
/// <summary>
|
||||
/// Fill Verb class
|
||||
/// </summary>
|
||||
public class Fill : Verb {
|
||||
Drawer drawer;
|
||||
bool enable;
|
||||
private Drawer drawer;
|
||||
private bool enable;
|
||||
|
||||
/// <summary>
|
||||
/// Fill enables or disables the fill insider drawer
|
||||
|
||||
+4
-11
@@ -1,19 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
/// <summary>
|
||||
/// The FillColor Verb class
|
||||
/// </summary>
|
||||
public class FillColor : Verb {
|
||||
|
||||
Drawer drawer;
|
||||
Color color;
|
||||
private Drawer drawer;
|
||||
private Color color;
|
||||
|
||||
/// <summary>
|
||||
/// Create the FillColor instance
|
||||
@@ -39,6 +33,5 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
public string GetDescription() {
|
||||
return "Set fill color to: " + color.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+4
-10
@@ -1,18 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
/// <summary>
|
||||
/// MoveTo Verb class
|
||||
/// </summary>
|
||||
public class MoveTo : Verb {
|
||||
|
||||
Drawer drawer;
|
||||
Point moveToPoint;
|
||||
private Drawer drawer;
|
||||
private Point moveToPoint;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a MoveTo instance
|
||||
@@ -49,6 +44,5 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
public string GetDescription() {
|
||||
return "Move origin to " + moveToPoint.X + ", " + moveToPoint.Y;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+4
-9
@@ -1,18 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
/// <summary>
|
||||
/// The PenColor Verb class
|
||||
/// </summary>
|
||||
public class PenColor : Verb {
|
||||
|
||||
Drawer drawer;
|
||||
Color color;
|
||||
private Drawer drawer;
|
||||
private Color color;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a PenColor instance
|
||||
|
||||
+3
-7
@@ -1,16 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
/// <summary>
|
||||
/// The Quadrilateral Verb class
|
||||
/// </summary>
|
||||
public class Quadrilateral : Verb {
|
||||
Verb verb;
|
||||
private Verb verb;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Quadrilateral instances
|
||||
|
||||
+5
-10
@@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
/// <summary>
|
||||
/// Rectangle Verb class
|
||||
/// </summary>
|
||||
@@ -14,11 +11,11 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
/// Correct
|
||||
/// </todo>
|
||||
public class Rectangle : Verb {
|
||||
Drawer drawer;
|
||||
PointF[] points;
|
||||
private Drawer drawer;
|
||||
private PointF[] points;
|
||||
|
||||
double width;
|
||||
double height;
|
||||
private double width;
|
||||
private double height;
|
||||
|
||||
/// <summary>
|
||||
/// Create a rectangle instance. Makes sure that
|
||||
@@ -43,7 +40,6 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description from the rectangle
|
||||
/// </summary>
|
||||
@@ -67,6 +63,5 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
drawer.DrawLines(morePoints.ToArray());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+6
-8
@@ -1,20 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
/// <summary>
|
||||
/// A class that generates a RegularPolygon verb.
|
||||
/// </summary>
|
||||
public class RegularPolygon : Verb {
|
||||
Drawer drawer;
|
||||
int sides;
|
||||
double scale;
|
||||
double offset;
|
||||
List<Point> points;
|
||||
private Drawer drawer;
|
||||
private int sides;
|
||||
private double scale;
|
||||
private double offset;
|
||||
private List<Point> points;
|
||||
|
||||
/// <summary>
|
||||
/// Draws a regular polygon.
|
||||
|
||||
+2
-8
@@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
/// <summary>
|
||||
/// Setsets the pen to the initial position.
|
||||
/// </summary>
|
||||
public class ResetPen : Verb {
|
||||
Drawer drawer;
|
||||
private Drawer drawer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates the ResetPen verb
|
||||
@@ -31,6 +26,5 @@ namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
public string GetDescription() {
|
||||
return "Moves pen to the start (0, 0)";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+2
-7
@@ -1,16 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
/// <summary>
|
||||
/// The Square Verb class
|
||||
/// </summary>
|
||||
public class Square : Verb {
|
||||
private Verb verb;
|
||||
|
||||
Verb verb;
|
||||
/// <summary>
|
||||
/// A new Squre instance. Draws squares using <see cref="RegularPolygon"/>
|
||||
/// </summary>
|
||||
|
||||
+3
-7
@@ -1,16 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs {
|
||||
|
||||
/// <summary>
|
||||
/// The Triangle Verb class
|
||||
/// </summary>
|
||||
public class Triangle : Verb {
|
||||
Verb verb;
|
||||
private Verb verb;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Triangle instance using <see cref="RegularPolygon"/>.
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Advanced_Software_Engineering.Verbs {
|
||||
|
||||
/// <summary>
|
||||
/// This class contains a large amount of useful conversions
|
||||
/// </summary>
|
||||
public class ValueHelper {
|
||||
|
||||
/// <summary>
|
||||
/// Converts string to int (if possible)
|
||||
/// </summary>
|
||||
@@ -74,7 +72,6 @@ namespace Advanced_Software_Engineering.Verbs {
|
||||
if (text.StartsWith("#"))
|
||||
text = text.Substring(1);
|
||||
|
||||
|
||||
switch (text.Length) {
|
||||
case 6:
|
||||
return Color.FromArgb(
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace Advanced_Software_Engineering {
|
||||
|
||||
namespace Advanced_Software_Engineering {
|
||||
/// <summary>
|
||||
/// Verb is an interface for executing and getting the descriptions of Verbs. Some Verbs draw lines, some verbs will assign
|
||||
/// </summary>
|
||||
public interface Verb {
|
||||
|
||||
/// <summary>
|
||||
/// This executes the verb to the drawer inside it.
|
||||
/// </summary>
|
||||
void ExecuteVerb();
|
||||
|
||||
/// <summary>
|
||||
/// The description of what the Verb will do.
|
||||
/// </summary>
|
||||
|
||||
@@ -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.DrawingVerbs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Advanced_Software_Engineering {
|
||||
|
||||
/// <summary>
|
||||
/// This class is responsible for creating Verbs.
|
||||
/// </summary>
|
||||
public class VerbFactory {
|
||||
|
||||
/// <summary>
|
||||
/// This function returns a Verb from a command and drawer.
|
||||
/// </summary>
|
||||
@@ -23,7 +21,6 @@ namespace Advanced_Software_Engineering {
|
||||
/// <param name="fullCommand">The command as a string</param>
|
||||
/// <returns>A verb that maches the command</returns>
|
||||
public static Verb MakeVerb(Drawer drawer, string fullCommand) {
|
||||
|
||||
Dictionary<string, string[]> commandAndParameters = SettingsAndHelperFunctions.CommandAndParameterParser(fullCommand);
|
||||
|
||||
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,
|
||||
ValueHelper.ConvertToInt(parameters[0]),
|
||||
ValueHelper.ConvertToInt(parameters[1]));
|
||||
|
||||
} else throw new Exception(command + " has an incorrect number of parameters");
|
||||
|
||||
case "drawto":
|
||||
@@ -142,7 +138,6 @@ namespace Advanced_Software_Engineering {
|
||||
return new Dot(drawer);
|
||||
} else throw new Exception(command + " doesn't take parameters");
|
||||
|
||||
|
||||
case "clear":
|
||||
if (parameterLength == 0) {
|
||||
return new Clear(drawer);
|
||||
@@ -210,7 +205,6 @@ namespace Advanced_Software_Engineering {
|
||||
default:
|
||||
throw new Exception("Unknown command");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,13 @@
|
||||
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 {
|
||||
|
||||
public partial class About_Window : Form {
|
||||
|
||||
namespace Advanced_Software_Engineering
|
||||
{
|
||||
public partial class About_Window : Form
|
||||
{
|
||||
///<summary>
|
||||
///Creates an About Window which shows details about the program.
|
||||
///</summary>
|
||||
public About_Window()
|
||||
{
|
||||
public About_Window() {
|
||||
InitializeComponent();
|
||||
SettingsAndHelperFunctions.NumberOfWindows++;
|
||||
}
|
||||
@@ -26,8 +17,7 @@ namespace Advanced_Software_Engineering
|
||||
/// </summary>
|
||||
/// <param name="sender"></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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Advanced_Software_Engineering {
|
||||
|
||||
/// <summary>
|
||||
/// This class is resposible for the command help window. The command help window shows help for the commands.
|
||||
/// </summary>
|
||||
public partial class CommandHelp : Form {
|
||||
|
||||
/// <summary>
|
||||
/// Initilize CommandHelp.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Advanced_Software_Engineering {
|
||||
|
||||
/// <summary>
|
||||
/// This form is reponsible for showing details. It is essentially a textbox in a form.
|
||||
/// </summary>
|
||||
public partial class DetailsWindow : Form {
|
||||
|
||||
/// <summary>
|
||||
/// A details window dedicated to showing details.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,21 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Advanced_Software_Engineering
|
||||
{
|
||||
public partial class Draw_Preview : Form
|
||||
{
|
||||
namespace Advanced_Software_Engineering {
|
||||
|
||||
Graphics graphics;
|
||||
Commander commander;
|
||||
bool pardonCommands;
|
||||
public partial class Draw_Preview : Form {
|
||||
private Graphics graphics;
|
||||
private Commander commander;
|
||||
private bool pardonCommands;
|
||||
|
||||
/// <summary>
|
||||
/// The draw preview window. Spawns the basic DrawPreview.
|
||||
@@ -23,8 +15,7 @@ namespace Advanced_Software_Engineering
|
||||
/// <remarks>
|
||||
/// This window is responsible for showing what has been drawn.
|
||||
/// </remarks>
|
||||
public Draw_Preview()
|
||||
{
|
||||
public Draw_Preview() {
|
||||
InitializeComponent();
|
||||
SettingsAndHelperFunctions.NumberOfWindows++;
|
||||
graphics = panel1.CreateGraphics();
|
||||
@@ -51,8 +42,7 @@ namespace Advanced_Software_Engineering
|
||||
button1.Enabled = false;
|
||||
}
|
||||
|
||||
private void DrawPreview_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
private void DrawPreview_FormClosed(object sender, FormClosedEventArgs e) {
|
||||
SettingsAndHelperFunctions.WindowClosed();
|
||||
Dispose();
|
||||
}
|
||||
@@ -61,14 +51,12 @@ namespace Advanced_Software_Engineering
|
||||
DrawPreviewPane_Paint(sender, null);
|
||||
}
|
||||
|
||||
private void DrawPreviewPane_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
private void DrawPreviewPane_Paint(object sender, PaintEventArgs e) {
|
||||
graphics = panel1.CreateGraphics();
|
||||
commander.DrawAllCommands(graphics);
|
||||
}
|
||||
|
||||
private void SubmitCommand(object sender, EventArgs e)
|
||||
{
|
||||
private void SubmitCommand(object sender, EventArgs e) {
|
||||
commander.ProcessCommandsAndExecute(textBox1.Text, pardonCommands);
|
||||
textBox1.Text = "";
|
||||
}
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Advanced_Software_Engineering {
|
||||
|
||||
/// <summary>
|
||||
/// The error window that can show errors, warnings and messages.
|
||||
/// </summary>
|
||||
public partial class ErrorWindow : Form {
|
||||
string desc;
|
||||
private string desc;
|
||||
|
||||
/// <summary>
|
||||
/// The error message type.
|
||||
/// </summary>
|
||||
public const int ERROR_MESSAGE = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The warning message type
|
||||
/// </summary>
|
||||
public const int WARNING_MESSAGE = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The info message type
|
||||
/// </summary>
|
||||
@@ -67,7 +66,6 @@ namespace Advanced_Software_Engineering {
|
||||
SetPicture(type);
|
||||
|
||||
Focus();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -112,7 +110,6 @@ namespace Advanced_Software_Engineering {
|
||||
}
|
||||
|
||||
private void ErrorWindow_Load(object sender, EventArgs e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Advanced_Software_Engineering
|
||||
{
|
||||
public partial class Menu : Form
|
||||
{
|
||||
namespace Advanced_Software_Engineering {
|
||||
|
||||
public partial class Menu : Form {
|
||||
|
||||
/// <summary>
|
||||
/// This creates the main menu window you see when launching the program.
|
||||
/// </summary>
|
||||
/// <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.
|
||||
/// </remarks>
|
||||
public Menu()
|
||||
{
|
||||
public Menu() {
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
private void button1_Click(object sender, EventArgs e) {
|
||||
new Draw_Preview().Show();
|
||||
this.Hide();
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
private void button2_Click(object sender, EventArgs e) {
|
||||
new Text_Editor().Show();
|
||||
this.Hide();
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
private void button3_Click(object sender, EventArgs e) {
|
||||
new About_Window().Show();
|
||||
this.Hide();
|
||||
}
|
||||
|
||||
private void button4_Click(object sender, EventArgs e)
|
||||
{
|
||||
private void button4_Click(object sender, EventArgs e) {
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void Menu_Load(object sender, EventArgs e)
|
||||
{
|
||||
private void Menu_Load(object sender, EventArgs e) {
|
||||
//Do things on load
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
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.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Advanced_Software_Engineering {
|
||||
public partial class Text_Editor : Form {
|
||||
const string DefaultTitleString = "ASE - Text Editor";
|
||||
|
||||
Draw_Preview DisplayForm = null;
|
||||
bool unsavedChanges = false;
|
||||
bool newWindow = true;
|
||||
bool okToOverwrite = false;
|
||||
string fileName = "";
|
||||
public partial class Text_Editor : Form {
|
||||
private const string DefaultTitleString = "ASE - Text Editor";
|
||||
|
||||
private Draw_Preview DisplayForm = null;
|
||||
private bool unsavedChanges = false;
|
||||
private bool newWindow = true;
|
||||
private bool okToOverwrite = false;
|
||||
private string fileName = "";
|
||||
|
||||
/// <summary>
|
||||
/// 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();
|
||||
}
|
||||
|
||||
void UpdateTitle(string fileName) {
|
||||
private void UpdateTitle(string fileName) {
|
||||
this.fileName = fileName;
|
||||
UpdateTitle();
|
||||
}
|
||||
|
||||
void UpdateTitle() {
|
||||
private void UpdateTitle() {
|
||||
if (fileName != "") this.Text = DefaultTitleString + " - " + fileName;
|
||||
else this.Text = DefaultTitleString;
|
||||
if (unsavedChanges) this.Text = "* " + this.Text + " *";
|
||||
@@ -126,11 +119,9 @@ namespace Advanced_Software_Engineering {
|
||||
}
|
||||
|
||||
private void openFile() {
|
||||
|
||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK) {
|
||||
|
||||
if (newWindow) {
|
||||
StreamReader fileStream = new StreamReader(openFileDialog.OpenFile());
|
||||
textBox1.Text = fileStream.ReadToEnd();
|
||||
@@ -141,7 +132,6 @@ namespace Advanced_Software_Engineering {
|
||||
fileStream.Close();
|
||||
} else new Text_Editor(openFileDialog).Show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void RunCode() {
|
||||
@@ -202,7 +192,6 @@ namespace Advanced_Software_Engineering {
|
||||
|
||||
private void runToolStripMenuItem_Click(object sender, EventArgs e) => RunCode();
|
||||
|
||||
|
||||
private void createNewInstance() => new Text_Editor().Show();
|
||||
|
||||
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 saveAsToolStripMenuItem_Click(object sender, EventArgs e) => saveFileAs();
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e) => saveFile();
|
||||
|
||||
private void newFileToolStripMenuItem_Click(object sender, EventArgs e) => createNewInstance();
|
||||
|
||||
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 exitToolStripMenuItem_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
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 helpToolStripMenuItem1_Click(object sender, EventArgs e) => new CommandHelp().Show();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user