Browse Source

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

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

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

@ -37,9 +37,18 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -37,9 +37,18 @@ namespace ICSharpCode.WpfDesign.Designer.Services
if (e.ChangedButton == MouseButton.Left && MouseGestureBase.IsOnlyButtonPressed(e, MouseButton.Left)) {
e.Handled = true;
ISelectionService selectionService = designPanel.Context.Services.Selection;
selectionService.SetSelectedComponents(new DesignItem[] { result.ModelHit }, SelectionTypes.Auto);
bool setSelectionIfNotMoving = false;
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