public void ToolMouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         varStateRectangle = new RectangleState(e.X, e.Y);
         this.varCanvas.AddDrawingObject(this.varStateRectangle);
     }
 }
예제 #2
0
        /// <summary>
        /// Controls mouse up event handler after
        /// Selection rectangle has been drawn
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Canvas_MouseUp(object sender, MouseEventArgs e)
        {
            mouseDown = false;

            if (currDrawingTool == DrawingTool.Rectangle)
            {
                assets.Add(currAsset);
                path.AddRectangle(currAsset.Rectangle);
            }
            else if (currDrawingTool == DrawingTool.Circle)
            {
                assets.Add(currAsset);
                path.AddRectangle(currAsset.Rectangle);
            }
            else if (currDrawingTool == DrawingTool.Pen)
            {
                if (currAsset.Points.Count == 1)
                {
                    currAsset.Points.Add(e.Location);
                }

                if (currAsset.Points.Count > 1)
                {
                    assets.Add(currAsset);
                }

                path.AddCurve(currAsset.Points.ToArray());
            }
            else if (currDrawingTool == DrawingTool.Line || currDrawingTool == DrawingTool.ArrowLine)
            {
                assets.Add(currAsset);
                path.AddLine(currAsset.LineStart, currAsset.LineEnd);
            }
            if (selectionRect.Height > 0 || selectionRect.Width > 0)
            {
                path.AddRectangle(selectionRect);

                toolbox.TopLevel = false;
                Controls.Add(toolbox);
                toolbox.Location = GetToolBoxLocation();
                toolbox.Show();
                toolbox.BringToFront();

                manipToolbox.TopLevel = false;
                Controls.Add(manipToolbox);
                manipToolbox.Location = GetManipToolboxLoc();
                manipToolbox.Show();
                manipToolbox.BringToFront();

                Focus();
            }

            rectState     = RectangleState.None;
            focusedHandle = GrabHandle.None;
        }
예제 #3
0
        private void StateIntegrate(RectangleState state)
        {
            switch (state)
            {
            case RectangleState.Drag:
                CalculationViewPosition();
                Drag();
                break;

            case RectangleState.DragEnd:
                CalculationViewPosition();
                DragEnd();
                break;
            }
        }
예제 #4
0
        /// <summary>
        /// Logic when selection draw starts
        /// drawing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Canvas_MouseDown(object sender, MouseEventArgs e)
        {
            drawBorders = true;
            drawHandles = true;
            mouseDown   = true;

            switch (currDrawingTool)
            {
            case DrawingTool.Arrow:
                bool inPos = false;
                foreach (GrabHandle handle in Enum.GetValues(typeof(GrabHandle)))
                {
                    if (rectangles[handle].Contains(e.Location))
                    {
                        inPos         = true;
                        focusedHandle = handle;
                        break;
                    }
                }

                if (inPos)
                {
                    rectState = RectangleState.Resize;
                }
                else if (selectionRect.Contains(e.Location) && !inPos)
                {
                    rectState = RectangleState.Move;
                }
                else
                {
                    rectState            = RectangleState.Draw;
                    toolbox.Visible      = false;
                    manipToolbox.Visible = false;
                    path = new GraphicsPath();
                }
                break;

            case DrawingTool.Circle:
                var circle = new Asset()
                {
                    BorderWidth = currBorderWidth,
                    Color       = toolbox.SelectedColor,
                    Shape       = Shape.Circle,
                    Rectangle   = new Rectangle(Cursor.Position.X, Cursor.Position.Y, 0, 0)
                };
                currAsset = circle;
                break;

            case DrawingTool.ArrowLine:
            case DrawingTool.Line:
                var line = new Asset()
                {
                    BorderWidth = currBorderWidth,
                    Color       = toolbox.SelectedColor,
                    Shape       = currDrawingTool == DrawingTool.Line ? Shape.Line : Shape.ArrowLine,
                    LineStart   = new Point(e.X, e.Y),
                    LineEnd     = new Point(e.X, e.Y)
                };
                currAsset = line;
                break;

            case DrawingTool.Pen:
                var pen = new Asset()
                {
                    BorderWidth = currBorderWidth,
                    Color       = toolbox.SelectedColor,
                    Shape       = Shape.Pen,
                    Points      = new List <PointF>()
                };

                pen.Points.Add(e.Location);
                currAsset = pen;
                break;

            case DrawingTool.Rectangle:
                var rectangle = new Asset()
                {
                    BorderWidth = currBorderWidth,
                    Color       = toolbox.SelectedColor,
                    Shape       = Shape.Rectangle,
                    Rectangle   = new RectangleF(Cursor.Position.X, Cursor.Position.Y, 0, 0)
                };
                currAsset = rectangle;
                break;

            case DrawingTool.Text:
                break;
            }

            pX = e.X;
            pY = e.Y;

            pnlDraw.Invalidate(Rectangle.Round(path.GetBounds()));
        }