GoGeneralNode position when adding/removing ports

When adding/removing ports to a GoGeneralNode, the node center stays in the same location, causing the node to grow 'outwards' from (or shrink 'inwards' to) the center.
I my case, I would like the node to grow at the bottom, retaining the top left position when adding/removing ports.
What is the best way to achieve this ?

Do you want the icon to scale to fit the ports, or stay fixed size? If you want a fixed icon, do you want it centered or top justified?

The icon should scale the way it does now, but the top left of the icon should stay fixed rather than the center.

OK, without overriding GoGeneralNode, you could just save the topleft, and then reset it after adding the port.

PointF tl = ng.Icon.GetSpotLocation(GoObject.TopLeft);
GoGeneralNodePort p = new GoGeneralNodePort();
ng.AddLeftPort(p);
ng.Icon.SetSpotLocation(GoObject.TopLeft, tl);
A cleaner solution would be to override LayoutChildren, and essentially do the same thing. (remember the topleft, call the base method, then move the node to location.)

This works, except that when undoing/redoing, the toplabel position is messed up.

You need to wrap any edits in


doc.StartTransaction();
...
doc.FinishTransaction("add port");