Like this:
private bool _createLinkNode(string linkText, Color linkTextColor, string nodeTag, DiagramNode org, DiagramNode dest){
....
DiagramLink link = diagram.Factory.CreateDiagramLink(org, dest);
...
}
But I just resolved it... don't know why, but this works:
private bool _createLinkNode(string linkText, Color linkTextColor, string nodeTag, DiagramNode org, DiagramNode dest){
....
DiagramLink link = diagram.Factory.CreateDiagramLink(diagram.GetNodeAt(org.Bounds.Location), diagram.GetNodeAt(dest.Bounds.Location));
....
}
But now I have sequel problem related to this.
Now on diagram arrange all nodes vanishes (only in case when a link is created || one or more)....
Also noticed that Diagram Bounds are messed because of this... default: (0,0, 2000, 1500)... after link creation + diagram_arrange (-23.3, -46.5, 2158, 1532). (note: this number is random, but mainly X & Y goes minus)....
DiagramItemCollection childNodes = null;
LayeredLayout ll = null;
/* FROM HERE */
/* ** will arrange nodes in containers ** */
// get nodes collection in diagram
foreach (DiagramItem di in diagram.Nodes){
Type t = di.GetType();
// find node type "ContainerNode"
if (t.Name.ToUpper() == "CONTAINERNODE"){
// get all nodes in container nodes and set them to a node collection to be arranged.
ContainerNode cn = di as ContainerNode;
if (cn.SubordinateGroup != null){
childNodes = new DiagramItemCollection();
foreach (DiagramNode childNode in cn.SubordinateGroup.AttachedNodes){
childNodes.Add(childNode);
foreach (DiagramLink link in childNode.OutgoingLinks)
childNodes.Add(link);
}
ll = new LayeredLayout();
ll.LayerDistance = 50;
ll.NodeDistance = 60;
ll.Orientation = MindFusion.Diagramming.Layout.Orientation.Horizontal;
ll.Arrange(diagram, childNodes);
cn.UpdateBounds(true);
}
}
}
/* TO HERE */
ll = new LayeredLayout();
ll.LayerDistance = 50;
ll.NodeDistance = 100;
ll.SplitLayers = true;
ll.Orientation = MindFusion.Diagramming.Layout.Orientation.Horizontal;
ll.Arrange(diagram);
// ======================
public Diagram diagram
{
get { return Session["diagram"] as Diagram; }
set { Session["diagram"] = value; }
}