GoDigram for .NET Framework and .NET Core
Northwoods.Go Namespace / GoLink Class
Members Example
In This Topic
    GoLink Class
    In This Topic
    This class provides a standard implementation of IGoLink as a GoObject.
    Syntax
    Remarks
    A GoLink is a GoStroke that connects two GoPorts. Make a link by constructing a link, setting both the %% and the ToPort, setting any other properties you want on the link, and adding the link to your GoDocument. Setting the two port properties will automatically add the link to each port's collection of links. Remove a link by calling Unlink. That will automatically disconnect the link from both of its ports.

    A link does not own either port to which it is connected -- ports are normally owned by nodes. Ports hold references to the links that are connected to them -- they do not own the links.

    The appearance of a link is determined by the stroke GoStroke.Style, by the GoShape.Pen, as well as by various link properties. Any filled arrowheads are painted by the GoShape.Brush. Many examples are presented in the User Guide.

    The path of a link is determined by the points in its stroke, as plotted by CalculateStroke. For links of GoStroke.Style GoStrokeStyle.Bezier, it takes the GoStroke.Curviness into account to automatically give the link a curve.

    When the link is Orthogonal, it is common to set the style to RoundedLine. Then the GoStroke.Curviness property controls the size of the corners in the link.

    Whenever either port is moved (normally because the port's parent node moved), CalculateStroke is called again. By default this will calculate all of the stroke points again. However, if you set the AdjustingStyle property, CalculateStroke will take the old path into account in calculating the new path.

    Example
    Typical programmatic 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);
    goView1.Document.Add(node1);
                
    GoBasicNode node2 = new GoBasicNode();
    node2.LabelSpot = GoObject.Middle;
    node2.Text = "basic node 2";
    node2.Shape.BrushColor = Color.LightYellow;
    node2.Location = new PointF(200, 50);
    goView1.Document.Add(node2);
                
    GoLink link = new GoLink();
    link.ToArrow = true;
    link.FromPort = node1.Port;
    link.ToPort = node2.Port;
    goView1.Document.Add(link);
    See Also