GoSubgraph and GoLayout

Hello,
I have two questions regarding a subgraph and GoLaout.
1) I am using a subgraph and in the subgraph I have children (nodes)
with links. I want to use the GoLayout to arrange the children in the
Subgraph. So I have the following two lines to control the layout in the
veiw.
[code]
GoLayoutLayeredDigraph layout = new GoLayoutLayeredDigraph();
layout.Document = this.methodBuilderView1.Document;
[/code]
In the case when my objects are not in the view but in a subgraoph I can not use the second line as it appears above.
So what should I assign the layout.document to so that it handles the subgraph as the document.
2) Which event gets fired when I collapse/expand a subgraph. I need to know because I need to have a call to
layout.PerformLayout(); in that event.
Thanks very much
Susan
  1. The Layout User Guide, and the code in SubGraphApp, shows you how to layout the nodes within a subgraph.
2) You can override the GoSubGraph.FinishExpand method; call the base method first, and then do your layout.

Thanks Walter,

The samples were great.
Susan

Regarding the second point in the original post.

Even if I overwrite the virtual method FinishExpand in my class definition it still does not get invoked at run time.
here is my code:
[code]
public new void FinishExpand()
{
base.FinishExpand(hpos);
//Do my stuff
}

public new void FinishCollapse()
{
base.FinishCollapse(sqrect);

//Do my stuff
}
[/code]
At run time Idynamically create a subgraph and dynamically populate it with other elements by dragging and dropping them inside the subgraph.
Then I create my links,etc.
The issue is this:
When I collapse the subgrph, I end up with this long arrow stretching for the entire height of the formerly expanded subgraph and thus I watste too much space even when the subgraph is collapsed. I need to shorten the arrow when I collapse the partucular subgraph which is why I need to call the layout.PerformLayout() in that event.
All my instances are created dynamically and I don't know in advance how many of them I will have.
Is there a property or a method of the layout which automatically takes care of that? OR if notare you aware of how to hande taht situation?
Thanks very much.
Susan

Using the “new” modifier means you are explicitly not overriding a method.

I agree,and I did that because I wanted to change the function signature to not accept the same parameters as the base funtion since all I want to do is to call the PerformLayout.

But what really stops me from continuing is the rest of the issue - how to get to that method for a particular instance of the class at run time.
I can not implement an event handler since this is not an even so I really don't know what to do.
Thanks
Susan

I was thinking maybe I can handle it in one of the GoVIew Events insted of the methods raised by the GoSubgraph.

Any thoughts on that?Any suggestions for an appropriate event?
Susan
PointF myOldPosition;<BR>    protected override void PrepareExpand() {<BR>      myOldPosition = this.Position;<BR>      base.PrepareExpand();<BR>    }<BR>    protected override void FinishExpand(PointF hpos) {<BR>      base.FinishExpand(hpos);<BR>      if (this.Document != null) {<BR>        GoLayoutLayeredDigraph layout = new GoLayoutLayeredDigraph();<BR>        layout.Document = this.Document;<BR>        GoLayoutLayeredDigraphNetwork net = layout.CreateNetwork();<BR>        net.AddNodesAndLinksFromCollection(this, true);<BR>        layout.Network = net;<BR>        layout.DirectionOption = GoLayoutDirection.Right;<BR>        layout.PerformLayout();<BR>      }<BR>    }<BR>    public override void Expand() {<BR>      base.Expand();<BR>      this.Position = myOldPosition;<BR>    }<BR>

Thans Walter but what I wanted to know was how to invoke the event from my program at run time.

Actually I figured it out - in the Paint event of the view I placed the
[code]
_mainLayout.DirectionOption = GoLayoutDirection.Down;
_mainLayout.PerformLayout();
[/code]
This way every time I Collapse or Expand any of the Subgraphs the link size is reduced / increased accordingly.
Thanks for trying to help me.
Susan

I strongly recommend not making any modifications to either the GoView or its GoDocument during a Paint event. That can cause all kinds of surprising and undesirable behavior.

thanks Walter.
I changed it actually and placed he code in another GoVIew event.

[code]
void methodBuilderView1_MouseCaptureChanged(object sender, EventArgs e)
{
_mainLayout.DirectionOption = GoLayoutDirection.Down; _mainLayout.PackOption = GoLayoutLayeredDigraphPack.Median; _mainLayout.CycleRemoveOption = GoLayoutLayeredDigraphCycleRemove.DepthFirst; _mainLayout.LayeringOption = GoLayoutLayeredDigraphLayering.OptimalLinkLength; _mainLayout.LayerSpacing = 0; _mainLayout.AggressiveOption = GoLayoutLayeredDigraphAggressive.More; _mainLayout.PerformLayout();
}
[/code]
Is that better?
Susan

That’s unlikely to be the time at which you want to do anything.

Do you just want this code to run when the user clicks on the GoSubGraph.Handle? If so, you could implement a GoView.ObjectSingleClicked event handler, and check whether the GoObjectEventArgs.GoObject is a GoCollapsibleHandle. This latter check is useful to avoid running the code when the user clicks on some other object.

Thanks Walter,

That is exactly what I needed to know - the name of the event and also how to know that it was trigerred by a click on he handle and not by something else.
Susan