Table of Contents

Class GuidedDraggingTool

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

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

public class GuidedDraggingTool : DraggingTool
Inheritance
GuidedDraggingTool
Inherited Members

Constructors

GuidedDraggingTool()

Constructs a GuidedDraggingTool and sets up the temporary guideline parts.

public GuidedDraggingTool()

Properties

CenterGuidelineColor

Gets or sets the color of center guidelines.

public string CenterGuidelineColor { get; set; }

Property Value

string

Remarks

The default value is "gray".

GuidelineSnapDistance

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

public double GuidelineSnapDistance { get; set; }

Property Value

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.

public double GuidelineWidth { get; set; }

Property Value

double

Remarks

The default value is 1.

HorizontalGuidelineColor

Gets or sets the color of horizontal guidelines.

public string HorizontalGuidelineColor { get; set; }

Property Value

string

Remarks

The default value is "gray".

IsGuidelineEnabled

Gets or sets whether the guidelines are enabled or disabled.

public bool IsGuidelineEnabled { get; set; }

Property Value

bool

Remarks

The default value is true.

IsGuidelineSnapEnabled

Gets or sets whether snapping to guidelines is enabled.

public bool IsGuidelineSnapEnabled { get; set; }

Property Value

bool

Remarks

The default value is true.

SearchDistance

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

public double SearchDistance { get; set; }

Property Value

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.

public string VerticalGuidelineColor { get; set; }

Property Value

string

Remarks

The default value is "gray".

Methods

ClearGuidelines()

Removes all of the guidelines from the grid.

public void ClearGuidelines()

DoDeactivate()

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

public override void DoDeactivate()

DoDragOver(Point, GraphObject)

Shows vertical and horizontal guidelines for the dragged part.

public override void DoDragOver(Point pt, GraphObject obj)

Parameters

pt Point
obj GraphObject

DoDropOnto(Point, GraphObject)

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

public override void DoDropOnto(Point pt, GraphObject obj)

Parameters

pt Point
obj GraphObject

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.

public static void InvalidateLinks(Part node)

Parameters

node Part

IsGuiding(Part, Part)

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

protected virtual bool IsGuiding(Part part, Part guidedpart)

Parameters

part Part

a stationary Part to which the dragged part might be aligned

guidedpart Part

the Part being dragged

Returns

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.

public void ShowHorizontalMatches(Part part, bool guideline, bool snap)

Parameters

part Part
guideline bool

if true, show guideline

snap bool

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.

public void ShowVerticalMatches(Part part, bool guideline, bool snap)

Parameters

part Part
guideline bool

if true, show guideline

snap bool

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