Class FreehandDrawingTool
The FreehandDrawingTool allows the user to draw a shape using the mouse.
Namespace: Northwoods.Go.Tools.Extensions
Assembly: FreehandDrawingAvalonia.dll
Syntax
public class FreehandDrawingTool : Tool
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.
Declaration
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.
Declaration
public object ArchetypePartData { get; set; }
Property Value
Type | Description |
---|---|
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.
Declaration
public bool IsBackgroundOnly { get; set; }
Property Value
Type | Description |
---|---|
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.
Declaration
public Shape TemporaryShape { get; set; }
Property Value
Type | Description |
---|---|
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.
Declaration
public void AddPoint(Point p)
Parameters
Type | Name | Description |
---|---|---|
Point | p |
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.
Declaration
public override bool CanStart()
Returns
Type | Description |
---|---|
bool |
Overrides
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.
Declaration
public override void DoActivate()
Overrides
DoDeactivate()
Release the mouse and reset the cursor.
Declaration
public override void DoDeactivate()
Overrides
DoMouseDown()
Start drawing the line by starting to accumulate points in the TemporaryShape's geometry.
Declaration
public override void DoMouseDown()
Overrides
DoMouseMove()
Keep accumulating points in the TemporaryShape's geometry.
Declaration
public override void DoMouseMove()
Overrides
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.
Declaration
public override void DoMouseUp()
Overrides
Remarks
This copies the ArchetypePartData and adds it to the model.