示例#1
0
        private void pnl_canvas_MouseUp(object sender, MouseEventArgs e)
        {
            isClicking = false;
            using (objDrawer = Graphics.FromImage(canvas))
            {
                switch (activeTool)
                {
                case Tools.Brush:
                case Tools.Pen:
                    objDrawer.DrawImage(lastPenDrawing, 0, 0);
                    lastPenDrawing = null;
                    break;

                case Tools.Line:
                    objDrawer.DrawLine(normalPen, lastLine[0], lastLine[1]);
                    lastLine = new Point[2];
                    break;

                case Tools.Rectangle:
                    lastShape = new Rectangle(0, 0, 0, 0);
                    drawFillables(objDrawer.DrawRectangle, objDrawer.FillRectangle, createRectangle(firstPoint, lastPoint));
                    break;

                case Tools.Circle:
                    lastShape = new Rectangle(0, 0, 0, 0);
                    drawFillables(objDrawer.DrawEllipse, objDrawer.FillEllipse, createRectangle(firstPoint, lastPoint));
                    break;

                case Tools.Triangle:
                    lastTriangle = new Point[3];
                    drawFillables(objDrawer.DrawPolygon, objDrawer.FillPolygon, createTriangle(firstPoint, lastPoint));
                    break;

                case Tools.RegularPolygon:
                    lastRegularPolygon = new Point[5];
                    outlineCircle      = new RectangleF();
                    drawFillables(objDrawer.DrawPolygon, objDrawer.FillPolygon, createRegularPolygon(firstPoint, lastPoint));
                    break;

                case Tools.IrregularPolygon:
                    if (checkIrregularPolygon())
                    {
                        drawFillables(objDrawer.DrawPolygon, objDrawer.FillPolygon, lastIrregularPolygon.ToArray());
                        lastIrregularPolygon = new List <Point>();
                    }
                    break;

                case Tools.Arrow:
                    lastArrow = new Point[7];
                    drawFillables(objDrawer.DrawPolygon, objDrawer.FillPolygon, createArrow(firstPoint, lastPoint));
                    break;

                case Tools.Selection:
                    if (isHolding)
                    {
                        objDrawer.DrawImage(lastImageSelection, lastSelection.Location);
                    }
                    else if (lastSelection.Width > 0 && lastSelection.Height > 0)
                    {
                        lastImageSelection = new Bitmap(lastSelection.Width, lastSelection.Height);
                        Graphics objSelect = Graphics.FromImage(lastImageSelection);
                        objSelect.DrawImage(canvas, 0, 0, lastSelection, GraphicsUnit.Pixel);
                        objSelect.Dispose();
                    }
                    break;

                case Tools.Curve:
                    if (!lastCurve[3].IsEmpty)
                    {
                        objDrawer.DrawBezier(normalPen, lastCurve[0], lastCurve[2], lastCurve[3], lastCurve[1]);
                        lastCurve = new Point[4];
                    }
                    break;

                case Tools.Star:
                    lastStar      = new Point[6];
                    outlineCircle = new RectangleF();
                    drawFillables(objDrawer.DrawPolygon, objDrawer.FillPolygon, createStar(firstPoint, lastPoint));
                    break;

                case Tools.Trapezoid:
                    lastQuad = new Point[4];
                    drawFillables(objDrawer.DrawPolygon, objDrawer.FillPolygon, createTrapezoid(firstPoint, lastPoint));
                    break;

                case Tools.Diamond:
                    lastQuad = new Point[4];
                    drawFillables(objDrawer.DrawPolygon, objDrawer.FillPolygon, createDiamond(firstPoint, lastPoint));
                    break;

                case Tools.RightTriangle:
                    lastTriangle = new Point[3];
                    drawFillables(objDrawer.DrawPolygon, objDrawer.FillPolygon, createRightTriangle(firstPoint, lastPoint));
                    break;

                default:
                    break;
                }
                pnl_canvas.Refresh();
            }
        }
示例#2
0
 public override void DrawNoFill(Graphics Gp)
 {
     Gp.DrawBezier(PenDraw, p1, new Point((p1.X + p2.X) / 4, (p1.Y + p2.Y) / 4 + 100), new Point((p1.X + p2.X) * 3 / 4, (p1.Y + p2.Y) * 3 / 5 - 100), p2);
 }