Ejemplo n.º 1
0
        private void Picture_MouseUp(object sender, MouseEventArgs e)
        {
            if (IsMoved == true)
            {
                if (linePanel.BackColor == Color.Green)
                {
                    g.DrawLine(new Pen(CurrentColor, PenWidth), firstP, secondP);
                }

                if (circlePanel.BackColor == Color.Green)
                {
                    if (menu_fill.BackColor == SystemColors.Control)
                    {
                        g.DrawEllipse(new Pen(CurrentColor, PenWidth), leftX, leftY, width, height);
                    }
                    else
                    {
                        g.FillEllipse(new SolidBrush(CurrentColor), leftX, leftY, width, height);
                    }
                }

                if (polygonPanel.BackColor == Color.Green && AmountOfSides > 2)
                {
                    if (menu_fill.BackColor == SystemColors.Control)
                    {
                        g.DrawPolygon(new Pen(CurrentColor, PenWidth), points.ToArray());
                    }
                    else
                    {
                        g.FillPolygon(new SolidBrush(CurrentColor), points.ToArray());
                    }
                }

                if (menu_additionally_rect.BackColor == Color.Green || menu_additionally_square.BackColor == Color.Green)
                {
                    if (menu_fill.BackColor == SystemColors.Control)
                    {
                        g.DrawRectangle(new Pen(CurrentColor, PenWidth), firstP.X, firstP.Y, width, height);
                    }
                    else
                    {
                        g.FillRectangle(new SolidBrush(CurrentColor), firstP.X, firstP.Y, width, height);
                    }
                }

                if (menu_additionally_circle.BackColor == Color.Green)
                {
                    if (menu_fill.BackColor == SystemColors.Control)
                    {
                        g.DrawEllipse(new Pen(CurrentColor, PenWidth), new Rectangle(leftX, leftY, width, height));
                    }
                    else
                    {
                        g.FillEllipse(new SolidBrush(CurrentColor), new Rectangle(leftX, leftY, width, height));
                    }
                }

                picture.Invalidate();
                IsMoved = false;
            }
        }
Ejemplo n.º 2
0
        private void panelPaint_MouseClick(object sender, MouseEventArgs e)
        {
            if (active.Equals("pen"))
            {
                g.DrawLine(pen, new Point(x, y), e.Location);
                x = e.X;
                y = e.Y;
            }
            else if (active.Equals("eraser"))
            {
                System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
                g.FillRectangle(myBrush, e.X, e.Y, 24, 24);
            }
            else if (active.Equals("rectangle"))
            {
                shapes = shapeFactory.getShape("RECTANGLE");
                shapes.SetParam(e.X - size / 2, e.Y - size / 2, size, size, mainColor);

                SolidBrush myBrush = new SolidBrush(mainColor);
                g.FillRectangle(myBrush, e.X - size / 2, e.Y - size / 2, size, size);
            }
            else if (active.Equals("triangle"))
            {
                System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(mainColor);
                Point[] pnt = new Point[3];

                pnt[0].X = e.X;
                pnt[0].Y = e.Y - size;

                pnt[1].X = e.X + size;
                pnt[1].Y = e.Y + size;

                pnt[2].X = e.X - size;
                pnt[2].Y = e.Y + size;
                g.FillPolygon(myBrush, pnt);
            }
            else if (active.Equals("circle"))
            {
                System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(mainColor);
                g.FillEllipse(myBrush, e.X - size / 2, e.Y - size / 2, size, size);
            }
            else if (active.Equals("polygon"))
            {
                Pen     myPen = new Pen(mainColor);
                Point[] pnt   = new Point[5];

                pnt[0].X = mouseX;
                pnt[0].Y = mouseY;

                pnt[1].X = mouseX + size;
                pnt[1].Y = mouseY;

                pnt[2].X = mouseX + size + (size / 2);
                pnt[2].Y = mouseY + size;

                pnt[3].X = mouseX - (size / 2);
                pnt[3].Y = mouseY + size;

                pnt[4].X = mouseX;
                pnt[4].Y = mouseY;
                g.DrawPolygon(myPen, pnt);
            }
        }