Table of Contents

Class FreehandDrawingTool

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

The FreehandDrawingTool allows the user to draw a shape using the mouse.

public class FreehandDrawingTool : Tool
Inheritance
FreehandDrawingTool
Inherited Members

Remarks

This tool collects all of the points from a mouse-down, all mouse-moves, until a mouse-up, and puts all of those points in a Geometry used by a Shape. It then adds a node data object to the diagram's model.

This tool may be installed as the first mouse down tool:

myDiagram.ToolManager.MouseDownTools.InsertAt(0, new FreehandDrawingTool());

The Shape used during the drawing operation can be customized by setting TemporaryShape. The node data added to the model can be customized by setting ArchetypePartData.

Constructors

FreehandDrawingTool()

Constructs a FreehandDrawingTool.

public FreehandDrawingTool()

Properties

ArchetypePartData

Gets or sets the node data object that is copied and added to the model when the freehand drawing operation completes.

public object ArchetypePartData { get; set; }

Property Value

object

IsBackgroundOnly

Gets or sets whether this tool can only run if the user starts in the diagram's background rather than on top of an existing Part.

public bool IsBackgroundOnly { get; set; }

Property Value

bool

Remarks

The default value is true.

TemporaryShape

Gets or sets the Shape that is used to hold the line as it is being drawn.

public Shape TemporaryShape { get; set; }

Property Value

Shape

Remarks

The default value is a simple Shape drawing an unfilled open thin black line.

Methods

AddPoint(Point)

This adds a Point to the TemporaryShape's geometry.

public void AddPoint(Point p)

Parameters

p Point

Remarks

If the Shape is not yet in the Diagram, its geometry is initialized and its parent Part is added to the Diagram.

If the point is less than half a pixel away from the previous point, it is ignored.

CanStart()

Only start if the diagram is modifiable and allows insertions.

public override bool CanStart()

Returns

bool

Remarks

OPTIONAL: if the user is starting in the diagram's background, not over an existing Part.

DoActivate()

Capture the mouse and use a "crosshair" cursor.

public override void DoActivate()

DoDeactivate()

Release the mouse and reset the cursor.

public override void DoDeactivate()

DoMouseDown()

Start drawing the line by starting to accumulate points in the TemporaryShape's geometry.

public override void DoMouseDown()

DoMouseMove()

Keep accumulating points in the TemporaryShape's geometry.

public override void DoMouseMove()

DoMouseUp()

Finish drawing the line by adding a node data object holding the geometry string and the node position that the node template can bind to.

public override void DoMouseUp()

Remarks

This copies the ArchetypePartData and adds it to the model.