Class LinkReshapingTool

GoDiagram®
v10.0.12
by Northwoods Software®

The LinkReshapingTool is used to interactively change the route of a Link by setting its Points list. You may want to save the route to the model by using a TwoWay Binding on the "Points" property of the Link.

Namespace: Northwoods.Go.Tools
Assembly: Northwoods.GoDiagram.Avalonia.dll
Syntax
public class LinkReshapingTool : Tool
Remarks

This tool makes use of an Adornment, shown when the adorned Link is selected, that includes some number of reshape handles. This tool conducts a transaction while the tool is active. A successful reshaping will result in a "LinkReshaped" DiagramEvent and a "LinkReshaping" transaction.

For a general discussion of link routing, see: Introduction to Links, Introduction to Link Labels, and Introduction to Link Connection Points. For customizing the linking tools, see Introduction to the Linking Tools. For a general discussion of validation, see Introduction to Validation.

Constructors

LinkReshapingTool()

You do not normally need to create an instance of this tool because one already exists as the LinkReshapingTool, which you can modify.

The Name of this tool is "LinkReshaping".

Declaration
public LinkReshapingTool()

Properties

This read-only property returns the Link that is being routed manually.

Declaration
public Link AdornedLink { get; }
Property Value
Type Description
Link

Handle

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 "LinkReshaping". Its AdornedPart is the same as the AdornedLink. This is normally set by DoActivate(), remembering the result of the call to FindToolHandleAt(Point, string).

HandleArchetype

Gets or sets a small GraphObject that is copied as a reshape handle at each movable point in the selected link's route.

Declaration
public GraphObject HandleArchetype { get; set; }
Property Value
Type Description
GraphObject
Remarks

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

Here is an example of changing the default handles to be larger yellow circles:

myDiagram.ToolManager.LinkReshapingTool.HandleArchetype =
  new Shape("Circle") { Width = 10, Height = 10, Fill = "yellow" };
See Also

MidHandleArchetype

Gets or sets a small GraphObject that is copied as a resegment handle at each mid-point in the selected Link's route.

Declaration
public GraphObject MidHandleArchetype { get; set; }
Property Value
Type Description
GraphObject
Remarks

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

Here is an example of changing the default handle to be larger cyan triangles:

myDiagram.ToolManager.LinkReshapingTool.MidHandleArchetype =
  new Shape("Triangle") { Width = 10, Height = 10, Fill = "cyan" };
See Also

OriginalPoint

This read-only property returns the Point that was the original location of the handle that is being dragged to reshape the Link.

Declaration
public Point? OriginalPoint { get; }
Property Value
Type Description
Point?
Remarks

This value is null if the tool hasn't activated or the handle's location didn't correspond with a value from Points.

OriginalPoints

This read-only property returns the read-only collection of Points that was the original route of the Link that is being reshaped.

Declaration
public IReadOnlyCollection<Point> OriginalPoints { get; }
Property Value
Type Description
IReadOnlyCollection<Point>
Remarks

This List should not be modified; its value is indeterminate until a reshaping has been activated.

Methods

CanStart()

This tool may run when there is a mouse-down event on a reshape handle.

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

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

ComputeReshape(Point)

This is called by DoMouseMove() and DoMouseUp() to limit the input point before calling Reshape(Point).

Declaration
public virtual Point ComputeReshape(Point p)
Parameters
Type Name Description
Point p

the point where the handle is being dragged.

Returns
Type Description
Point

Either the same Point p or one constrained by the reshape behavior to be moved only vertically or only horizontally.

Remarks

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()

Start reshaping, if FindToolHandleAt(Point, string) finds a reshape handle at the mouse down point.

Declaration
public override void DoActivate()
Overrides
Remarks

If successful this sets Handle to be the reshape handle that it finds and AdornedLink to be the Link being routed. It also remembers the original link route (a list of Points) in case this tool is cancelled. And it starts a transaction.

DoCancel()

Restore the link route to be the original points and stop this tool.

Declaration
public override void DoCancel()
Overrides

DoDeactivate()

This stops the current reshaping operation with the link route shaped the way it is.

Declaration
public override void DoDeactivate()
Overrides

DoMouseMove()

Call Reshape(Point) with a new point determined by the mouse to change the route of the AdornedLink.

Declaration
public override void DoMouseMove()
Overrides

DoMouseUp()

Reshape the route with a point based on the most recent mouse point by calling Reshape(Point), and then raise a "LinkReshaped" DiagramEvent before stopping this tool.

Declaration
public override void DoMouseUp()
Overrides

GetReshapingBehavior(GraphObject)

Get the permitted reshaping behavior for a particular reshape handle.

Declaration
protected ReshapingBehavior GetReshapingBehavior(GraphObject obj)
Parameters
Type Name Description
GraphObject obj

a reshape handle in the "LinkReshaping" Adornment.

Returns
Type Description
ReshapingBehavior

one of ReshapingBehavior.All, .Vertical, .Horizontal, or .None

Reshape(Point)

Change the route of the AdornedLink by moving the point corresponding to the current Handle to be at the given Point.

Declaration
public virtual void Reshape(Point newPoint)
Parameters
Type Name Description
Point newPoint

the value of the call to ComputeReshape(Point).

Remarks

This is called by DoMouseMove() and DoMouseUp() with the result of calling ComputeReshape(Point) to constrain the input point.

This method respects the orthogonality of the link, if necessary limiting movement along only one axis. To maintain orthogonality it may need to modify more than one point in the route.

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

SetReshapingBehavior(GraphObject, ReshapingBehavior)

Set the permitted reshaping behavior for a particular reshape handle.

Declaration
protected void SetReshapingBehavior(GraphObject obj, ReshapingBehavior behavior)
Parameters
Type Name Description
GraphObject obj

a reshape handle in the "LinkReshaping" Adornment.

ReshapingBehavior behavior

one of ReshapingBehavior.All, .Vertical, .Horizontal, or .None

StopTransaction()

This calls the base StopTransaction() method, and if the result is true, attempts to optimize the transaction by removing all changes except the first and last by calling Optimize().

Declaration
public override bool StopTransaction()
Returns
Type Description
bool

the result of the call to rollback or commit the transaction.

Overrides
Remarks

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

UpdateAdornments(Part)

Show an Adornment with reshape handles at each of the interesting points of the link's route, if the link is selected and visible and if CanReshape() is true.

Declaration
public override void UpdateAdornments(Part part)
Parameters
Type Name Description
Part part
Overrides
Remarks

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