/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Painter game = new Painter()) { game.Run(); } }
private void Drawing() { var factory = new ShapeFactory(); var designer = new Designer(factory); var wpfCanvas = (System.Windows.Controls.Canvas)FindName("canvas"); var canvas = new Canvas(wpfCanvas); var painter = new Painter.Painter(); Console.WriteLine("Enter commands to draw shapes. Enter 'exit' to see the result"); Console.WriteLine("Usage: RegularPolygon <color> <center> <radius> <vertexCount>"); Console.WriteLine("Usage: Triangle <color> <vertex1> <vertex2> <vertex3>"); Console.WriteLine("Usage: Rectangle <color> <leftTop> <rightBottom>"); Console.WriteLine("Usage: Ellipse <color> <center> <horisontalRadius> <verticalRadius>"); var draft = designer.CreateDraft(Console.In); painter.DrawPicture(draft, canvas); }
public void DrawPicture_WithShapeAndCanvas_ShouldDrawPicture() { var painter = new Painter.Painter(); var pictureDraft = new PictureDraft(); var rectangle = new Rectangle(new Point(150, 150), new Point(10, 300), Color.Blue); var ellipse = new Ellipse(new Point(200, 200), 100, 75, Color.Yellow); var sw = new StringWriter(); var canvas = new TestCanvas(sw); pictureDraft.AddShape(rectangle); pictureDraft.AddShape(ellipse); painter.DrawPicture(pictureDraft, canvas); string expected = "Blue line from (150, 150), to (10, 150)\r\n" + "Blue line from (10, 150), to (10, 300)\r\n" + "Blue line from (10, 300), to (150, 300)\r\n" + "Blue line from (150, 300), to (150, 150)\r\n" + "Yellow ellipse with center: (200, 200); width: 200; height: 150\r\n"; Assert.AreEqual(expected, sw.ToString()); }
static void Main() { using (var painter = new Painter()) painter.Run(); }