Hi everyone! I was wondering if someone can help me figure out how to save the current exact position of the Diagram that is manipulated after user intervention. Just the way the nodes and links are positioned on the diagram. I stored my diagrams in a SQL backend, and I have an autolayout arranging the graph for me. Any help to get me on the right track would be appreciated. Thanks!
For each node I suggest you save the .SelectionObject.Position (two floating point numbers).
OoOooo thanks Walter I’ll try using those properties on each node, and hmmm I’ll play with the links also. Would that also help me save the shape of the link if my users added a point to the link itself to move it?
I tried saving and setting the X and Y axis of the node but I get this on compile-time
“Cannot modify the return value of ‘Northwoods.Go.GoObject.Position’ because it is not a variable” on this code
node.SelectionObject.Position.X = (float)row["Xaxis"];
node.SelectionObject.Position.Y = (float)row["Yaxis"];
I am trying to set my values before it is drawn to the GoDocument. I also have my own Node Class that extends the GoBasicNode object.
That’s because Position is a PointF, which is a structure passed by value, not a class passed by reference.
OOoo I figured out what I’m doing wrong
PointF pos = new PointF((float)row["Xaxis"], (float)row["Yaxis"]);
node.SelectionObject.Position = pos;
That seems to work for me now.
Oo just saw your post too thanks Walter!
Hey Walter! The problem I’m having now, is trying to find all the Nodes on the goView object so I can save their positions. Is there a method where I can get a collection of objects from the goView and then pick out the nodes and save the positions from those nodes?
This is discussed in the User Guide, in the section “Traversing a Diagram”.
Woohoo!
foreach (GoObject obj in this.goView1.Document)
{
MatterNode n = obj as MatterNode;
if (n != null)
{
}
}
That totally works thanks Walter!
Also FYI to anyone that is trying to write those crazy X,Y positions to a DB in Microsoft SQL the Datatype you want for your X and Y column is real not float.