Search
BehaviorBase.StartDraw Method
See Also
 





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

Namespace: MindFusion.Diagramming.Wpf.Behaviors
Assembly: MindFusion.Diagramming.Wpf

 Syntax

C#  Copy Code

public abstract InteractionState StartDraw (
    Point point
)

Visual Basic  Copy Code

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

 Parameters

point
A Point 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(Point point)
{
    DiagramNode node = Diagram.GetNodeAt(point, true, false);
    if (node != null)
        return new InteractionState(node, NodeAdjustmentHandle.Move, Action.Modify);
    else
        return new InteractionState(new ShapeNode(Diagram), null, Action.Create);
}
Visual Basic  Copy Code

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

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

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

End Function

 See Also