I am using bunch of Composite Nodes to generate a tree layout. But when I try draw links from a node in the lower level to a node in the upper level, the links overlap the nodes.
Refer to Overlaping_Composite_Nodes.png
_RootLayout = new TreeLayout(
_RootNode,
TreeLayoutType.Cascading,
false,
TreeLayoutLinkType.Cascading2,
TreeLayoutDirections.TopToBottom,
5,
5,
true,
new SizeF(10,10));
if (_RootLayout != null)
{
_RootLayout.Arrange(Diagram);
}
Is there a way this can be avoided?
One option that prevent this behavior is Diagram.RouteAllLinks();
But if I call this method after creating and arranging the tree layout, it messes up with other links and nodes.
Refer to RouteAllLinks.png
_RootLayout = new TreeLayout(
_RootNode,
TreeLayoutType.Cascading,
false,
TreeLayoutLinkType.Cascading2,
TreeLayoutDirections.TopToBottom,
5,
5,
true,
new SizeF(10,10));
if (_RootLayout != null)
{
_RootLayout.Arrange(Diagram);
}
foreach (DiagramNode node in Diagram.Nodes)
{
Diagram.ResizeToFitItem(node);
}
//Diagram.RoutingOptions.TurnCost = 50;
//Diagram.RoutingOptions.LengthCost = 50;
//Diagram.RoutingOptions.CrossingCost = 50;
Diagram.RouteAllLinks();
As you see, I have also tried setting the RoutingOptions for TurnCost, LengthCost and CrossingCost
Code to add link:
DiagramLink link = new DiagramLink(Diagram);
link.Origin = fromNode;
link.Destination = toNode;
link.AllowMoveEnd = false;
link.AllowMoveStart = false;
link.AutoSnapToNode = true;
link.BaseShape = ArrowHeads.Circle;
link.BaseShapeSize = 2;
link.AutoRoute = false;
Diagram.Links.Add(link);
Is there a way I can achieve this without my links overlapping the nodes, and without the links being messed up.