GoBasic Node’s store … … writer.WriteAttributeString(“w”, XmlConvert.ToString(c.Width)); writer.WriteAttributeString(“h”, XmlConvert.ToString(c.Height));
Load
float w = 0; a = item.Attributes[“w”]; if (a != null) w = XmlConvert.ToSingle(a.Value); n.Width = w;
float h = 0; a = item.Attributes[“h”]; if (a != null) h = XmlConvert.ToSingle(a.Value); n.Height = h;
n.Size = new SizeF(w, h);
==> Problem
Load object’s Height change…
i can reSizeble is true, scale change… save
after Loading
Weight is ok Height is change…
Yes, that was the obvious problem, but there’s a more subtle one as well–you probably want to set both Width and Height at the same time by setting the Size to new SizeF(w, h). The reason is that setting one dimension may cause the other dimension to change.
And sometimes you don’t want the object’s Location to change, when the Location is defined differently from the Position. This is true, for example, with the GoBasicNode class, where the Location property is overridden to be the same as the Center of the GoBasicNode.Shape object. You can call GoObject.SetSizeKeepingLocation to keep an object’s Location the same while changing its Size.
A third common problem is that sometimes you don’t want to save and restore the Size of a whole node, but of the node’s Icon or other principal child object around which the other child objects are placed.