diff --git a/Advanced Software Engineering/Advanced Software Engineering/Drawer.cs b/Advanced Software Engineering/Advanced Software Engineering/Drawer.cs
index f9f71d8..0dfc806 100644
--- a/Advanced Software Engineering/Advanced Software Engineering/Drawer.cs
+++ b/Advanced Software Engineering/Advanced Software Engineering/Drawer.cs
@@ -7,51 +7,127 @@ using System.Text;
using System.Threading.Tasks;
namespace Advanced_Software_Engineering {
+ ///
+ /// The drawer is responsible for drawing on the graphics object.
+ ///
public class Drawer {
+ ///
+ /// The starting color of the pen / brush
+ ///
protected static Color defaultColor = Color.Black;
+ ///
+ /// The deafult width of the pen
+ ///
protected static float defaultWidth = 1f;
+ ///
+ /// Weather enclosed spaces will have fill.
+ ///
protected bool fill = false;
-
+ ///
+ /// The Brush object
+ ///
protected Brush brush;
+ ///
+ /// The Pen object
+ ///
protected Pen pen;
-
+ ///
+ /// The current position of the pen.
+ ///
protected Point penPosition;
+ ///
+ /// The graphics object
+ ///
protected Graphics graphics;
+ ///
+ /// Creates a new drawer object.
+ ///
+ /// Graphics context
public Drawer(Graphics graphics) {
this.graphics = graphics;
ResetDrawer();
}
+ ///
+ /// Restart the drawer.
+ ///
public void ResetDrawer() {
graphics.Clear(Color.White);
penPosition = new Point(0, 0);
pen = new Pen(defaultColor, defaultWidth);
brush = new SolidBrush(defaultColor);
+ fill = false;
}
+ ///
+ /// Set thhe graphics context.
+ ///
+ ///
public void SetGraphics(Graphics graphics) => this.graphics = graphics;
+ ///
+ /// Move the pen to the point.
+ ///
+ /// Position to move the pen to
public void MovePen(Point point) => penPosition = point;
+ ///
+ /// Returns the current pen position
+ ///
+ /// The curren pen position
public Point GetPenPosition() => new Point(penPosition.X, penPosition.Y);
+ ///
+ /// Get current fill status
+ ///
+ /// current fill satus
public bool GetFill() => fill;
+ ///
+ /// Allows the filling of objects.
+ ///
public void EnableFill() => fill = false;
+ ///
+ /// Disables the filling of objects.
+ ///
public void DisableFill() => fill = true;
- public void SetFill(bool down) => fill = down;
+ ///
+ /// Set the filling of objects
+ ///
+ /// Set fill
+ public void SetFill(bool fill) => this.fill = fill;
+ ///
+ /// Set the pen color
+ ///
+ /// Pen color
public void SetPenColor(Color color) => pen.Color = color;
+ ///
+ /// Set the width of the pen
+ ///
+ /// Pen width
public void SetPenWidth(float width) => pen.Width = width;
+ ///
+ /// Set fill color
+ ///
+ /// Fill color
public void SetFillColor(Color color) => ((SolidBrush)brush).Color = color;
+ ///
+ /// Draws a line from the current pen position to the one specified in the parameter. This also sets the pens new position.
+ ///
+ /// Draw to point
public void DrawLine(Point point) {
graphics.DrawLine(pen, penPosition, point);
penPosition = point;
}
+ ///
+ /// Draws multiple lines to multiple points. This doesn't change the pens position.
+ ///
+ /// Points to draw to
public void DrawLines(Point[] points) {
if (points.Length < 2) {
throw new Exception("Cannot have less than two points in a line");
@@ -68,21 +144,34 @@ namespace Advanced_Software_Engineering {
DrawLines(path);
}
- //Doesn't move pen
+ ///
+ /// Draws multiple lines to multiple points. This doesn't change the pens position.
+ ///
+ /// GraphicsPath to draw to
public void DrawLines(GraphicsPath path) {
//path.Widen(pen);
if (fill) graphics.FillPath(brush, path);
graphics.DrawPath(pen, path);
}
+ ///
+ /// Draws a circle of a scale ath the pen's position
+ ///
+ /// Scale of the circle
public void DrawCircle(double scale) {
graphics.DrawEllipse(pen, penPosition.X - (float)(scale), penPosition.Y - (float)(scale), (float)scale * 2, (float)scale * 2);
}
+ ///
+ /// Clears the canvas
+ ///
public void ClearCanvas() {
graphics.Clear(Color.White);
}
+ ///
+ /// Draws a single pixel with the pen's color at the pen's position.
+ ///
public void DrawDot() {
graphics.FillRectangle(new SolidBrush(pen.Color), penPosition.X, penPosition.Y, 1, 1);
}