GoBoxNode bn = new GoBoxNode();<BR> bn.Text = "box";<BR> bn.Label.TextColor = Color.Blue;<BR> bn.Label.TransparentBackground = true;<BR> bn.Port.Brush = Brushes.LightCyan;<BR> bn.Port.Pen = Pens.DarkCyan;<BR> bn.PortBorderMargin = new SizeF(24, 4);<BR> bn.Position = new PointF(100, 100);<BR> doc.Add(bn);
By the way, you could also compare with the appearance and behavior of a GoBasicNode:
GoBasicNode bn2 = new GoBasicNode();
bn2.Shape = new GoRectangle();
//bn2.Port = new GoBoxPort();
bn2.LabelSpot = GoObject.Middle;
bn2.Text = “box”;
bn2.Label.TextColor = Color.Blue;
bn2.Shape.Brush = Brushes.LightCyan;
bn2.Shape.Pen = Pens.DarkCyan;
bn2.MiddleLabelMargin = new SizeF(48, 8);
bn2.Position = new PointF(200, 100);
The appearance should be about the same, but the way links connect to the GoBoxPort of the GoBoxNode is different from how they connect to the GoPort used by the GoBasicNode. But you can make even that difference go away by having the GoBasicNode use a GoBoxPort, as shown in the commented-out statement above.
So if those two look and act the same, why have both GoBoxNode and GoBasicNode classes? Because they can be configured quite differently.
GoBoxNode lets you have any GoObject, including arbitrarily complex GoGroups, as the GoBoxNode.Body. It’s just by default that the Body is a simple GoText label. Furthermore the port is always assumed to be rectangular surrounding the Body, although you can control how much it extends beyond the Body by setting GoBoxNode.PortBorderMargin.
GoBasicNode lets you use any GoShape as the background, allows it to be resized independently of the Label if GoBasicNode.AutoResizes is false, and also supports putting the Label at various spots relative to the Shape, according to the value of GoBasicNode.LabelSpot. The port takes the shape of the Shape, because its PortObject refers to the Shape, so it doesn’t have to be rectangular.