diff --git a/Advanced Software Engineering/Advanced Software Engineering/Drawer.cs b/Advanced Software Engineering/Advanced Software Engineering/Drawer.cs index 0dfc806..fe6370b 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Drawer.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Drawer.cs @@ -27,7 +27,7 @@ namespace Advanced_Software_Engineering { /// /// The Brush object /// - protected Brush brush; + protected SolidBrush brush; /// /// The Pen object /// @@ -87,11 +87,11 @@ namespace Advanced_Software_Engineering { /// /// Allows the filling of objects. /// - public void EnableFill() => fill = false; + public void EnableFill() => fill = true; /// /// Disables the filling of objects. /// - public void DisableFill() => fill = true; + public void DisableFill() => fill = false; /// /// Set the filling of objects /// @@ -113,7 +113,7 @@ namespace Advanced_Software_Engineering { /// Set fill color /// /// Fill color - public void SetFillColor(Color color) => ((SolidBrush)brush).Color = color; + public void SetFillColor(Color color) => 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. @@ -129,18 +129,17 @@ namespace Advanced_Software_Engineering { /// /// 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"); } GraphicsPath path = new GraphicsPath(); + path.FillMode = FillMode.Winding; - for (int i = 1; i < points.Length; i++) { - path.AddLine(points[i - 1], points[i]); - } - - path.AddLine(points[0], points.Last()); - + path.AddLines(points); + path.AddLine(points[0], points.Last()); //Add final line + DrawLines(path); } @@ -159,6 +158,7 @@ namespace Advanced_Software_Engineering { /// /// Scale of the circle public void DrawCircle(double scale) { + if (fill) graphics.FillEllipse(brush, penPosition.X - (float)(scale), penPosition.Y - (float)(scale), (float)scale * 2, (float)scale * 2); graphics.DrawEllipse(pen, penPosition.X - (float)(scale), penPosition.Y - (float)(scale), (float)scale * 2, (float)scale * 2); }