Browse Source

WPF Designer: Fixed "Cannot move multiple controls" (http://community.sharpdevelop.net/forums/t/13250.aspx)

4.1
Daniel Grunwald 15 years ago
parent
commit
c1ba2b7a41
  1. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs
  2. 13
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/PointerTool.cs

16
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs

@ -16,13 +16,15 @@ namespace ICSharpCode.WpfDesign.Designer.Services
sealed class DragMoveMouseGesture : ClickOrDragMouseGesture sealed class DragMoveMouseGesture : ClickOrDragMouseGesture
{ {
bool isDoubleClick; bool isDoubleClick;
bool setSelectionIfNotMoving;
MoveLogic moveLogic; MoveLogic moveLogic;
internal DragMoveMouseGesture(DesignItem clickedOn, bool isDoubleClick) internal DragMoveMouseGesture(DesignItem clickedOn, bool isDoubleClick, bool setSelectionIfNotMoving = false)
{ {
Debug.Assert(clickedOn != null); Debug.Assert(clickedOn != null);
this.isDoubleClick = isDoubleClick; this.isDoubleClick = isDoubleClick;
this.setSelectionIfNotMoving = setSelectionIfNotMoving;
this.positionRelativeTo = clickedOn.Services.DesignPanel; this.positionRelativeTo = clickedOn.Services.DesignPanel;
moveLogic = new MoveLogic(clickedOn); moveLogic = new MoveLogic(clickedOn);
@ -41,10 +43,14 @@ namespace ICSharpCode.WpfDesign.Designer.Services
protected override void OnMouseUp(object sender, MouseButtonEventArgs e) protected override void OnMouseUp(object sender, MouseButtonEventArgs e)
{ {
if (!hasDragStarted && isDoubleClick) { if (!hasDragStarted) {
// user made a double-click if (isDoubleClick) {
Debug.Assert(moveLogic.Operation == null); // user made a double-click
moveLogic.HandleDoubleClick(); Debug.Assert(moveLogic.Operation == null);
moveLogic.HandleDoubleClick();
} else if (setSelectionIfNotMoving) {
services.Selection.SetSelectedComponents(new DesignItem[] { moveLogic.ClickedOn }, SelectionTypes.Auto);
}
} }
moveLogic.Stop(); moveLogic.Stop();
Stop(); Stop();

13
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/PointerTool.cs

@ -37,9 +37,18 @@ namespace ICSharpCode.WpfDesign.Designer.Services
if (e.ChangedButton == MouseButton.Left && MouseGestureBase.IsOnlyButtonPressed(e, MouseButton.Left)) { if (e.ChangedButton == MouseButton.Left && MouseGestureBase.IsOnlyButtonPressed(e, MouseButton.Left)) {
e.Handled = true; e.Handled = true;
ISelectionService selectionService = designPanel.Context.Services.Selection; ISelectionService selectionService = designPanel.Context.Services.Selection;
selectionService.SetSelectedComponents(new DesignItem[] { result.ModelHit }, SelectionTypes.Auto); bool setSelectionIfNotMoving = false;
if (selectionService.IsComponentSelected(result.ModelHit)) { if (selectionService.IsComponentSelected(result.ModelHit)) {
new DragMoveMouseGesture(result.ModelHit, e.ClickCount == 2).Start(designPanel, e); setSelectionIfNotMoving = true;
// There might be multiple components selected. We might have
// to set the selection to only the item clicked on
// (or deselect the item clicked on if Ctrl is pressed),
// but we should do so only if the user isn't performing a drag operation.
} else {
selectionService.SetSelectedComponents(new DesignItem[] { result.ModelHit }, SelectionTypes.Auto);
}
if (selectionService.IsComponentSelected(result.ModelHit)) {
new DragMoveMouseGesture(result.ModelHit, e.ClickCount == 2, setSelectionIfNotMoving).Start(designPanel, e);
} }
} }
} }

Loading…
Cancel
Save