Ejemplo n.º 1
0
        public override void MouseMove(ViewportBase vp, ViewportEvent e)
        {
            base.MouseMove(vp, e);

            if (_currentTool == null)
            {
                return;
            }

            _currentTool.MouseMove(vp, e);
            if (e.Handled)
            {
                return;
            }

            if (!(vp is Viewport2D))
            {
                return;
            }
            if (_currentTool.NoSelection())
            {
                return;
            }

            var viewport = (Viewport2D)vp;

            if (_movingPoint == null)
            {
                // Not moving a point, just test for the cursor.
                var vtxs = _currentTool.GetVerticesAtPoint(e.X, viewport.Height - e.Y, viewport);
                if (vtxs.Any())
                {
                    viewport.Cursor = Cursors.Cross;
                }
                else if (viewport.Cursor == Cursors.Cross)
                {
                    viewport.Cursor = Cursors.Default;
                }
            }
            else
            {
                // Moving a point, get the delta moved
                var point = SnapIfNeeded(viewport.Expand(viewport.ScreenToWorld(e.X, viewport.Height - e.Y)));
                if (!KeyboardState.Alt && KeyboardState.Shift)
                {
                    // If shift is down, retain the offset the point was at before (relative to the grid)
                    point += _snapPointOffset;
                }
                var moveDistance = point - viewport.ZeroUnusedCoordinate(_movingPoint.Coordinate);
                _currentTool.DragMove(moveDistance);
                //RefreshMidpoints(false);
                UpdateMidpoints();
                MoveSelection = null;
            }
        }