Class PolygonDrawingTool

GoDiagram®
v10.0.12
by Northwoods Software®

The PolygonDrawingTool class lets the user draw a new polygon or polyline shape by clicking where the corners should go.

Inheritance
PolygonDrawingTool
Namespace: Northwoods.Go.Tools.Extensions
Assembly: PolygonDrawingAvalonia.dll
Syntax
public class PolygonDrawingTool : Tool
Remarks

Right click or type ENTER to finish the operation.

Set IsPolygon to false if you want this tool to draw open unfilled polyline shapes. Set ArchetypePartData to customize the node data object that is added to the model. Data-bind to those properties in your node template to customize the appearance and behavior of the part.

This tool uses a temporary Shape, TemporaryShape, held by a Part in the "Tool" layer, to show interactively what the user is drawing.

Constructors

PolygonDrawingTool()

Constructs an PolygonDrawingTool and sets the name for the tool.

Declaration
public PolygonDrawingTool()

Properties

ArchetypePartData

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

Declaration
public object ArchetypePartData { get; set; }
Property Value
Type Description
object

HasArcs

Gets or sets whether this tool draws shapes with quadratic bezier curves for each segment, or just straight lines.

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

The default value is false -- only use straight lines.

IsGridSnapEnabled

Gets or sets whether this tool only places the shape's corners on the Diagram"s visible grid.

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

The default value is false

IsOrthoOnly

Gets or sets whether this tool draws shapes with only orthogonal segments, or segments in any direction.

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

The default value is false -- draw segments in any direction. This does not restrict the closing segment, which may not be orthogonal.

IsPolygon

Gets or sets whether this tools draws a filled polygon or an unfilled open polyline.

Declaration
public bool IsPolygon { 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

CanStart()

Don't start this tool in a mode-less fashion when the user's mouse-down is on an existing Part.

Declaration
public override bool CanStart()
Returns
Type Description
bool
Overrides
Remarks

When this tool is a mouse-down tool, it requires using the left mouse button in the background of a modifiable Diagram. Modal uses of this tool will not call this canStart predicate.

DoActivate()

Start a transaction, capture the mouse, use a "crosshair" cursor, and start accumulating points in the geometry of the TemporaryShape.

Declaration
public override void DoActivate()
Overrides

DoKeyDown()

Typing the "ENTER" key accepts the current geometry (excluding the current mouse point) and creates a new part in the model by calling FinishShape().

Typing the "Z" key causes the previous point to be discarded.

Typing the "ESCAPE" key causes the temporary Shape and its geometry to be discarded and this tool to be stopped.

Declaration
public override void DoKeyDown()
Overrides

DoMouseDown()

Add another point to the geometry of the TemporaryShape.

Declaration
public override void DoMouseDown()
Overrides

DoMouseMove()

Move the last point of the TemporaryShape's geometry to follow the mouse point.

Declaration
public override void DoMouseMove()
Overrides

DoMouseUp()

Do not stop this tool, but continue to accumulate Points via mouse-down events.

Declaration
public override void DoMouseUp()
Overrides

DoStart()

Start a transaction, capture the mouse, use a "crosshair" cursor, and start accumulating points in the geometry of the TemporaryShape.

Declaration
public override void DoStart()
Overrides

DoStop()

Stop the transaction and clean up.

Declaration
public override void DoStop()
Overrides

FinishShape()

Add a new node data object to the model and initialize the Part's position and its Shape's geometry by copying the TemporaryShape's Geometry.

Declaration
public void FinishShape()

Undo()

Undo: remove the last point and continue the drawing of new points.

Declaration
public void Undo()