Table of Contents

Class DragZoomingTool

Namespace
Northwoods.Go.Tools.Extensions
Assembly
DragZoomingWinForms.dll

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.

public class DragZoomingTool : Tool
Inheritance
DragZoomingTool
Inherited Members

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.

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.

public Part Box { get; set; }

Property Value

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.

public TimeSpan Delay { get; set; }

Property Value

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.

public Diagram ZoomedDiagram { get; set; }

Property Value

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.

public override bool CanStart()

Returns

bool

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.

public Rect ComputeBoxBounds()

Returns

Rect

a Rect in document coordinates.

DoActivate()

Capture the mouse and show the Box.

public override void DoActivate()

DoDeactivate()

Release the mouse and remove any Box.

public override void DoDeactivate()

DoMouseMove()

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

public override void DoMouseMove()

DoMouseUp()

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

public override void DoMouseUp()

ZoomToRect(Rect)

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

public void ZoomToRect(Rect r)

Parameters

r Rect

a rectangular bounds in document coordinates.