Is there a sample that shows you how to save the shapes when you modify the basiclayoutnode from the standard default circle to say a 200,100 circle, or when each node is a custom size? I’m trying to save and load documents, but when I do all of the size settings for the nodes are lost. I am customizing each node to a unique size to create a chart with a unique size for each node. So when I save it, I have to know the size to reload. So I’m looking for a sample that shows this.
Basically, you have to store something into the XML that is going to result in the same call you make in your code to “set” the size when the node is restored.
So, you mentioned BasicLayoutNode, from LayoutDemo. There are a couple of things you need to do:
In InitReaderWriter, add this line:
t.AddBinding(“size”, “Ellipse.Size”); // new line
which should be enough… but LayoutDemo has some code in BasicLayoutNode.LayoutChildren to change the ellipse size based on the number of ports… which sets the size back to the default. Unless the number of ports or the setting of “Horizontal” changes for the node, I think you can just comment out that code… thus:
//SizeF temp1; //with every layout, resize the ellipse.
// temp1 = new SizeF((myStdSize / 2) * (myPorts.Count + 1), myStdSize);
// temp1 = new SizeF(myStdSize, (myStdSize / 2) * (myPorts.Count + 1));
//myEllipse.Size = temp1;
so… the xml file now looks like:
(I saved the file and edited the size values by hand to simulate what you’re doing in code.) the graph looks like this when opened:
Thanks for information. That makes complete sense.
Yes, XML element (and attribute) names are case-sensitive.