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;
            }
        }
        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 startCircle(MouseEventArgs e)
        {
            PointD CurrPosition = new PointD(e.ClientX - LocalData.SVGPosition.X, e.ClientY - LocalData.SVGPosition.Y);

            BPaintCircle new_BPaintCircle = new BPaintCircle();


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

            BPaintVertex startVertex = new BPaintVertex(CurrPosition, Color1);

            VerticesList.Add(startVertex);

            new_BPaintCircle.Selected  = true;
            new_BPaintCircle.EditMode  = true;
            new_BPaintCircle.Color     = Color1;
            new_BPaintCircle.LineWidth = LineWidth1;
            new_BPaintCircle.Position  = startVertex;
            BPaintVertex endVertex = new BPaintVertex(CurrPosition, Color1);

            new_BPaintCircle.end = endVertex;
            VerticesList.Add(endVertex);
            CurrPaintMode             = BPaintMode.movingAnElement;
            bpVertexUnderMousePointer = endVertex;
            ObjectsList.Add(new_BPaintCircle);
        }
        protected void btnSelectAll_onClick()
        {
            //ChangeObjectsSelection(true);
            RectD unionRect = ObjectsList.First().BoundingRectD();

            foreach (BPaintObject obj in ObjectsList)
            {
                unionRect = unionRect.UnionWith(obj.BoundingRectD());
            }

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

            BPaintVertex startVertex = new BPaintVertex(new PointD(unionRect.x - 10, unionRect.y - 10), "magenta");

            SelectionVerticesList.Add(startVertex);

            bpSelectionRectangle.Selected  = false;
            bpSelectionRectangle.EditMode  = true;
            bpSelectionRectangle.Color     = "red";
            bpSelectionRectangle.LineWidth = 2;
            bpSelectionRectangle.Position  = startVertex;
            BPaintVertex endVertex = new BPaintVertex(new PointD(unionRect.x + unionRect.width + 10, unionRect.y + unionRect.height + 10), "magenta");

            bpSelectionRectangle.end = endVertex;
            SelectionVerticesList.Add(endVertex);
            bpSelectionVertexUnderMousePointer = endVertex;

            ProcessSelection();
            cmd_RefreshSVG();
            StateHasChanged();
        }
コード例 #5
0
        public static RectD Get_Border_Points(BPaintVertex Par_obj)
        {
            RectD result = new RectD();

            result.x      = Par_obj.x - 10;
            result.y      = Par_obj.y - 10;
            result.width  = 20;
            result.height = 20;

            return(result);
        }
        public BPaintVertex makeVertex(MouseEventArgs e)
        {
            PointD CurrPosition = new PointD(e.ClientX - LocalData.SVGPosition.X, e.ClientY - LocalData.SVGPosition.Y);

            BPaintVertex currBPaintVertex = new BPaintVertex();


            if (ObjectsList.Any())
            {
                cmd_Clear_Selection();
            }

            currBPaintVertex.Selected = true;
            currBPaintVertex.Color    = Color1;
            currBPaintVertex.PtD      = new PointD(CurrPosition);
            VerticesList.Add(currBPaintVertex);
            return(currBPaintVertex);
        }
        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();
            }
        }
        public void onMouseMove(MouseEventArgs e)
        {
            //this.OnScroll();

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

            currMouseLocation    = CurrPosition;
            strCurrMouseLocation = "x: " + currMouseLocation.X.ToString("F2") + "; y: " + currMouseLocation.Y.ToString("F2");

            if (CurrOperationalMode == OperationalMode.select)
            {
                switch (CurrSelectionMode)
                {
                case SelectionMode.idle:
                    if (SelectionVerticesList.Any(x => (CurrPosition.DistanceTo(x.PtD) <= 10)))
                    {
                        BPaintVertex currVertex =
                            SelectionVerticesList.Single(x => (CurrPosition.DistanceTo(x.PtD) <= 10));

                        bpSelectionVertexUnderMousePointer          = currVertex;
                        bpSelectionVertexUnderMousePointer.Selected = true;
                        CurrSelectionMode = SelectionMode.hoveredAVertex;
                    }
                    else
                    {
                        bpSelectionVertexUnderMousePointer = null;
                        CurrSelectionMode = SelectionMode.idle;
                    }

                    break;

                case SelectionMode.movingAnElement:
                    BPaintVertex vertex2Move = bpSelectionVertexUnderMousePointer as BPaintVertex;
                    vertex2Move.PtD = CurrPosition;
                    break;

                case SelectionMode.hoveredAVertex:
                    if (SelectionVerticesList.Any(x => (CurrPosition.DistanceTo(x.PtD) <= 10)))
                    {
                        BPaintVertex currVertex =
                            SelectionVerticesList.Single(x => (CurrPosition.DistanceTo(x.PtD) <= 10));

                        bpSelectionVertexUnderMousePointer = currVertex;
                        CurrSelectionMode = SelectionMode.hoveredAVertex;
                    }
                    else
                    {
                        bpSelectionVertexUnderMousePointer = null;

                        foreach (BPaintVertex vertex in SelectionVerticesList)
                        {
                            vertex.Selected = false;
                        }

                        CurrSelectionMode = SelectionMode.idle;
                    }

                    break;

                default:
                    break;
                }
            }
            else
            {
                switch (CurrPaintMode)
                {
                // TODO: Fix vertices highlighting
                // category=Appearance issue=none estimate=2h
                // when there is no selection rectangle, vertices under the mouse cursor are not highlighted

                case BPaintMode.idle:
                    if (VerticesList.Any(x => (CurrPosition.DistanceTo(x.PtD) <= 10)))
                    {
                        BPaintVertex currVertex = VerticesList.Single(x => (CurrPosition.DistanceTo(x.PtD) <= 10));

                        bpVertexUnderMousePointer          = currVertex;
                        bpVertexUnderMousePointer.Selected = true;
                        CurrPaintMode = BPaintMode.hoveredAVertex;
                    }
                    else
                    {
                        bpVertexUnderMousePointer = null;
                        CurrPaintMode             = BPaintMode.idle;
                    }

                    break;

                case BPaintMode.drawing:
                    break;

                case BPaintMode.movingAnElement:
                    BPaintVertex vertex2Move = bpVertexUnderMousePointer as BPaintVertex;
                    vertex2Move.PtD = CurrPosition;
                    break;

                case BPaintMode.hoveredAVertex:
                    if (VerticesList.Any(x => (CurrPosition.DistanceTo(x.PtD) <= 10)))
                    {
                        BPaintVertex currVertex = VerticesList.Single(x => (CurrPosition.DistanceTo(x.PtD) <= 10));

                        bpVertexUnderMousePointer = currVertex;
                        CurrPaintMode             = BPaintMode.hoveredAVertex;
                    }
                    else
                    {
                        bpVertexUnderMousePointer = null;
                        foreach (BPaintObject bpObject in ObjectsList)
                        {
                            //bpObject.Selected = false;
                            bpObject.EditMode = false;
                        }

                        foreach (BPaintVertex vertex in VerticesList)
                        {
                            vertex.Selected = false;
                        }

                        CurrPaintMode = BPaintMode.idle;
                    }

                    break;

                default:
                    break;
                }
            }

            ProcessSelection();
            StateHasChanged();
        }