Location of ports in GoGeneralNode

The GoGeneralNode always seems to center the left and right ports around the center of the nodes vertical axis. Is there a way to change this. Basically I’m trying to make my Left ports group from the top and the right ports group from the bottom. Thanks.

As with every other question, you want to override LayoutChildren to do your own custom positioning calculations. Here’s the definition of GoGeneralNode.LayoutChildren, but simplified to just do the Horizontal Orientation case, but keeping the complexity of dealing with null Icons et al:
public override void LayoutChildren(GoObject childchanged) {
if (this.Initializing) return;
this.Initializing = true;
GoObject icon = this.Icon;
GoObject toplabel = this.TopLabel;
GoObject bottomlabel = this.BottomLabel;
if (this.Orientation == Orientation.Horizontal) {
int num = this.LeftPortsCount;
float totalh = 0; // total height of left ports
float maxw = 0; // maximum width of left ports
for (int i = 0; i < num; i++) {
GoGeneralNodePort p = GetLeftPort(i);
if (!p.Visible) continue;
totalh += p.PortAndLabelHeight;
maxw = Math.Max(maxw, p.PortAndLabelWidth);
}
if (icon != null) {
SizeF minIconSize = this.MinimumIconSize;
float newW = Math.Max(minIconSize.Width, icon.Width);
float newH = Math.Max(minIconSize.Height, icon.Height);
icon.Bounds = new RectangleF(icon.Left - (newW - icon.Width)/2,
icon.Top - (newH - icon.Height)/2,
newW, newH);
}
float rectx = 0;
float recty = 0;
if (icon != null) {
rectx = icon.Left;
} else {
rectx = this.Left;
}
if (icon != null)
recty = icon.Top;
else
recty = this.Top + (toplabel != null ? toplabel.Height : 0);
if (icon != null && icon.Height > totalh) {
recty += (icon.Height-totalh)/2;
}
float h = 0; // height of visible items so far
for (int i = 0; i < num; i++) {
GoGeneralNodePort p = GetLeftPort(i);
if (!p.Visible) continue;
h += p.PortAndLabelHeight/2;
p.SetSpotLocation(MiddleRight, new PointF(rectx, recty+h));
p.LayoutLabel();
h += p.PortAndLabelHeight/2;
}
num = this.RightPortsCount;
totalh = 0; // total height of right ports
for (int i = 0; i < num; i++) {
GoGeneralNodePort p = GetRightPort(i);
if (!p.Visible) continue;
totalh += p.PortAndLabelHeight;
}
if (icon != null) {
rectx = icon.Right;
} else {
rectx = this.Right;
}
if (icon != null)
recty = icon.Top;
else
recty = this.Top + (toplabel != null ? toplabel.Height : 0);
if (icon != null && icon.Height > totalh) {
recty += (icon.Height-totalh)/2;
}
h = 0; // height of visible items so far
for (int i = 0; i < num; i++) {
GoGeneralNodePort p = GetRightPort(i);
if (!p.Visible) continue;
h += p.PortAndLabelHeight/2;
p.SetSpotLocation(MiddleLeft, new PointF(rectx, recty+h));
p.LayoutLabel();
h += p.PortAndLabelHeight/2;
}
if (toplabel != null) {
if (icon != null) {
toplabel.SetSpotLocation(MiddleBottom, icon, MiddleTop);
} else {
toplabel.SetSpotLocation(MiddleTop, this, MiddleTop);
}
}
if (bottomlabel != null) {
if (icon != null) {
bottomlabel.SetSpotLocation(MiddleTop, icon, MiddleBottom);
} else {
bottomlabel.SetSpotLocation(MiddleBottom, this, MiddleBottom);
}
}
} else { // Orientation == Vertical
… elided for simplicity
}
this.Initializing = false;
}