Class DragZoomingTool

GoDiagram®
v10.0.11
by Northwoods Software®

The DragZoomingTool lets the user zoom into a diagram by stretching a box to indicate the new contents of the diagram's viewport (the area of the model shown by the Diagram). Hold down the Shift key in order to zoom out.

Inheritance
DragZoomingTool
Namespace: Northwoods.Go.Tools.Extensions
Assembly: DragZoomingAvalonia.dll
Syntax
public class DragZoomingTool : Tool
Remarks

The default drag selection box is a magenta rectangle. You can modify the Box to customize its appearance.

The diagram that is zoomed by this tool is specified by the ZoomedDiagram property. If the value is null, the tool zooms its own Diagram.

You can use this tool in a modal manner by executing:

diagram.CurrentTool = new DragZoomingTool();

Use this tool in a mode-less manner by executing:

myDiagram.ToolManager.MouseMoveTools.InsertAt(2, new DragZoomingTool());

However when used mode-lessly as a mouse-move tool, in MouseMoveTools, this cannot start running unless there has been a motionless delay after the mouse-down event of at least Delay milliseconds.

This tool does not utilize any Adornments or tool handles, but it does temporarily add the Box part to the diagram. This tool does not modify the model or conduct any transaction.

Constructors

DragZoomingTool()

Constructs a DragZoomingTool, sets Box to a magenta rectangle, and sets name of the tool.

Declaration
public DragZoomingTool()

Properties

Box

Gets or sets the Part used as the "rubber-band zoom box" that is stretched to follow the mouse, as feedback for what area will be passed to ZoomToRect(Rect) upon a mouse-up.

Declaration
public Part Box { get; set; }
Property Value
Type Description
Part
Remarks

Initially this is a Part containing only a simple magenta rectangular Shape. The object to be resized should be named "SHAPE". Setting this property does not raise any events.

Modifying this property while this tool IsActive might have no effect.

Delay

Gets or sets the TimeSpan for which the mouse must be stationary before this tool can be started.

Declaration
public TimeSpan Delay { get; set; }
Property Value
Type Description
TimeSpan
Remarks

The default value is 175 milliseconds. Setting this property does not raise any events.

ZoomedDiagram

Gets or sets the Diagram whose Position and Scale should be set to display the drawn Box rectangular bounds.

Declaration
public Diagram ZoomedDiagram { get; set; }
Property Value
Type Description
Diagram
Remarks

The default value is null, which causes ZoomToRect(Rect) to modify this tool's Diagram. Setting this property does not raise any events.

Methods

CanStart()

This tool can run when there has been a mouse-drag, far enough away not to be a click, and there has been delay of at least Delay milliseconds after the mouse-down before a mouse-move.

Declaration
public override bool CanStart()
Returns
Type Description
bool
Overrides

ComputeBoxBounds()

This just returns a Rect stretching from the mouse-down point to the current mouse point while maintaining the aspect ratio of the ZoomedDiagram.

Declaration
public Rect ComputeBoxBounds()
Returns
Type Description
Rect

a Rect in document coordinates.

DoActivate()

Capture the mouse and show the Box.

Declaration
public override void DoActivate()
Overrides

DoDeactivate()

Release the mouse and remove any Box.

Declaration
public override void DoDeactivate()
Overrides

DoMouseMove()

Update the Box's position and size according to the value of ComputeBoxBounds().

Declaration
public override void DoMouseMove()
Overrides

DoMouseUp()

Call ZoomToRect(Rect) with the value of a call to ComputeBoxBounds().

Declaration
public override void DoMouseUp()
Overrides

ZoomToRect(Rect)

This method is called to change the ZoomedDiagram's viewport to match the given rectangle.

Declaration
public void ZoomToRect(Rect r)
Parameters
Type Name Description
Rect r

a rectangular bounds in document coordinates.