Port Alignment

I created a custom node based on Demo1.InfoNode8 sample. I was able to modify the port positioning so the ports centered on the body outline by using the LayoutChildren overrides and manually moving them left or right. (Ex: <|> for the diamond PortStyle, though the port was above the body outline.)

I created a second custom node based on the Demo1.CollapsingRecordNode object, but am unable to achieve the same results with port layout, by overriding LayoutChildren in either the CollapsingNodeRecord, CollapsingNodeRecordItem, or CollapsingNodeRecordItemList.

Any thoughts?

Since it is the “item” class that holds the ports, it is CollapsingRecordNodeItem.LayoutChildren that you want to modify, since it is already overridden in that class.
Although I don’t understand exactly what you are doing (if you inserted an image in your message, I and other people can’t see it), perhaps what you want to do is just like what GraphNode.LayoutChildren does with the ports for certain shapes of nodes in the FlowCharter sample application.

Sorry, here is the image.

The ports on the right are what I want, overlapping the node border in the Demo1.InfoNode8. The ones on the left, in the CollapsingRecordNodeItem class, don’t seem to want to extend beyond the bounds of the node. In the picture, the left side ports are inside the node.

Here is the code I am using:

Public Overrides Sub LayoutChildren(ByVal childchanged As GoObject)


          Dim e As IEnumerator = Me.Ports.GetEnumerator
          Do While e.MoveNext
              Dim p As GoPort = CType(e.Current, GoPort)

              If p.IsValidFrom Then
                  p.Left = p.Left + 6
                  p.Left = p.Left - 7
              End If

OK, so you can’t use the default boundary of the node, since the Bounds includes all of its children, including the items’ ports.
So comment out the statements in CollapsingRecordNode.CreateBody where it sets the body’s Brush and BorderPen.
And add code to the override of CollapsingRecordNodeItemList.Paint. Before the call to the base method do:
if (this.ChildIndentation <= 0) {
RectangleF r = this.Bounds;
GoShape.DrawRectangle(g, view, null, Brushes.DarkSlateBlue, r.X+7, r.Y, r.Width-7-6, r.Height);
Of course you can specify your own values for the Pen and the Brush here – I have just “moved” them from CollapsingRecordNode.CreateBody. Note that the bounds of the rectangle are adjusted corresponding to the shifts you made of the ports in the override of CollapsingRecordNodeItem.LayoutChildren.

A modification of your suggestion worked wonderfully. Thank you.