User defined Selection Frame

hello,

I am looking for a way to show the selection frame around a node (GoMultiTextNode) with rounded corners like the node itself ( I used “this.Corner = new SizeF(10, 10);”).


How can I achive this? Thanks!


That’s easy enough. First define a shape that implements IGoHandle:

[Serializable]
public class RoundedHandle : GoRoundedRectangle, IGoHandle {
public RoundedHandle() {
this.Selectable = false;
}
// implement IGoHandle
public GoObject GoObject {
get { return this; }
}
public int HandleID {
get { return myHandleID; }
set { myHandleID = value; }
}
public GoObject SelectedObject {
get { return mySelectedObject; }
set { mySelectedObject = value; }
}
public GoObject HandledObject {
get { return this.SelectedObject.SelectionObject; }
}
private int myHandleID;
private GoObject mySelectedObject;
}
Then override GoObject.CreateBoundingHandle on your GoMultiTextNode-inheriting class to return one of these:
// Customize the bounding selection handle to be a rounded rectangle
// bigger than the node itself.
// This only gets used when it's not Resizable.
// The Pen is determined by GoSelection and various GoView properties,
// such as GoView.PrimarySelectionColor and BoundingHandlePenWidth.
public override IGoHandle CreateBoundingHandle() {
RoundedHandle h = new RoundedHandle();
RectangleF r = this.Bounds;
h.Bounds = new RectangleF(r.X-5, r.Y-5, r.Width+10, r.Height+10);
return h;
}