// Apply the move action private bool PerformMoveShape(IDiagramPresenter diagramPresenter) { bool result = false; if (selectedShapeAtCursorInfo.IsEmpty) { // This should never happen... Debug.Assert(!selectedShapeAtCursorInfo.IsEmpty); } if (ActionStartMouseState.Position != CurrentMouseState.Position) { // calculate the movement int distanceX = CurrentMouseState.X - ActionStartMouseState.X; int distanceY = CurrentMouseState.Y - ActionStartMouseState.Y; //snapDeltaX = snapDeltaY = 0; //if (diagramPresenter.SnapToGrid) // FindNearestSnapPoint(diagramPresenter, SelectedShapeAtCursorInfo.Shape, distanceX, distanceY, out snapDeltaX, out snapDeltaY, ControlPointCapabilities.All); ICommand cmd = new MoveShapeByCommand(diagramPresenter.SelectedShapes, distanceX + snapDeltaX, distanceY + snapDeltaY); diagramPresenter.Project.ExecuteCommand(cmd); snapDeltaX = snapDeltaY = 0; snapPtId = ControlPointId.None; result = true; } return result; }
// Apply the move action private bool PerformMoveShape(IDiagramPresenter diagramPresenter) { bool result = false; if (SelectedShapeAtCursorInfo.IsEmpty) { // This should never happen... Debug.Assert(!SelectedShapeAtCursorInfo.IsEmpty); } if (ActionStartMouseState.Position != CurrentMouseState.Position) { // calculate the movement int distanceX = CurrentMouseState.X - ActionStartMouseState.X; int distanceY = CurrentMouseState.Y - ActionStartMouseState.Y; //snapDeltaX = snapDeltaY = 0; //if (diagramPresenter.SnapToGrid) // FindNearestSnapPoint(diagramPresenter, SelectedShapeAtCursorInfo.Shape, distanceX, distanceY, out snapDeltaX, out snapDeltaY, ControlPointCapabilities.All); #if DEBUG_DIAGNOSTICS int dx = distanceX + snapDeltaX; int dy = distanceY + snapDeltaY; Debug.Assert(CurrentMouseState.Position == CurrentMouseState.Position); foreach (Shape selectedShape in diagramPresenter.SelectedShapes) { Shape previewShape = previewShapes[selectedShape]; Debug.Assert((previewShape.X == selectedShape.X && previewShape.Y == selectedShape.Y) || (previewShape.X == selectedShape.X + dx && previewShape.Y == selectedShape.Y + dy), string.Format("Preview shape '{0}' was expected at position {1} but it is at position {2}.", previewShape.Type.Name, new Point(selectedShape.X, selectedShape.Y), new Point(previewShape.X, previewShape.Y))); } #endif ICommand cmd = new MoveShapeByCommand(diagramPresenter.SelectedShapes, distanceX + snapDeltaX, distanceY + snapDeltaY); diagramPresenter.Project.ExecuteCommand(cmd); snapDeltaX = snapDeltaY = 0; snapPtId = ControlPointId.None; result = true; } return result; }