public void startEllipse(MouseEventArgs e)
        {
            PointD CurrPosition = new PointD(e.ClientX - LocalData.SVGPosition.X, e.ClientY - LocalData.SVGPosition.Y);

            BPaintEllipse new_BPaintEllipse = new BPaintEllipse();


            if (ObjectsList.Any())
            {
                new_BPaintEllipse.ObjectID = ObjectsList.Max(x => x.ObjectID) + 1;
                cmd_Clear_Selection();
                cmd_Clear_Editing();
            }
            else
            {
                new_BPaintEllipse.ObjectID = 1;
            }

            BPaintVertex startVertex = new BPaintVertex(CurrPosition, Color1);

            VerticesList.Add(startVertex);

            new_BPaintEllipse.Selected  = true;
            new_BPaintEllipse.EditMode  = true;
            new_BPaintEllipse.Color     = Color1;
            new_BPaintEllipse.LineWidth = LineWidth1;
            new_BPaintEllipse.Position  = startVertex;
            //new_BPaintEllipse.VerticesList.Add(startVertex);
            CurrPaintMode = BPaintMode.drawing;
            ObjectsList.Add(new_BPaintEllipse);
        }
        public void continueEllipse(MouseEventArgs e)
        {
            PointD CurrPosition = new PointD(e.ClientX - LocalData.SVGPosition.X, e.ClientY - LocalData.SVGPosition.Y);

            BPaintEllipse currBPaintEllipse =
                ObjectsList.Single(o => ((o.EditMode) & (o.ObjectType == BPaintOpbjectType.Ellipse))) as BPaintEllipse;

            BPaintVertex currVertex = new BPaintVertex(CurrPosition, Color1);

            VerticesList.Add(currVertex);

            switch (currBPaintEllipse.VerticesList.Count)
            {
            case 1:
                currBPaintEllipse.pt2 = currVertex;
                break;

            case 2:
                currBPaintEllipse.pt3      = currVertex;
                currBPaintEllipse.EditMode = false;
                CurrPaintMode = BPaintMode.idle;
                break;

            default:
                break;
            }
        }
예제 #3
0
        public static RectD Get_Border_Points(BPaintEllipse Par_obj, bool padding = true)
        {
            RectD  result     = new RectD();
            SizeD  bRectSizeD = Par_obj.boundingRectangleSizeD;
            PointD cPoint     = Par_obj.centerPointD;

            result.x      = cPoint.X - 0.5 * bRectSizeD.Width;
            result.y      = cPoint.Y - 0.5 * bRectSizeD.Height;
            result.width  = bRectSizeD.Width;
            result.height = bRectSizeD.Height;

            if (padding)
            {
                Set_Padding(result);
            }

            return(result);
        }
        public void onMouseDown(MouseEventArgs e)
        {
            if (CurrOperationalMode == OperationalMode.select)
            {
                if (CurrSelectionMode == SelectionMode.idle)
                {
                    if (bpSelectionRectangle != null)
                    {
                        foreach (BPaintVertex vertex in bpSelectionRectangle.VerticesList)
                        {
                            SelectionVerticesList.RemoveAll(x => true);
                        }
                        bpSelectionRectangle = null;
                    }

                    PointD CurrPosition = new PointD(e.ClientX - LocalData.SVGPosition.X, e.ClientY - LocalData.SVGPosition.Y);

                    bpSelectionRectangle = new BPaintRectangle()
                    {
                        ObjectID = 999
                    };

                    BPaintVertex startVertex = new BPaintVertex(CurrPosition, "magenta");
                    SelectionVerticesList.Add(startVertex);

                    bpSelectionRectangle.Selected  = false;
                    bpSelectionRectangle.EditMode  = true;
                    bpSelectionRectangle.Color     = "red";
                    bpSelectionRectangle.LineWidth = 2;
                    bpSelectionRectangle.Position  = startVertex;
                    BPaintVertex endVertex = new BPaintVertex(CurrPosition, "magenta");
                    bpSelectionRectangle.end = endVertex;
                    SelectionVerticesList.Add(endVertex);
                    CurrSelectionMode = SelectionMode.movingAnElement;
                    bpSelectionVertexUnderMousePointer = endVertex;
                }
                else if (CurrSelectionMode == SelectionMode.hoveredAVertex)
                {
                    if (bpSelectionVertexUnderMousePointer != null)
                    {
                        BPaintVertex currVertex = bpSelectionVertexUnderMousePointer as BPaintVertex;
                        currVertex.Selected = true;
                        CurrSelectionMode   = SelectionMode.movingAnElement;
                    }
                }
                StateHasChanged();
            }
            else
            {
                if (CurrPaintMode == BPaintMode.idle)
                {
                    if (!ObjectsList.Any(o => o.EditMode))
                    {
                        switch (FigureCode)
                        {
                        case 2:
                            startLine(e);
                            break;

                        case 3:
                            BPaintVertex newVertex = makeVertex(e);
                            CurrPaintMode = BPaintMode.idle;
                            break;

                        case 4:
                            startCircle(e);
                            break;

                        case 5:
                            //cmd_prepareEllipse(e);
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        BPaintObject currBPaintObject = ObjectsList.Single(o => o.EditMode);
                        BPaintVertex newVertex        = makeVertex(e);

                        switch (currBPaintObject.ObjectType)
                        {
                        case BPaintOpbjectType.Ellipse:
                            BPaintEllipse currEllipse = currBPaintObject as BPaintEllipse;
                            currEllipse.pt3      = newVertex;
                            currEllipse.EditMode = false;
                            break;

                        default:
                            break;
                        }

                        CurrPaintMode = BPaintMode.idle;
                    }
                }
                else if (CurrPaintMode == BPaintMode.hoveredAVertex)
                {
                    if (bpVertexUnderMousePointer != null)
                    {
                        BPaintVertex currVertex = bpVertexUnderMousePointer as BPaintVertex;
                        currVertex.Selected = true;
                        CurrPaintMode       = BPaintMode.movingAnElement;
                    }
                }

                StateHasChanged();
            }
        }