Hi,
I have attached 2 screenshots.
One is the actual diagram that is rendered (with the red arrow and textbox); the other is how we'd like it to look.
The main concern is the placement of the start shape (the solid circle).
Any suggestions on how we might be able to locate this symbol as indicated?
I have also included the relevant C# code below.
Thanks
Jim
case "Orthogonal":
{
OrthogonalLayout layout = new OrthogonalLayout();
layout.Padding = 25;
layout.Arrange(diagram);
OrthogonalRouter layout2 = new OrthogonalRouter();
layout2.Arrange(diagram);
MirrorVertically(diagram); // Increase the likelihood of the start shape being at the top of the diagram
setLinksToSingleSegment(diagram); // Make the text on the links be center'd
fixSelfLoopBackLinks(diagram); // Draws a more attractive (bezier curve)
break;
}
protected void MirrorVertically(Diagram diagram)
{
// Adapted from code provided by MF
var bounds = diagram.GetContentBounds(false, true);
var y = bounds.Y + bounds.Height / 2;
foreach (DiagramNode node in diagram.Nodes)
{
var ny = node.GetCenter().Y;
var dy = ny - y;
MoveNode(node, y - dy);
}
foreach (DiagramLink link in diagram.Links)
{
for (int i = 0; i < link.ControlPoints.Count; i++)
{
var p = link.ControlPoints[i];
var dy = p.Y - y;
p.Y = y - dy;
link.ControlPoints[i] = p;
}
link.UpdateFromPoints(false, false);
}
diagram.Invalidate();
}
protected void MoveNode(DiagramNode node, float newY)
{
var bounds = node.Bounds;
bounds.Y = newY - bounds.Height / 2;
node.SetBounds(bounds, false, false);
}
protected void setLinksToSingleSegment(Diagram diagram)
{
foreach (DiagramLink link in diagram.Links)
{
// If the link is vertical (all X coordinates the same) then reduce the # of segments to 1
// This will ensure that the Rotate LinkTextStyle and StringAlignment.Center work properly
// Adapted from code provided by MF
if (link.SegmentCount == 3 && link.ControlPoints[0].X == link.ControlPoints[1].X && link.ControlPoints[1].X == link.ControlPoints[2].X && link.ControlPoints[2].X == link.ControlPoints[3].X)
{
var p1 = link.ControlPoints[0];
var p2 = link.ControlPoints[3];
link.Style = LinkStyle.Polyline;
//link.Shape = LinkShape.Polyline; // NetDiagram V5
link.SegmentCount = 1;
link.ControlPoints[0] = p1;
link.ControlPoints[1] = p2;
link.UpdateFromPoints();
}
// If the link is horizontal (all Y coordinates the same) then reduce the # of segments to 1
// This will ensure that the Rotate LinkTextStyle and StringAlignment.Center work properly
if (link.SegmentCount == 3 && link.ControlPoints[0].Y == link.ControlPoints[1].Y && link.ControlPoints[1].Y == link.ControlPoints[2].Y && link.ControlPoints[2].Y == link.ControlPoints[3].Y)
{
var p1 = link.ControlPoints[0];
var p2 = link.ControlPoints[3];
link.Style = LinkStyle.Polyline;
//link.Shape = LinkShape.Polyline; // NetDiagram V5
link.SegmentCount = 1;
link.ControlPoints[0] = p1;
link.ControlPoints[1] = p2;
link.UpdateFromPoints();
}
}
}
protected void fixSelfLoopBackLinks(Diagram diagram)
{
foreach (DiagramLink link in diagram.Links)
{
if (link.Origin == link.Destination) // Is this a loop back to the same state?
{
RectangleF r = link.Origin.Bounds;
float centerx = r.Left + r.Width / 2;
float dist = 16;
SetLinkPoints(link,
new PointF(centerx, r.Top),
new PointF(centerx - dist, r.Top - dist),
new PointF(centerx + dist, r.Top - dist),
new PointF(centerx, r.Top));
}
}
}