GoDigram for .NET Framework and .NET Core
Northwoods.Go Namespace / GoBasicNode Class
Members Example
In This Topic
    GoBasicNode Class
    In This Topic
    A simple node with a Shape, a single Port and an optional text Label.

    By default the Shape is a GoEllipse. You can easily replace that shape with a GoRectangle or other GoShape. If you call the GoBasicNode Constructor(GoFigure) constructor, the shape will be a GoDrawing initialized to have that GoFigure.

    The position and size of the Label relative to the Shape is determined by the LabelSpot property. When the spot is GoObject.Middle, the shape is automatically resized to fit the label's text (if AutoResizes is true) plus the MiddleLabelMargin, and the port is hidden and resized to be the same size as the shape itself.

    When AutoResizes is false, the Label is sized to fit inside the bounds of the Shape, minus the margins. The label (a GoText) is automatically wrapped and clipped.

    Since the default value for LabelSpot is GoObject.MiddleTop, you will need to explicitly set the LabelSpot to GoObject.Middle to get this appearance and behavior. Otherwise the default appearance is to have the Label be positioned outside of the Shape, with the Port small and positioned in the middle of the Shape.

    Unless you set the Text or the Label property, there will be no Label. However, the GoBasicNode Constructor(GoFigure) constructor does create a Label, in addition to having the label be in the middle of the shape.

    When the Shape is an instance of GoDrawing, you can get and set the Figure property, if you want to dynamically change the appearance of the node. More generally, you can modify that GoDrawing or replace the Shape with another kind of GoShape.

    Setting the GoNode.Location, GoNode.Resizable, GoNode.Reshapable and GoNode.Shadowed properties actually set the same properties on the node's SelectionObject, which is the Shape.

    Typical usage might be something like:
    GoBasicNode node1 = new GoBasicNode();
    node1.LabelSpot = GoObject.Middle;
    node1.Text = "basic node 1";
    node1.Shape.BrushColor = Color.LightGreen;
    node1.Location = new PointF(75, 50);
    GoBasicNode node2 = new GoBasicNode(GoFigure.CreateRequest);
    node2.Text = "basic node 2";
    node2.Shape.BrushColor = Color.LightYellow;
    node2.Location = new PointF(200, 50);
    GoLink link = new GoLink();
    link.ToArrow = true;
    link.FromPort = node1.Port;
    link.ToPort = node2.Port;
    See Also