예제 #1
0
        } // RectangleMode

        void CircleMode(Graphics graphics, Pen pen, Point start, Point end, MyFigures figures)
        {
            if (start.X > end.X) // if start point > end point swap
            {
                int temp = start.X;
                start.X = end.X;
                end.X   = temp;
            }

            if (start.Y > end.Y) // if start point > end point swap
            {
                int temp = start.Y;
                start.Y = end.Y;
                end.Y   = temp;
            }

            int       width  = end.X - start.X;
            int       height = end.Y - start.Y;
            Rectangle rect   = new Rectangle(start.X, start.Y, width, height);

            graphics.DrawEllipse(pen, rect);

            if (BrushOn)
            {
                graphics.FillEllipse(brush.GetBrush(), rect);
                figures.Add(new MyCircle(start, width, height, pen.Color, pen.Width, brush));
            }
            else
            {
                figures.Add(new MyCircle(start, width, height, pen.Color, pen.Width));
            }
        } // CircleMode
예제 #2
0
        } // CircleMode

        void TriangleMode(Graphics graphics, Pen pen, Point start, Point end, MyFigures figures)
        {
            if (start.X > end.X) // if start point > end point swap
            {
                int temp = start.X;
                start.X = end.X;
                end.X   = temp;
            }

            if (start.Y > end.Y) // if start point > end point swap
            {
                int temp = start.Y;
                start.Y = end.Y;
                end.Y   = temp;
            }

            Point point1 = new Point(end.X / 2, start.Y);
            Point point2 = new Point(end.X, end.Y);
            Point point3 = new Point(start.X, end.Y);

            graphics.DrawPolygon(pen, new Point[] { point1, point2, point3 });

            if (BrushOn)
            {
                graphics.FillPolygon(brush.GetBrush(), new Point[] { point1, point2, point3 });
                figures.Add(new MyTriangle(point1, point2, point3, pen.Color, pen.Width, brush));
            }
            else
            {
                figures.Add(new MyTriangle(point1, point2, point3, pen.Color, pen.Width));
            }
        } // RectangleMode
예제 #3
0
        } // SizeSubMenu_Click

        void PenMode()
        {
            graphics.DrawLine(pen, start, end);
            figures.Add(new MyPencil(start, end, pen.Color, pen.Width));
            start = end;
        } // PenMode
예제 #4
0
        } // PenMode

        void LineMode(Graphics graphics, Pen pen, Point start, Point end, MyFigures figures)
        {
            graphics.DrawLine(pen, start, end);
            figures.Add(new MyPencil(start, end, pen.Color, pen.Width));
        } // LineMode