Get this version of the control:
https://mindfusion.eu/download/WpfDiagram.2.6a.trial.zipThe above version adds a new mouse button action for the right mouse button - Draw. By using the following code, you will enable interactive creation of nodes and links through the right mouse button:
diagram.RightButtonActions = MouseButtonActions.Draw;
Now, in order to create new nodes on click (rather than on click & drag), you need to create a custom behavior class:
public class CustomBehavior : LinkShapesBehavior
{
public CustomBehavior(Diagram view)
: base(view)
{
}
protected override void OnMouseDown(Point mousePosition, MouseButton mouseButton)
{
if (mouseButton == MouseButton.Right)
{
var node = Diagram.GetNodeAt(mousePosition);
if (node == null)
{
Diagram.Factory.CreateShapeNode(mousePosition.X - 20, mousePosition.Y - 20, 40, 40);
Diagram.CancelDrag();
}
}
base.OnMouseDown(mousePosition, mouseButton);
}
}
To use this behavior, assign an instance of this class to the Diagram.CustomBehavior:
diagram.CustomBehavior = new CustomBehavior(diagram);
Now, new nodes should be created through right-clicking and links should be created through right-clicking and dragging. Note, that the size of the newly created nodes is hardcoded in the CustomBehavior.OnMouseDown method above.
Regards,
Meppy