in my app, a network diagram is being generated and displayed. The end user cannot add nor delete nodes.
We know how many layers are in the network, and so derived from GoLayoutLayeredDigraph
to assign a specific layer to a specific type of hardware (e.g., router).
Sometimes we cannot find what should fall into a layer, and so skip that node. We do however , want the link to span the missing node, and want the nodes to show in the right layer.
A <-> B <-> C
B' <-> C'
So , above has 3 layers, and 3 columns, right?
Sometimes we only know "B" and "C" , so we want the diagram to look like
B <- > C
now there are only 2 layers. Since "A" is missing.
It can get complicated, e.g., if
A <------- > C
In order to create the layers and get the right value for "MaxLayer" , I'm creating nodes and links and setting Visible to false.
However the GoDocument's TopLeftPosition now seems to be shifting.
I want the Visible nodes to always appear at Location (20, 20)
goView1.DocPosition = new PointF(20F, 20F);
How can I
a) either specify the MaxLayers for the document such that I don't have to create dummy/invisible nodes
b) tell GoDocument to ignore the invisible nodes when computing the DocPosition, such that it looks like the Visible nodes always start at
new PointF(20F, 20F);
code to create dummy nodes to set maxlayer (e.g., to 3:
GoTextNode gn = null;
GoTextNode gnPrev = null;
for (int i = 0; i < 3; i++)
gnPrev = gn;
gn = new GoTextNode();
gn.Text = "basic " + i;
gn.Visible = false; // we don't want to see it, just use it
if (gnPrev != null)
GoLabeledLink gl = new GoLabeledLink();
gl.FromPort = gnPrev.Ports.Last;
gl.ToPort = gn.Ports.First;
gl.ToArrow = true;
gl.Visible = false; // we don't want to see it, just use it
Addendum / More Info:
the GoView is being re-used, i.e., there's a selection list ,
when the selection is changed, the code calls
and reshows the GoView with the new data.
I've noticed that the Y offset problem happens after the goView has been reused one time (i.e., the goView has nodes, the nodes are cleared, then new nodes are added).