You started with CustomSubGraph, right? CustomSubGraph uses a CollapsedObject for when it is collapsed, so you must have changed that. Without knowing what changes you’ve made, it’s hard for me to say.
Note that both TreeSubGraph and MultiPortSubgraph (the other two types in SubGraphApp) both have exactly the collapse behavior you want (or at least what I think you want).
You are right, the collapse behaviour of MultiPortSubGraph in the Demo is what I want.
I use the CustomSubGraph from the Demo application.
What changes do you mean?
Does your version of the SubGraphApp-Demo provide another collapse behaviour than mine?
If no: What causes the different collapse behaviour compared with MultiPortSubGraph?
If yes: Can I download somewhere the uptodate CustomSubGraph.cs?
so there was and is no override of CreateCollapsedObject.
I commented the method ComputeCollapsedSize now, but the result keeps the same.
If you can’t reproduce the problem from my screenshots with your version of CustomSubGraph resp. SubGraphApp, perhaps you could send me your version by email?
Ok, now it works, if the content node has a long label.
But if the SubgraphNode itself has a long label, there is the same behaviour as before, if I want to show the complete label and comment therefore the code in PrepareCollapse and FinishCommand.
So, how can I have the collapsed subgraph always right below the handle?
Thanks for the hint. That leads into the right direction!
I tried CollapsedLabelSpot TopLeft and BottomLeft.
And TopLeft is near to my needs, although it positions the label above the handle.
I tried also CollapsedLabelSpot=MiddleLeft, but that led to the label on the left side of the handle (other than TopLeft and BottomLeft).
There remains another problem when having a Subgraph inside another Subgraph. The layout of the collapsed outer subgraph then depends on the collapsed state of the inner subgraph. If the inner subgraph was collapsed, too, then the collapsed outer subgraph looks relative ok (the large empty area would not be necessary - the label could be drawn here as well),
but if the inner subgraph was expanded, there are now empty areas on the left and the bottom of the handle in the collapsed outer subgraph.
From my point of view it would be convenient and easy to understand,
if there were two properties CollapsedLabelSpot and CollapsedObjectSpot,
which define the relationship between handle and Label resp. “Invisible Objects Area” of Collapsed Subgraph
such that “TopLeft” means "top left corner of Label resp. Object is positioned at the Handles position (and the same for “MiddleLeft” etc.
Perhaps there is even already a work around available to get this behaviour ?
OK… there are a little more than an infinite number of options here.
Why CollapsedLabelSpot = MiddleLeft is so weird, I don’t understand. I saw that too. But here is a better option, I think…
first, if you are trying to keep things similar between expanded and collapsed, you may want to set Margins the same in both (although you may already have this…)
and try this trick to have the collapsed label not move:
public override void LayoutLabel() {
if (this.IsExpanded)
base.LayoutLabel();
}
I’ve tried this, and the results look good to me, although you can be the final judge… (note CollapsedLabelSpot has no meaning anymore with the above override)
When collapsing subgraphs, which include uncollapsed subgraphs there seem to remain some space on the left of the handle, but all in all it looks much better than the approaches before.
I modified the trick a little bit to avoid very wide and flat collapsed subgraphs in my hierarchical model (about 7 levels of subgraphs):
public override void LayoutLabel()
{
if (this.IsExpanded) base.LayoutLabel();
else Label.Position = new PointF(Handle.Position.X + 20, Handle.Position.Y);
}
and I am planning to build in some mechanisms to collapse recursively.
Things can be so easy if one knows what to do.
Thank you very much!