Disable the selection and dragging of the node during rubber band zoom


#1

I have implemented the rubber band zoom feature.
When the strating point of the rectangle is on a node, the node is selected and is dragged.
How do I disable the selection and dragging of the node during rubber band zoom.

I have tried setting false to AllowSelect property in diagram but it does not work because the selection rectangle itself is disabled.


#2

Override the DragSelectingTool.CanStart method, http://www.goxam.com/2.2/helpWPF/webframe.html#Northwoods.GoWPF~Northwoods.GoXam.Tool.DragSelectingTool~CanStart.html, so that it ignores whether or not there is a Part at the mouse point. Here is the standard definition of that method, with the Part-checking code commented out:

    public override bool CanStart() {
      if (!base.CanStart()) return false;

      Diagram diagram = this.Diagram;
      if (diagram == null || !diagram.AllowSelect) return false;

      // require left button & that it has moved far enough away from the mouse down point, so it isn't a click
      if (!IsLeftButtonDown()) return false;

      // don't include the following check when this tool is running modally
      if (diagram.CurrentTool != this) {
        // mouse needs to have moved from the mouse-down point
        if (!IsBeyondDragSize()) return false;

        // don't start if we're over a selectable part
        //Part part = FindPartAt(diagram.FirstMousePointInModel, true);
        //if (part != null) return false;
      }
      return true;
    }

From your description I assume you want to disable the DraggingTool. You can do that directly, by setting DraggingTool.MouseEnabled to false. Or you can set Diagram.allowMove and Diagram.allowCopy to false.


#3

I have tried the above implementation.When I zoom anywhere on the diagram, CanStart() works fine. But when I try to zoom a particular node where the start point of the rect is inside the node, it hits the (!base.CanStart() ) and returns false. Hence the node is selected.
Diagram.AllowMove & Diagram.AllowCopy when set to false disables the DraggingTool itself which I don’t want.
Is there any other way to solve this?


#4

What do you want a mouse-down-and-drag to do when the mouse-down point is on a Node? You can either choose to drag the node (starting the DraggingTool) or you can choose to start a selection box (DragSelectingTool).

By default the DraggingTool takes precedence, but you could swap the order of the DraggingTool and the DragSelectingTool in the Diagram.MouseMoveTools list.