Links not showing

So I maybe completely wrong on this one…

I have nodes with links between them that are programmatically set up. I have implemented a layout strategy (separate from the go components) that figures out where to place the nodes. The nodes show up where they are suppose to, but the links between them do not.

  1. Do you have to position the links physically as well as the nodes? (I would have assumed they lay themselves out based on the ports/nodes they are connected to).
  1. Do you have to override some “draw” functionality to get them to be drawn?

Are you setting SuspendsUpdates or SuspendsRouting during your layout?

No I am not. What do those do, and why would I set them? What exactly do I set them on?

They prevent the auto-updating (like the links connected to ports when a node moves). In normal operation, you shouldn’t play with these “Suspends” properties.

But if you were, it would explain what you are seeing....
So, if you click a button (for example) to do the layout, the nodes move but the links attached don't? Is that what you are seeing?

And you shouldn’t be using those properties. Never mind; we shouldn’t have mentioned them without saying that they shouldn’t be used.

Yes, links route themselves automatically. And they paint themselves automatically too.

You did add the links to the document, yes? Actually, the FAQ lists most of the common reasons why some GoObject isn’t showing up in the view.

Here is the code I am using to link up the nodes…

public static void LinkUpNodes(DiagramNode source, DiagramNode dest,
DiagramConstants.CardinalDirections sourceSpot,
DiagramConstants.CardinalDirections destSpot,
DiagramLink link)
{
source.AddSourceLinkAt(sourceSpot, link);
dest.AddDestinationLinkAt(destSpot, link);
}

public void AddDestinationLinkAt(DiagramConstants.CardinalDirections direction, DiagramLink link)
{
GoPort port = GetPortAt(direction);
if (port == null)
{
port = CreatePort(direction);
}
link.FromPort = port;
port.AddDestinationLink(link);
}

    public void AddSourceLinkAt(DiagramConstants.CardinalDirections direction, DiagramLink link)
    {
        GoPort port = GetPortAt(direction);
        if (port == null)
        {
            port = CreatePort(direction);
        }
        link.ToPort = port;
        port.AddSourceLink(link);
    }

Do you add the links to the Document?

No… I posted a question on this forum asking if you perform the two steps (setting link to/from port, and adding to port) that if it behind the scenes added them to the doc.

You guys said they did. So why do I need to do all 3? That is pretty redundant.

So is the sequence:

set link to/from port
add link to source/dest on port
add link to doc?

do I also have to add to node?

GoLink link = new GoLink();
// … other initialization of the link …
link.FromPort = aNode.Port;
link.ToPort = bNode.Port;
goView1.Document.Add(link);

this is assuming the aNode and bNode are already part of the GoDocument.
When GoView has been asked to "Paint" itself, it iterates through the GoObjects in the GoView's layers -- layers like Grids and Selection are owned by the GoView, other layers belong to the GoDocument. When it is painting, it doesn't know anything about this link or that node, the view is just going "GoObject at Location 10,15... Paint yourself please". (The objects that get painted first will end up visually being "behind" things painted later.)
If the GoObject isn't in the GoDocument, it doesn't get painted, even if other GoObjects that are in the document have connections to it.
Run the "Object Browser" sample... and at least initially ignore the stuff that hangs off "View2" on the right. It gives you a visual representation of all of the main players in the GoDiagram design.