Beispiel #1
0
 void Start()
 {
     InitializeComponent();
     figures = new MyFigures(this.Width, this.Width);
     //openFileDialog1.Filter = "Image Files (*.bmp;*.jpg;*.png)|*.bmp;*.jpg;*.png";
     //saveFileDialog1.Filter = "Images|*.bmp;*.jpg;*.png";
 }
Beispiel #2
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
Beispiel #3
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
Beispiel #4
0
 void Start()
 {
     InitializeComponent();
     figures  = new MyFigures(this.Width, this.Height);
     graphics = panel1.CreateGraphics();
     pen.SetLineCap(System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.DashCap.Round);
     BrushType = PenMode;
 }
Beispiel #5
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