Class ClickCreatingTool

GoDiagram®
v10.0.8
by Northwoods Software®

The ClickCreatingTool lets the user create a node by clicking where they want the new node to be. By default a double-click is required to start this tool; set IsDoubleClick to false if you want a single-click to create a node.

Inheritance
ClickCreatingTool
Namespace: Northwoods.Go.Tools
Assembly: Northwoods.GoDiagram.WinForms.dll
Syntax
public class ClickCreatingTool : Tool
Remarks

This tool is a standard mouse-up tool, the ClickCreatingTool. However, it will not be able to start running unless you have set the ArchetypeNodeData property to an object that can be copied and added to the diagram's model.

If you set IsGridSnapEnabled to true, newly created parts will be snapped to points on a grid.

This tool does not utilize any Adornments or tool handles. This tool does conduct a transaction when inserting the new node.

If you want to programmatically create a Part, you can call InsertPart(Point).

Constructors

ClickCreatingTool()

You do not normally need to create an instance of this tool because one already exists as the ClickCreatingTool, which you can modify.

The Name of this tool is "ClickCreating".

Declaration
public ClickCreatingTool()

Properties

ArchetypeNodeData

Gets or sets a data object that will be copied and added to the diagram's model each time this tool executes.

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

The default value is null. The value must be non-null for this tool to be able to run. Setting this property does not raise any events.

IsDoubleClick

Gets or sets whether a double click rather than a single-click is required to insert a new Part at the mouse-up point.

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

The default value is true -- only a double-click will cause a node to be created. Setting this property does not raise any events.

IsGridSnapEnabled

Gets or sets whether the ClickCreatingTool snaps object sizes to the diagram's background grid during creation.

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

By default this property is false. Setting this property does not raise any events.

Methods

CanStart()

This tool can run when the diagram is not read-only and supports creating new nodes, and when there has been a click (or double-click if IsDoubleClick is true) in the background of the diagram (not on a Part), and ArchetypeNodeData is an object that can be copied and added to the model.

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

This method may be overridden. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

DoMouseUp()

Upon a click, call InsertPart(Point) and stop this tool.

Declaration
public override void DoMouseUp()
Overrides

InsertPart(Point)

Create a node by adding a copy of the ArchetypeNodeData object to the diagram's model, assign its Location to be the given point, and select the new part.

Declaration
public virtual Part InsertPart(Point loc)
Parameters
Type Name Description
Point loc

a Point in document coordinates.

Returns
Type Description
Part

the newly created Part, or null if it failed.

Remarks

This starts and commits a transaction and also raises the "PartCreated" DiagramEvent. The actual part that is added to the diagram may be a Part, a Node, or even a Group, depending on the properties of the ArchetypeNodeData and the type of the template that is copied to create the part.

This method also raises the "ChangingSelection" and "ChangedSelection" diagram events outside the transaction.

This method may be overridden, although it is usually much easier to just set ArchetypeNodeData. Please read the Introduction page on Extensions for how to override methods and how to call this base method.