Thank you for your patience.
The Essential Diagram of V5.1 has been fully refactored to make the product more stable and maintainable. The sample available at the above link is for v126.96.36.199 samples. The other thread was referred since it discusses about a more similar issue.
Here is the more details regarding your query.
1) InsertNodesCmd Sample - Insert a node to the diagram
- The node to the diagram has to be added using the append child method. Here is the code for doing it,
Rectangle fromNode = new Rectangle(100, 100, 150, 100);
fromNode.Name = "Rectangle1";
fromNode.FillStyle.Type = FillStyleType.LinearGradient;
fromNode.FillStyle.ForeColor = Color.BlanchedAlmond;
fromNode.FillStyle.Color = Color.Orange;
fromNode.EditStyle.AllowSelect = true;
fromNode.LineStyle.LineWidth = 2;
fromNode.PinPoint = new PointF(100, 100);
2) LinkCmd Sample - Using Line connector to link different node
- The LineConnector class has to be used to connect two nodes. Here is the sample for doing it,
LineConnector connector = new LineConnector(PointF.Empty, new PointF(20, 20));
connector.HeadDecorator.DecoratorShape = DecoratorShape.FilledFancyArrow;
connector.HeadDecorator.Size = new SizeF(12, 9);
connector.HeadDecorator.FillStyle.Color = Color.DarkGray;
connector.HeadDecorator.LineStyle.LineColor = Color.DarkGray;
connector.LineStyle.LineWidth = 2;
connector.LineStyle.LineColor = Color.DarkGray;
3) Determine Addition and Deletion of Node /Addition and Deletion of Links
- The addition and deletion of nodes can be handled using the NodeCollection changed event and determining the collection changed type in it. Here is the code for doing it,
this.diagram1.Model.EventSink.NodeCollectionChanged += new CollectionExEventHandler(EventSink_NodeCollectionChanged);
void EventSink_NodeCollectionChanged(CollectionExEventArgs evtArgs)
if (evtArgs.ChangeType == CollectionExChangeType.Insert)
Node node = evtArgs.Element as Node;
Console.WriteLine("Node name:"+ node.Name);
Here is a sample demonstrating all the above,
Kindly take a look and let me know if you need any further assistance.