Exemplo n.º 1
0
        private void UpdateReservedBounding()
        {
            CADPoint centerInModel = _presenter.CanvasToModel(_center);
            double   sideInModel   = _presenter.CanvasToModel(_side);

            _reservedBounding = new Bounding(centerInModel, sideInModel, sideInModel);
        }
Exemplo n.º 2
0
        //public void Draw()
        //{
        //    foreach (KeyValuePair<ObjectId, List<GripPoint>> kvp in _gripPnts)
        //    {
        //        foreach (GripPoint gripPnt in kvp.Value)
        //        {
        //            double width = 10;
        //            double height = 10;
        //            CADPoint posInCanvas = _drawing.ModelToCanvas(gripPnt.Position);
        //            posInCanvas.X -= width / 2;
        //            posInCanvas.Y -= height / 2;
        //            _drawing.FillRectangle(graphics, Color.Blue, posInCanvas, width, height, CSYS.Canvas);
        //        }
        //    }
        //}

        public CADPoint Snap(CADPoint posInCanvas)
        {
            CADPoint posInModel = _drawing.CanvasToModel(posInCanvas);

            foreach (KeyValuePair <ObjectId, List <GripPoint> > kvp in _gripPnts)
            {
                int index = -1;
                foreach (GripPoint gripPnt in kvp.Value)
                {
                    ++index;
                    double   width           = 10;
                    double   height          = 10;
                    CADPoint gripPosInCanvas = _drawing.ModelToCanvas(gripPnt.Position);
                    gripPosInCanvas.X -= width / 2;
                    gripPosInCanvas.Y -= height / 2;
                    Rectangle2 rect = new Rectangle2(gripPosInCanvas, width, height);

                    if (MathUtils.IsPointInRectangle(posInCanvas, rect))
                    {
                        currentGripPoint      = gripPnt;
                        currentGripEntityId   = kvp.Key;
                        currentGripPointIndex = index;
                        return(gripPnt.Position);
                    }
                }
            }

            currentGripPoint      = null;
            currentGripEntityId   = ObjectId.Null;
            currentGripPointIndex = -1;
            return(posInModel);
        }
Exemplo n.º 3
0
        public IEventResult OnMouseMove(IMouseEventArgs e)
        {
            _pos.X = e.X;
            _pos.Y = e.Y;
            _loc   = _drawing.CanvasToModel(_pos);
            switch (mode)
            {
            case PointerModes.Default:
                if (SelRect.Active)
                {
                    SelRect.EndPoint = _pos;
                }
                else
                {
                    CurrentSnapPoint = _anchorMgr.Snap(_pos);
                    _loc             = CurrentSnapPoint;
                }
                break;

            case PointerModes.Select:
                if (SelRect.Active)
                {
                    SelRect.EndPoint = _pos;
                }
                else
                {
                    _loc = _drawing.CanvasToModel(_pos);
                }
                break;

            case PointerModes.Locate:
                CurrentSnapPoint = _snapNodesMgr.Snap(_pos);
                _loc             = CurrentSnapPoint;
                _snapNodesMgr.OnMouseMove(e);
                break;

            case PointerModes.Drag:
                break;

            default:
                break;
            }

            Draw();
            return(null);
        }