GoDocument serialization/deserialization

I have a custom XML Serialization/deserialization for GoDocument objects (and contents of course).

Some times, some parts of nodes (node labels and ports labels) are not in correct position after deserialization (relative to left/top of document instead of relative to left/top of node).

I suspect some position/size problems, but hard to find…

I do not serialize all document’s properties (only Size and TopLeft).

Some idea ?


Perhaps the effect of intermediate calls to GoGroup.LayoutChildren during the reconstruction of your nodes is causing some child objects to be (re-)positioned.
You might want to set GoObject.Initializing to true during the construction of each node, since by convention LayoutChildren is normally a no-op when Initializing is true.
Another way of dealing with this same problem is that perhaps you shouldn’t be saving the Position and/or Size of each node, but its Location and/or SelectionObject.Size. The reason is that many nodes have a particular object around which all the other sibling objects get positioned and/or sized. For example, several of the predefined node classes have an Icon property or a Background property referring to a child object that is the “main” child. Often the GoObject.SelectionObject is this child, rather than just being the object (i.e. group/node) itself.

Thanks Walter!

The “Position + SelectionObject.Size” do the job!

Thanks again for top service!