Class GuidedDraggingTool

GoDiagram®
v10.0.12
by Northwoods Software®

The GuidedDraggingTool class makes guidelines visible as the parts are dragged around a diagram when the selected part is nearly aligned with another part.

Inheritance
GuidedDraggingTool
Namespace: Northwoods.Go.Tools.Extensions
Assembly: GuidedDraggingWinForms.dll
Syntax
public class GuidedDraggingTool : DraggingTool

Constructors

GuidedDraggingTool()

Constructs a GuidedDraggingTool and sets up the temporary guideline parts.

Declaration
public GuidedDraggingTool()

Properties

CenterGuidelineColor

Gets or sets the color of center guidelines.

Declaration
public string CenterGuidelineColor { get; set; }
Property Value
Type Description
string
Remarks

The default value is "gray".

GuidelineSnapDistance

Gets or sets the margin of error for which guidelines show up.

Declaration
public double GuidelineSnapDistance { get; set; }
Property Value
Type Description
double
Remarks

The default value is 6. Guidelines will show up when the aligned nodes are ± 6px away from perfect alignment.

GuidelineWidth

Gets or sets the StrokeWidth of the guidelines.

Declaration
public double GuidelineWidth { get; set; }
Property Value
Type Description
double
Remarks

The default value is 1.

HorizontalGuidelineColor

Gets or sets the color of horizontal guidelines.

Declaration
public string HorizontalGuidelineColor { get; set; }
Property Value
Type Description
string
Remarks

The default value is "gray".

IsGuidelineEnabled

Gets or sets whether the guidelines are enabled or disabled.

Declaration
public bool IsGuidelineEnabled { get; set; }
Property Value
Type Description
bool
Remarks

The default value is true.

IsGuidelineSnapEnabled

Gets or sets whether snapping to guidelines is enabled.

Declaration
public bool IsGuidelineSnapEnabled { get; set; }
Property Value
Type Description
bool
Remarks

The default value is true.

SearchDistance

Gets or sets the distance around the selected part to search for aligned parts.

Declaration
public double SearchDistance { get; set; }
Property Value
Type Description
double
Remarks

The default value is 1000. Set this to double.PositiveInfinity if you want to search the entire diagram no matter how far away.

VerticalGuidelineColor

Gets or sets the color of vertical guidelines.

Declaration
public string VerticalGuidelineColor { get; set; }
Property Value
Type Description
string
Remarks

The default value is "gray".

Methods

ClearGuidelines()

Removes all of the guidelines from the grid.

Declaration
public void ClearGuidelines()

DoDeactivate()

Calls the base method and removes the guidelines from the graph.

Declaration
public override void DoDeactivate()
Overrides

DoDragOver(Point, GraphObject)

Shows vertical and horizontal guidelines for the dragged part.

Declaration
public override void DoDragOver(Point pt, GraphObject obj)
Parameters
Type Name Description
Point pt
GraphObject obj
Overrides

DoDropOnto(Point, GraphObject)

On a mouse-up, snaps the selected part to the nearest guideline. If not snapping, the part remains at its position.

Declaration
public override void DoDropOnto(Point pt, GraphObject obj)
Parameters
Type Name Description
Point pt
GraphObject obj
Overrides

When nodes are shifted due to being guided upon a drop, make sure all connected link routes are invalidated, since the node is likely to have moved a different amount than all its connected links in the regular operation of the DraggingTool.

Declaration
public static void InvalidateLinks(Part node)
Parameters
Type Name Description
Part node

IsGuiding(Part, Part)

This predicate decides whether or not the given Part should guide the draggred part.

Declaration
protected virtual bool IsGuiding(Part part, Part guidedpart)
Parameters
Type Name Description
Part part

a stationary Part to which the dragged part might be aligned

Part guidedpart

the Part being dragged

Returns
Type Description
bool

ShowHorizontalMatches(Part, bool, bool)

This finds parts that are aligned near the selected part along horizontal lines. It compares the selected part to all parts within a rectangle approximately twice the SearchDistance wide. The guidelines appear when a part is aligned within a margin-of-error equal to GuidelineSnapDistance.

Declaration
public void ShowHorizontalMatches(Part part, bool guideline, bool snap)
Parameters
Type Name Description
Part part
bool guideline

if true, show guideline

bool snap

if true, snap the part to where the guideline would be

ShowVerticalMatches(Part, bool, bool)

This finds parts that are aligned near the selected part along vertical lines. It compares the selected part to all parts within a rectangle approximately twice the SearchDistance tall. The guidelines appear when a part is aligned within a margin-of-error equal to GuidelineSnapDistance.

Declaration
public void ShowVerticalMatches(Part part, bool guideline, bool snap)
Parameters
Type Name Description
Part part
bool guideline

if true, show guideline

bool snap

if true, don't show guidelines but just snap the part to where the guideline would be