Class PortShiftingTool

GoDiagram®
v10.0.11
by Northwoods Software®

The PortShiftingTool class lets a user move a port on a Node.

Inheritance
PortShiftingTool
Namespace: Northwoods.Go.Tools.Extensions
Assembly: PortShiftingWinForms.dll
Syntax
public class PortShiftingTool : Tool
Remarks

This tool only works when the Node has a port (any GraphObject) marked with a non-null and non-empty PortId that is positioned in a Spot Panel, and the user holds down the Shift key. It works by modifying that port's Alignment property.

Constructors

PortShiftingTool()

Constructs a PortShiftingTool and sets the name for the tool.

Declaration
public PortShiftingTool()

Fields

Port

The port being shifted.

Declaration
public GraphObject Port
Field Value
Type Description
GraphObject

Methods

CanStart()

This tool can only start if the mouse has moved enough so that it is not a click, and if the mouse down point is on a GraphObject "port" in a Spot Panel, as determined by FindPort().

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

DoActivate()

Start a transaction, call FindPort() and remember it as the "Port" property, and remember the original value for the port"s Alignment property.

Declaration
public override void DoActivate()
Overrides

DoCancel()

Restore the port's original value for Alignment.

Declaration
public override void DoCancel()
Overrides

DoDeactivate()

Stop any ongoing transaction.

Declaration
public override void DoDeactivate()
Overrides

DoMouseMove()

During the drag, call UpdateAlignment() in order to set the Alignment of the port.

Declaration
public override void DoMouseMove()
Overrides

DoMouseUp()

At the end of the drag, update the alignment of the port and finish the tool, completing a transaction.

Declaration
public override void DoMouseUp()
Overrides

DoStop()

Clear any reference to a port element.

Declaration
public override void DoStop()
Overrides

FindPort()

From the GraphObject at the mouse point, search up the visual tree until we get to an object that has the PortId property set to a non-empty string, that is in a Spot Panel, and that is not the main element of the panel (typically the first element).

Declaration
public GraphObject FindPort()
Returns
Type Description
GraphObject

This returns null if no such port is at the mouse down point.

UpdateAlignment()

Save the port's Alignment as a fractional Spot in the Spot Panel that the port is in.

Declaration
public void UpdateAlignment()
Remarks

If the main element changes size, the relative positions of the ports will be maintained. But that does assume that the port must remain inside the main element -- it cannot wander away from the node. This does not modify the port's AlignmentFocus property.