Ejemplo n.º 1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Painter game = new Painter())
     {
         game.Run();
     }
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
 static void Main()
 {
     using (var painter = new Painter())
         painter.Run();
 }