Search
BehaviorBase.StartDraw Method
See Also
 





Invoked when a user presses the left mouse button inside the diagram drawing area.

Namespace: MindFusion.Diagramming.WinForms.Behaviors
Assembly: MindFusion.Diagramming.WinForms

 Syntax

C#  Copy Code

public abstract InteractionState StartDraw (
    PointF point
)

Visual Basic  Copy Code

Public MustOverride Function StartDraw( _
    point As PointF _
) As InteractionState

 Parameters

point
A PointF structure, which specifies the current position of the mouse cursor, in document coordinates.

 Return Value

An instance of the InteractionState class, which specifies whether dragging the mouse should create or modify an item.

 Remarks

To start creating an item, pass a new instance of a DiagramItem derived class to the InteractionState constructor and set the constructor's action argument to Action.Create. Do not use methods such as Nodes.Add or CreateShapeNode to add the new item to the diagram; the item will be added automatically when the user completes drawing it. If creating a link, use the DiagramLink constructor that takes a single DiagramNode argument, specifying the origin node.

To start modifying an item, provide a reference to an existing item as argument of the InteractionState constructor and set the action argument to Action.Modify.

 Example

This StartDraw implementation allows only moving existing nodes or creating new nodes using the mouse:

C#  Copy Code

public override InteractionState StartDraw(PointF point)
{
    DiagramNode node = Diagram.GetNodeAt(point, true, false);
    if (node != null)
        return new InteractionState(node, 8, Action.Modify);
    else
        return new InteractionState(new ShapeNode(Diagram), -1, Action.Create);
}

Visual Basic  Copy Code

Public Overrides Function StartDraw(ByVal point As PointF) As InteractionState

    Dim node As DiagramNode = Diagram.GetNodeAt(point, True, False)

    If Not node Is Nothing Then
        Return New InteractionState(node, 8, Action.Modify)
    Else
        Return New InteractionState(New ShapeNode(Diagram), -1, Action.Create)
    End If

End Function

 See Also