Table of Contents

Class RescalingTool

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

A custom tool for rescaling an object.

public class RescalingTool : Tool
Inheritance
RescalingTool
Inherited Members

Remarks

Install the RescalingTool as a mouse-down tool by calling:

myDiagram.ToolManager.MouseDownTools.Add(new RescalingTool());

Normally it would not make sense for the same object to be both resizable and rescalable.

Note that there is no Part.RescaleElementName property and there is no Part.Rescalable property. So although you cannot customize any Node to affect this tool, you can set RescaleElementName and set IsEnabled to control whether objects are rescalable and when.

Constructors

RescalingTool()

Constructs a RescalingTool.

public RescalingTool()

Properties

AdornedElement

Gets the GraphObject that is being rescaled.

public GraphObject AdornedElement { get; set; }

Property Value

GraphObject

Remarks

This may be the same object as the selected Part or it may be contained within that Part.

This property is also settable, but should only be set when overriding functions in RescalingTool, and not during normal operation.

Handle

This property returns the GraphObject that is the tool handle being dragged by the user.

public GraphObject Handle { get; set; }

Property Value

GraphObject

Remarks

This will be contained by an Adornment whose category is "RescalingTool". Its AdornedElement is the same as the AdornedElement.

This property is also settable, but should only be set either within an override of DoActivate() or prior to calling DoActivate().

HandleArchetype

Gets or sets a small GraphObject that is copied as a rescale handle for the selected part.

public Shape HandleArchetype { get; set; }

Property Value

Shape

Remarks

By default this is a Shape that is a small blue square. Setting this property does not raise any events.

Here is an example of changing the default handle to be green "X":

tool.HandleArchetype =
  new Shape("XLine")
    { Width = 8, Height = 8, Stroke = "green", Fill = "transparent" };

RescaleElementName

This property returns the name of the GraphObject that identifies the object to be rescaled by this tool.

public string RescaleElementName { get; set; }

Property Value

string

Remarks

The default value is the empty string, resulting in the whole Node being rescaled. This property is used by FindRescaleElement when calling FindElement(string).

Methods

CanStart()

This tool can start running if the mouse-down happens on a "Rescaling" handle.

public override bool CanStart()

Returns

bool

ComputeScale(Point)

Compute the new scale given a point.

public double ComputeScale(Point newPoint)

Parameters

newPoint Point

Returns

double

Remarks

This method is called by both DoMouseMove() and DoMouseUp(). This method may be overridden. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

DoActivate()

Activating this tool remembers the Handle that was dragged, the AdornedElement that is being rescaled, starts a transaction, and captures the mouse.

public override void DoActivate()

DoCancel()

Restore the original Scale of the adorned object.

public override void DoCancel()

DoDeactivate()

Stop the current transaction, forget the Handle and AdornedElement, and release the mouse.

public override void DoDeactivate()

DoMouseMove()

Call Scale(double) with a new scale determined by the current mouse point. This determines the new scale by calling ComputeScale(Point).

public override void DoMouseMove()

DoMouseUp()

Call Scale(double) with a new scale determined by the most recent mouse point, and commit the transaction.

public override void DoMouseUp()

FindRescaleElement(Part)

Return the GraphObject to be rescaled by the user.

public GraphObject FindRescaleElement(Part part)

Parameters

part Part

Returns

GraphObject

Scale(double)

public void Scale(double newScale)

Parameters

newScale double

UpdateAdornments(Part)

The diagram asks each tool to update any adornments the tool might use for a given part.

public override void UpdateAdornments(Part part)

Parameters

part Part

Remarks

If the tool uses its own tool handles, this should display them or hide them as appropriate. Typically this should only show them if the part is selected.

By default this method does nothing.

This method may be overridden. Please read the Introduction page on Extensions for how to override methods and how to call this base method.