Ellipse with Multiports

I’m interested in creating an ellipse node that dynamically create ports on the edge of the ellipse where the cursor is closest. Suggestions on how best to proceed?

If you look at Demo1, the ellipse with the label “a longer label” does this… it’s created with this snippet:

  GoBasicNode bn2 = new GoBasicNode();
  bn2.Location = new PointF(400, 300);
  bn2.LabelSpot = GoObject.Middle;
  bn2.Text = "a longer label";
  doc.Add(bn2);

Now… this isn’t really creating dynamic ports… there’s one port that uses the ellipse as it’s shape. and if you move a connecting node, the link will stay “connected” to the closest point between the two nodes.

Does that meet your needs, or do you really need a “fixed” port that gets created when the link is established?

I’m trying to simulate the GoBoxNode.LinkPointsSpread feature, but with an ellipse shape. I’ve considered the option you mentioned, but when I have shape.Orthogonal and shape.AvoidsNodes turned on, the link points are limited to top, bottom, left, right. Further suggestions?

[code] [Serializable]
public class BoxNode4 : GoBoxNode {
public BoxNode4() {
this.Label.Alignment = Middle;
this.PortBorderMargin = new SizeF(20, 10); // extra room needed due to ellipse
}

protected override GoPort CreatePort() {
  return new BoxPort4();
}

}

[Serializable]
public class BoxPort4 : GoBoxPort {
public BoxPort4() {
this.LinkPointsSpread = true;
this.Style = GoPortStyle.Ellipse;
this.BrushColor = Color.White;
this.PenColor = Color.Black;
}

protected override void AssignLinkPoints(GoBoxPortLinkInfo[] linkinfos) {
  base.AssignLinkPoints(linkinfos);
  PointF c = this.Center;
  foreach (GoBoxPortLinkInfo info in linkinfos) {
    PointF result;
    GoEllipse.NearestIntersectionOnEllipse(this.Bounds, info.LinkPoint, c, out result);
    info.LinkPoint = result;
  }
}

}[/code]