Class RescalingTool

GoDiagram®
v10.0.12
by Northwoods Software®

A custom tool for rescaling an object.

Inheritance
RescalingTool
Namespace: Northwoods.Go.Tools.Extensions
Assembly: RescalingWinForms.dll
Syntax
public class RescalingTool : Tool
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.

Declaration
public RescalingTool()

Properties

AdornedElement

Gets the GraphObject that is being rescaled.

Declaration
public GraphObject AdornedElement { get; set; }
Property Value
Type Description
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.

Declaration
public GraphObject Handle { get; set; }
Property Value
Type Description
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.

Declaration
public Shape HandleArchetype { get; set; }
Property Value
Type Description
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.

Declaration
public string RescaleElementName { get; set; }
Property Value
Type Description
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.

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

ComputeScale(Point)

Compute the new scale given a point.

Declaration
public double ComputeScale(Point newPoint)
Parameters
Type Name Description
Point newPoint
Returns
Type Description
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.

Declaration
public override void DoActivate()
Overrides

DoCancel()

Restore the original Scale of the adorned object.

Declaration
public override void DoCancel()
Overrides

DoDeactivate()

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

Declaration
public override void DoDeactivate()
Overrides

DoMouseMove()

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

Declaration
public override void DoMouseMove()
Overrides

DoMouseUp()

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

Declaration
public override void DoMouseUp()
Overrides

FindRescaleElement(Part)

Return the GraphObject to be rescaled by the user.

Declaration
public GraphObject FindRescaleElement(Part part)
Parameters
Type Name Description
Part part
Returns
Type Description
GraphObject

Scale(double)

Declaration
public void Scale(double newScale)
Parameters
Type Name Description
double newScale

UpdateAdornments(Part)

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

Declaration
public override void UpdateAdornments(Part part)
Parameters
Type Name Description
Part part
Overrides
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.