We’re using GoBalloon to implement comments attached to other diagram items and we’ve got some problems. How can I achieve following behavior of GoBalloon:
comment is resizable (user can drag handle and resize balloon)
text is displayed multiline and adapts to size of comment
I thought that implementing this will be quite easy task but it wasn’t. I definitely missed something and I’ll be thankful for any tip.
Actually, it is pretty easy to modify the ResizableComment class to get what you want. Basically you want resizing to resize the Label instead of resizing the Background shape.
To do this, change ResizableComment to inherit from GoBalloon, initialize the GoText label to support being resized, and change DoResize to set the Label.Bounds instead of setting the margins. Also, since ResizableComment also supports a GoCollapsibleHandle, we need to position the Handle relative to the Label instead of relative to the Background.
But if you strip out all of the IGoCollapsible support, you get:
[code] [Serializable]
public class ResizableBalloon : GoBalloon {
public ResizableBalloon() {
this.Resizable = true;
GoText lab = this.Label;
if (lab != null) {
lab.Wrapping = true;
lab.AutoResizes = false;
lab.Clipping = true;
lab.StringTrimming = StringTrimming.EllipsisCharacter;
}
}
I tried to set the label width after other initialization.
It works when the resizable ballon object is created.
See the blue line of code.
[Serializable]
public class ResizableBalloon : GoBalloon {
public ResizableBalloon() {
this.Resizable = true;
GoText lab = this.Label;
if (lab != null) {
lab.Wrapping = true;
lab.AutoResizes = false;
lab.Clipping = true;
lab.StringTrimming = StringTrimming.EllipsisCharacter;
lab.Width = 100;
}
}
}