Label position on subgraph

Hello,

We have a requirement that the label of Subgraph should be at topleft border of subgraph by default and then movable by user if required. I was abel to accomplish the first requirement using following function:
public override void LayoutLabel()
{
RectangleF borderArea = ComputeBorder();
base.Label.Position = new PointF(borderArea.X , borderArea.Y);
}
Now the problem is that it is not allowing me to move the label to some other position.
Could you please suggest on how to make it movable?
Thanks,
Nagaraj.

You’ll have to remember to do the LayoutLabel just the first time. Add a flag. Be aware this adds requirements to CopyObject.

Also, it's a good idea to make sure "Label" is non-null before using it.

Hello,

Thanks for the reply.
One thing I observed is that, when I move label outside current bounds,
the subgraph is expanded but only the expanded area is not repainted with the background color that was specified and remains white. But this happens only with Label
and not with other GoNode child objects added to the subgraph.
Is this also the expected behavor?
Thanks,
Nagaraj.

Expected? Well, dragging the label around wasn’t part of the original design of the node, so you’re already outside the bounds of “expected” behavior.

Which SubGraph class did you start with?

Hello,

I have my own class derived from GoSubgraph and overriding CreateHandle(), LayoutLable() and ComputeInsideMarginsSkip()
methods.
protected override bool ComputeInsideMarginsSkip(GoObject child)
{
// return true for Label object
if (child == base.Label)
{
return true;
}
else
{
return base.ComputeInsideMarginsSkip(child);
}
}
protected override GoSubGraphHandle CreateHandle()
{
GoSubGraphHandle handle = new GoSubGraphHandle();
handle.Visible = false;
return handle;
}
Thanks,
Nagaraj.

If you are using the default background then, it gets painted by PaintDecoration as a Rounded Rectangle with a rectangle size returned by GoSubGraph.ComputeBorder.

ComputeBorder returns ComputeInsideMargins plus the margins.
and... you're skipping your object in ComputeInsideMargins.