Today, I’ve added a resizable subgraph class to my current project. Basically, it’s a class derived from GoSubGraph, with some additions.
But when trying it I found the subgraphs jumping around when resizing them. First I thought there might be something wrong with the code I added, but even after removing everything new, the problem still persisted.
When I grab the resize handle and move it, the subgraph does as wanted. Yet when I put my finger off the mouse button, the graph jumps up, and occasionally also to the left. I found out that it jumps up by exactly its initial height. This also happens when you just click on the resize handle.
If you, Walter, or anyone else knows or has an idea what’s going on here, please let me know; any help is appreciated
Thanks for your reply, Walter.
As I am not in the office now and therefore don’t have the code available, I tried it from scatch, unsing the FlowChart sample. Well, I have been able to reproduce it again. Maybe (or better hopefully) you can reproduce it, too.
It’s a class derived from GoSubGraph, no methods overridden. Only the constructor sets Shadowed, PickableBackground and Resizable to true.
Then an instance of it gets added to the FlowChart’s palette. When dragged to the document window, the effects described appear.
Well, this works fine for me:
GoSubGraph sg = new GoSubGraph(); sg.Resizable = true; sg.PickableBackground = true; sg.Add(new GoRectangle()); goView1.Document.Add(sg);
However, do you only see the problem when the GoSubGraph is empty? That’s a known problem that will be fixed in the next release. Or send me mail for a recent build.
Ah, great! That did the trick. Thank you! :)
I tried it with an empty subgraph only, and therefore had the jumping graph problem.
As for a recent build, I’ll send you a mail when I’m back in office tomorrow; thanks for offering.
Hmmm, by looking at the check-ins and diff’s, it appears you might be able to get a bug fix by overriding GoSubGraph.LayoutLabel:
public override void LayoutLabel() { GoText lab = this.Label; if (lab == null) return; if (this.IsExpanded) { // don’t move label if it’s the only thing left (besides the standard children) int numchildren = 0; if (this.Handle != null) numchildren++; if (this.Label != null) numchildren++; if (this.Port != null) numchildren++; if (this.CollapsedObject != null) numchildren++; if (numchildren == this.Count) return; } base.LayoutLabel(); }
I haven’t tested this, though.