Ejemplo n.º 1
0
    public void DoDrawing(Pen pen, PenPosition penPosition, Graphics g, string line)
    {
        var    split = line.Split();
        double rectangleWidth;
        double rectangleHeight;

        try
        {
            var W = split[1];
            var H = split[2];

            if (double.TryParse(W, out rectangleWidth) && double.TryParse(H, out rectangleHeight) && rectangleHeight != rectangleWidth)
            {
                IShape rec = new RectangleShape(rectangleWidth, rectangleHeight);

                float widthF  = Convert.ToSingle(W);
                float heightF = Convert.ToSingle(H);

                g.DrawRectangle(pen, penPosition.X, penPosition.Y, widthF, heightF);
            }
            else
            {
                MessageBox.Show("Height & Width must be not be the same : FORMAT <Shape> <Width> <Height>", "Wrong Paramters", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        catch (Exception)
        {
            MessageBox.Show("Missing Width & Height Parameters : FORMAT <Shape> <Width> <Height>", "Missing Paramters", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
Ejemplo n.º 2
0
        public void DoDrawing(Pen pen, PenPosition penPosition, Graphics g, string line)
        {
            var    split = line.Split();
            string Operator;
            int    repeatSize = 5;


            int.TryParse(split[4], out int AmountOfRepition);
            Operator = split[3];
            double.TryParse(split[2], out double circleRadius);


            IShape circle = new CircleShape(circleRadius);

            double diameter  = circle.GetDiameter();
            float  diameterF = Convert.ToSingle(diameter);

            if (Operator == "+")
            {
                for (int i = 0; i < AmountOfRepition; i++)
                {
                    g.DrawEllipse(pen, penPosition.X, penPosition.Y, diameterF, diameterF);
                    diameterF += repeatSize;
                }
            }
            if (Operator == "-")
            {
                for (int i = 0; i < AmountOfRepition; i++)
                {
                    g.DrawEllipse(pen, penPosition.X, penPosition.Y, diameterF, diameterF);
                    diameterF -= repeatSize;
                }
            }
        }
Ejemplo n.º 3
0
        public PenPosition MovePen(string line, PenPosition penStatus, Pen pen, Graphics G)
        {
            var   splitCommand = line.Split();
            float X            = 0;
            float Y            = 0;

            try
            {
                var penX = int.Parse(splitCommand[1]);
                var penY = int.Parse(splitCommand[2]);

                if (penStatus.Enabled)
                {
                    G.DrawLine(pen, Y, X, penX, penY);
                    X = penX;
                    Y = penY;
                }
                else if (penStatus.Enabled == false)
                {
                    X = penX;
                    Y = penY;
                }


                return(new PenPosition
                {
                    X = penX,
                    Y = penY,
                });
            }
            catch (Exception)
            {
                throw new Exception("Unable to parse X & Y co-ordinates, please try again with two integers!");
            }
        }
Ejemplo n.º 4
0
        public void DoDrawing(Pen pen, PenPosition penPosition, Graphics g, string line)
        {
            var Points = new ShapePoints
            {
                A = new Points
                {
                    X = penPosition.X = 10,
                    Y = penPosition.Y = 10
                },
                B = new Points
                {
                    X = penPosition.X = 90,
                    Y = penPosition.Y = 10
                },
                C = new Points
                {
                    X = penPosition.X = 40,
                    Y = penPosition.Y = 90
                },
                D = new Points
                {
                    X = penPosition.X = 10,
                    Y = penPosition.Y = 90
                },
                E = new Points
                {
                    X = penPosition.X = 10,
                    Y = penPosition.Y = 10
                }
            };

            Point[] points = { new Point(Points.A.X, Points.A.Y), new Point(Points.B.X, Points.B.Y), new Point(Points.C.X, Points.C.Y), new Point(Points.D.X, Points.D.Y), new Point(Points.E.X, Points.E.Y) };
            g.DrawPolygon(pen, points);
        }
Ejemplo n.º 5
0
        public void DoDrawing(Pen pen, PenPosition penPosition, Graphics g, string line)
        {
            var    split = line.Split();
            string Operator;
            var    repeatSize = 5;

            Operator = split[2];
            int.TryParse(split[3], out int AmountOfRepition);

            var Points = new ShapePoints
            {
                A = new Points
                {
                    X = penPosition.X = 10,
                    Y = penPosition.Y = 10
                },
                B = new Points
                {
                    X = penPosition.X = 90,
                    Y = penPosition.Y = 10
                },
                C = new Points
                {
                    X = penPosition.X = 40,
                    Y = penPosition.Y = 90
                },
                D = new Points
                {
                    X = penPosition.X = 10,
                    Y = penPosition.Y = 90
                },
                E = new Points
                {
                    X = penPosition.X = 10,
                    Y = penPosition.Y = 10
                }
            };

            if (Operator == "+")
            {
                for (int i = 0; i < AmountOfRepition; i++)
                {
                    Point[] points = { new Point(Points.A.X += repeatSize, Points.A.Y += repeatSize), new Point(Points.B.X += repeatSize, Points.B.Y += repeatSize), new Point(Points.C.X += repeatSize, Points.C.Y += repeatSize), new Point(Points.D.X += repeatSize, Points.D.Y += repeatSize), new Point(Points.E.X += repeatSize, Points.E.Y += repeatSize) };
                    g.DrawPolygon(pen, points);
                }
            }
            if (Operator == "-")
            {
                for (int i = 0; i < AmountOfRepition; i++)
                {
                    Point[] points = { new Point(Points.A.X -= repeatSize, Points.A.Y -= repeatSize), new Point(Points.B.X -= repeatSize, Points.B.Y -= repeatSize), new Point(Points.C.X -= repeatSize, Points.C.Y -= repeatSize), new Point(Points.D.X -= repeatSize, Points.D.Y -= repeatSize), new Point(Points.E.X -= repeatSize, Points.E.Y -= repeatSize) };
                    g.DrawPolygon(pen, points);
                }
            }
        }
Ejemplo n.º 6
0
    public void DoDrawing(Pen pen, PenPosition penPosition, Graphics g, string line)
    {
        var    split = line.Split();
        double rectangleWidth;
        double rectangleHeight;

        var W = split[1];
        var H = split[2];

        if (double.TryParse(W, out rectangleWidth) && double.TryParse(H, out rectangleHeight))
        {
            IShape rec = new RectangleShape(rectangleWidth, rectangleHeight);

            float widthF  = Convert.ToSingle(W);
            float heightF = Convert.ToSingle(H);

            g.DrawRectangle(pen, penPosition.X, penPosition.Y, widthF, heightF);
        }
    }
Ejemplo n.º 7
0
    public void DoDrawing(Pen pen, PenPosition penPosition, Graphics g, string line)
    {
        var    split = line.Split();
        string Operator;
        int    repeatSize = 5;

        int.TryParse(split[5], out int AmountOfRepition);
        Operator = split[4];

        if (double.TryParse(split[2], out double W) && double.TryParse(split[3], out double H) && W != H)
        {
            IShape rec = new RectangleShape(W, H);

            float widthF  = Convert.ToSingle(W);
            float heightF = Convert.ToSingle(H);

            if (Operator == "+")
            {
                for (int i = 0; i < AmountOfRepition; i++)
                {
                    g.DrawRectangle(pen, penPosition.X, penPosition.Y, widthF, heightF);
                    widthF  += repeatSize;
                    heightF += repeatSize;
                }
            }
            if (Operator == "-")
            {
                for (int i = 0; i < AmountOfRepition; i++)
                {
                    g.DrawRectangle(pen, penPosition.X, penPosition.Y, widthF, heightF);
                    widthF  -= repeatSize;
                    heightF -= repeatSize;
                }
            }
        }
        else
        {
            MessageBox.Show("Height & Width must be not be the same : FORMAT <Command> <Shape> <Width> <Height> <Operator> <Repitition Size>", "Wrong Paramters", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
Ejemplo n.º 8
0
        public void DoDrawing(Pen pen, PenPosition penPosition, Graphics g, string line)
        {
            var split = line.Split();

            try
            {
                double.TryParse(split[1], out var circleRadius);
                IShape circle = new CircleShape(circleRadius);

                ShapeFactory fac = new ShapeFactory();
                fac.CreateShape("circle");

                double diameter  = circle.GetDiameter();
                float  diameterF = Convert.ToSingle(diameter);

                g.DrawEllipse(pen, penPosition.X, penPosition.Y, diameterF, diameterF);
            }
            catch (IndexOutOfRangeException)
            {
                MessageBox.Show("Missing Radius Parameter, FORMAT <Shape> <Radius>", "Missing Paramters", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 9
0
 public void DoDrawing(Pen pen, PenPosition penPosition, Graphics g, string line)
 {
     MessageBox.Show("If statements are not coded yet.", "Uncomplete command", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Ejemplo n.º 10
0
 public void DoDrawing(Pen pen, PenPosition penPosition, Graphics g, string line)
 {
     throw new NotImplementedException();
 }