MultiPortNode and SubGraph

Hi Walter,

I've got another question for you.
I have implemented the MultiPortNode class (with some modifications) to my project, but after some stress test related to PerformLayout - it seems my target machines would not be able to handle the amount of load the layout functions are using.
So I have decided to implement the SubGraph object so a number of nodes maybe grouped and layed-out more quickly. However I am unsure how to place my nodes into the SubGraph programmatically.
Please advice.

GoSubGraph inherits from GoNode which inherits from GoGroup. Just call GoGroup.Add to add a GoObject as a child to the group.

Thanks for the reply Walter,

It seems I could even simple use GoSubGraph.Add to add the node into the Graph directly.
However when I do this (- and I've tried both ways using GoSubGraph and casting as GoGroup.Add), I found that the SubGraph must be expanded in order for the Graph to properly display. Otherwise if the Graph was collapsed, a node would still be added to the document as if the Graph was expanded (but without the -default- blue background).
At this point, I would manually press the (+) sign to expand the Graph - and if I press the (-) to collapse the Graph, THEN the newly created node would be minimized inside the Graph.
This is a weird effect. Do I need to ensure the graph is expanded before trying to programmatically add nodes to it?

GoSubGraph.Add is the same method as GoGroup.Add, because GoSubGraph inherits from GoGroup.

If you don't want to add subgraph children when the GoSubGraph is expanded, there are several things you'll need to do before Add'ing it: position the node, set its Visible and Printable properties to false, and save its relative position and size (for when it the subgraph is expanded) in GoSubGraph.SavedBounds. These things are normally done by GoSubGraph.SavedChildBounds and CollapseChild.

I’m not quite sure my question was clearly expressed.

In regards to the weird effect I was talking about, here is the scenario: My test application will create a new IconicNode everytime I double-click on the GoView. The location at which I double-clicked is where the new node will appear. This works OK.
Next I implemented a GoSubGraph - and upon double-clicking the GoView, the application will automatically add the new node to the Graph as well. This works great when the graph is expanded. If I'm not mistaken, the graph has a default blue background engulfing all its child nodes - so when the graph is expanded, and a new node is added to the GoView, I would see the blue background expand just enough to include the new node.
However, the weird effect occur when the graph is collapsed. In the collapsed state, I have specified an Icon to represent the collapsed graph - but I think that shouldn't matter in this case. However when I double-click on the GoView, I would see a new node created - all the while, the graph is still collapsed; and the new node is not encased with the graph's defualt blue background.
This is weird. But what I have tried doing is expanding the graph - at which point the graph expands to include the new node. Now if I collapse the graph again, the new node would disappear from the view and the entire graph replaced with its specified icon.
I would be happy to post my code if necessary. Thanks for your help.

A little update for everyone reading this…

I have tried my theory expressed above and it works perfectly. Prior to actually adding a new node to the document, I would check if the SubGraph is collapsed (.. actually thats check if !IsExpanded). If it is collapsed, then I would Expand() it first, then add the node, then Collapse() it back.
Initial speculations was that the GoView would flicker too much, however after thorough testing; the results are promising.