示例#1
0
        public IEventResult OnMouseUp(IMouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left && e.ButtonState == MouseButtonState.Released)
            {
                if (SelRect.Active)
                {
                    List <Selection> sels = SelRect.Select(_drawing.CurrentBlock);
                    if (sels.Count > 0)
                    {
                        if (e.IsShiftKeyDown())
                        {
                            (_drawing.Document as Document).Selections.Remove(sels);
                        }
                        else
                        {
                            (_drawing.Document as Document).Selections.Add(sels);
                        }
                        DrawSelection(sels, e.IsShiftKeyDown());
                    }
                }

                SelRect.Reset();
                Draw();
            }
            _snapNodesMgr.OnMouseUp(e);
            return(null);
        }
示例#2
0
        public IEventResult OnMouseDown(IMouseButtonEventArgs e)
        {
            _pos.X = e.X;
            _pos.Y = e.Y;
            Command cmd = null;

            switch (mode)
            {
            case PointerModes.Default:
                #region
            {
                if (e.IsLeftPressed)
                {
                    if (_anchorMgr.currentGripPoint == null)
                    {
                        _pickupBox.center = _pos;
                        List <Selection> sels = _pickupBox.Select(_drawing.CurrentBlock);
                        if (sels.Count > 0)
                        {
                            //user directly clicked on entities.
                            if (e.IsShiftKeyDown())
                            {
                                (_drawing.Document as Document).Selections.Remove(sels);
                            }
                            else
                            {
                                (_drawing.Document as Document).Selections.Add(sels);
                            }

                            DrawSelection(sels, e.IsShiftKeyDown());
                        }
                        else
                        {
                            //start a selection box
                            SelRect.Active     = true;
                            SelRect.StartPoint = SelRect.EndPoint = _pos;
                        }
                    }
                    else
                    {
                        //user selected a grip point

                        Database db     = (_drawing.Document as Document).Database;
                        Entity   entity = db.GetObject(_anchorMgr.currentGripEntityId) as Entity;
                        if (entity != null)
                        {
                            GripPointMoveCmd gripMoveCmd = new GripPointMoveCmd(
                                entity, _anchorMgr.currentGripPointIndex, _anchorMgr.currentGripPoint);

                            cmd = gripMoveCmd;
                        }
                    }
                }
            }
                #endregion
                break;

            case PointerModes.Select:
                #region
            {
                if (e.IsLeftPressed)
                {
                    _pickupBox.center = _pos;
                    List <Selection> sels = _pickupBox.Select(_drawing.CurrentBlock);
                    if (sels.Count > 0)
                    {
                        if (e.IsShiftKeyDown())
                        {
                            (_drawing.Document as Document).Selections.Remove(sels);
                        }
                        else
                        {
                            (_drawing.Document as Document).Selections.Add(sels);
                        }
                        DrawSelection(sels, e.IsShiftKeyDown());
                    }
                    else
                    {
                        SelRect.Active     = true;
                        SelRect.StartPoint = SelRect.EndPoint = _pos;
                    }
                }
            }
                #endregion
                break;

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

            case PointerModes.Drag:
                break;

            default:
                break;
            }

            return(new EventResult()
            {
                data = cmd
            });
        }