Table of Contents

Class PortShiftingTool

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

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

public class PortShiftingTool : Tool
Inheritance
PortShiftingTool
Inherited Members

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.

public PortShiftingTool()

Fields

Port

The port being shifted.

public GraphObject Port

Field Value

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

public override bool CanStart()

Returns

bool

DoActivate()

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

public override void DoActivate()

DoCancel()

Restore the port's original value for Alignment.

public override void DoCancel()

DoDeactivate()

Stop any ongoing transaction.

public override void DoDeactivate()

DoMouseMove()

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

public override void DoMouseMove()

DoMouseUp()

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

public override void DoMouseUp()

DoStop()

Clear any reference to a port element.

public override void DoStop()

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

public GraphObject FindPort()

Returns

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.

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.