GoSubGraph Collapse cover the label

HI

What’s the best way to move the collapse sign(-) so that it won’t cover the Label of the subgraph. I have tried to override the LayoutChildren function of the SubGraph but no success.

Thanks

Did you start with one of the SubGraphs in the SubGraphApp sample, or do you have your own?

Let me see your LayoutChildren code…

I used the SubGraphApp2 to see the problem.

The “-” will cover the title text. The pictures is taken from SubGraphApp example when I made a custom SubGraph from out of a circle from that example.

Thanks

In the sample CustomSubGraph.cs, there is a commented-out method… LayoutHandle().

Just uncomment this code and you should be set.

That LayoutChildren did solve the problem in that particular case. I guess my situation is a little bit different. My subGraph is a simple one without extra boundary. I copied the layoutChildren into my subGraph, it still covers a little bit. I tried the follow code to move the label down below handle but didn’t work.

public override void LayoutChildren(GoObject childchanged) { if (childchanged is GoText) { if (this.Initializing) return;
            GoSubGraphHandle h = this.Handle;

            if (h != null && h.CanView())
            {
                RectangleF newb = ComputeBorder();
                GoObject label = this.Label;

                label.Location = new PointF(h.Location.X + h.Size.Width, this.Location.Y + h.Height);
                

            }
        }

        base.LayoutChildren(childchanged);
    }

    public override void LayoutHandle()
    {
        GoSubGraphHandle h = this.Handle;
        if (h != null && h.CanView())
        {
            // keep handle up-to-date
            RectangleF b = ComputeBorder();
            h.Position = b.Location;
        }
    }

Forgot to show the picture after add the layoutHandle function.

I found these line do the trick I am looking for

        this.TopLeftMargin = new SizeF(5, 10);
        this.CollapsedTopLeftMargin = new SizeF(5, 10);

Thanks

ok… setup collapsed margins

  this.CollapsedTopLeftMargin = new SizeF(10, 10);
  this.CollapsedBottomRightMargin = new SizeF(10, 10);

and…
public override void LayoutHandle()
{
if (!this.IsExpanded) return;
GoSubGraphHandle h = this.Handle;
if (h != null)
{
RectangleF b = ComputeBorder();
// top-left, in the margins
h.Position = new PointF(b.X, b.Y);
}
}

Actually, I setup both the expanded and collapsed subgraph margin all with 10 and modify the layoutHandle as follow, the undesired behavior is that the subgraph object moving back and forth when I click expaned/collapsed sign twice. I set an observer to the lable object and found that there is a change bound events fired with new bound when I click on the collapse icon . Is there a way to prevent the moving ?

Thanks

public override void LayoutHandle()
{
//if (!this.IsExpanded) return;
GoSubGraphHandle h = this.Handle;
if (h != null)
{
RectangleF b = ComputeBorder();
// top-left, in the margins
h.Position = new PointF(b.X, b.Y);
}
}

You can get that walking behavior with SubGraphs if you’re not careful, which is why we document the samples overrides in the LayoutHandle API reference.

Comment out your LayoutHandle and make sure that’s what’s causing the walking… then add it back if it isn’t. The code I posted above doesn’t have that problem when used in CustomSubGraph.