Exemplo n.º 1
0
        private void Panel_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            for (i = 0; i < all_shapes.Length; i++)
            {
                if (!all_shapes[i].getSolid())
                {
                    pen.Width     = 1;
                    pen.Color     = all_shapes[i].getLineColor();
                    pen.DashStyle = DashStyle.Dot;
                }
                else
                {
                    pen.Width     = all_shapes[i].getThick();
                    pen.Color     = all_shapes[i].getLineColor();
                    pen.DashStyle = DashStyle.Solid;
                }

                if (all_shapes[i].GetType() == new MyPen().GetType())
                {
                    MyPen mypen = (MyPen)all_shapes[i];

                    e.Graphics.DrawLine(pen, mypen.getStart(), mypen.getFinish());
                    e.Graphics.FillEllipse(new SolidBrush(pen.Color), mypen.getStart().X, mypen.getStart().Y, 1, 1);
                }
                else if (all_shapes[i].GetType() == new MyLines().GetType())
                {
                    MyLines myline = (MyLines)all_shapes[i];

                    e.Graphics.DrawLine(pen, all_shapes[i].getStart(), all_shapes[i].getFinish());
                }
                else if (all_shapes[i].GetType() == new MyCircle().GetType())
                {
                    MyCircle mycircle = (MyCircle)all_shapes[i];

                    e.Graphics.DrawEllipse(pen, mycircle.getRectC());
                    if (mycircle.getFill())
                    {
                        sb.Color = mycircle.getColor();
                        e.Graphics.FillEllipse(sb, mycircle.getRectC());
                    }
                }
                else if (all_shapes[i].GetType() == new MyRect().GetType())
                {
                    MyRect myrect = (MyRect)all_shapes[i];

                    e.Graphics.DrawRectangle(pen, myrect.getRect());
                    if (myrect.getFill())
                    {
                        sb.Color = myrect.getColor();
                        e.Graphics.FillRectangle(sb, myrect.getRect());
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void Panel_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            for (i = 0; i <= nobject; i++)
            {
                if (all_object[i].GetType() == new MyRect().GetType())
                {
                    MyRect myrect = (MyRect)all_object[i];
                    if (!myrect.getSolid())
                    {
                        pen.Width     = 1;
                        pen.Color     = myrect.getLineColor();
                        pen.DashStyle = DashStyle.Dot;
                    }
                    else
                    {
                        pen.Width     = myrect.getThick();
                        pen.Color     = myrect.getLineColor();
                        pen.DashStyle = DashStyle.Solid;
                    }

                    e.Graphics.DrawRectangle(pen, myrect.getRect());
                    if (myrect.getFill())
                    {
                        sb.Color = myrect.getColor();
                        e.Graphics.FillRectangle(sb, myrect.getRect());
                    }
                }
                else if (all_object[i].GetType() == new MyLines().GetType())
                {
                    MyLines myline = (MyLines)all_object[i];
                    if (!myline.getSolid())
                    {
                        pen.Width     = 1;
                        pen.Color     = myline.getLineColor();
                        pen.DashStyle = DashStyle.Dot;
                    }
                    else
                    {
                        pen.Width     = myline.getThick();
                        pen.Color     = myline.getLineColor();
                        pen.DashStyle = DashStyle.Solid;
                    }
                    e.Graphics.DrawLine(pen, myline.getPoint1(), myline.getPoint2());
                }
                else if (all_object[i].GetType() == new MyCircle().GetType())
                {
                    MyCircle mycircle = (MyCircle)all_object[i];
                    if (!mycircle.getSolid())
                    {
                        pen.Width     = 1;
                        pen.Color     = mycircle.getLineColor();
                        pen.DashStyle = DashStyle.Dot;
                    }
                    else
                    {
                        pen.Width     = mycircle.getThick();
                        pen.Color     = mycircle.getLineColor();
                        pen.DashStyle = DashStyle.Solid;
                    }
                    e.Graphics.DrawEllipse(pen, mycircle.getRectC());
                    if (mycircle.getFill())
                    {
                        sb.Color = mycircle.getColor();
                        e.Graphics.FillEllipse(sb, mycircle.getRectC());
                    }
                }
                else if (all_object[i].GetType() == new MyPen().GetType())
                {
                    MyPen mypen = (MyPen)all_object[i];
                    if (!mypen.getSolid())
                    {
                        pen.Width     = 1;
                        pen.Color     = mypen.getLineColor();
                        pen.DashStyle = DashStyle.Dot;
                    }
                    else
                    {
                        pen.Width     = mypen.getThick();
                        pen.Color     = mypen.getLineColor();
                        pen.DashStyle = DashStyle.Solid;
                    }
                    e.Graphics.DrawLine(pen, mypen.getOld(), mypen.getCurrent());
                    e.Graphics.FillEllipse(new SolidBrush(pen.Color), mypen.getOld().X - 6, mypen.getOld().Y - 6, 1, 1);
                }
            }

            pen.Width     = thick;
            pen.DashStyle = DashStyle.Solid;
            graphics      = e.Graphics;
        }