I’d like to change the color, thickness, etc of the outline drawn when a GoBasicNode is selected in the view. Can anyone show me how to do it?
Thanks,
Mark
Did you mean changing GoView.BoundingHandlePenWidth?
Or did you mean actually modifying your GoBasicNode.Shape.Pen?
I’m not sure…Right now, when a node is selected, a thin blue rectangle is shown. I’d like to replace it with a thick red circle around the node instead. A thick red rectangle might be ok, too.
If you are seeing a bounding selection handle (i.e. a GoHandle that belongs to the GoView, not to the GoDocument or any part of the document), then you can set
goView1.BoundingHandlePenWidth = 3;
goView1.PrimarySelectionColor = Color.DarkRed;
goView1.SecondarySelectionColor = Color.DarkRed;
Is it possible to override the default selection handle with a different shape? When I select circle nodes, I would like to see a larger circle surrounding the selected node, and when I select a rectangle node, I would like to see a larger rectangle surrounding the selected node.
I have tried doing this by adding a shape behind my node that I can turn on and off using a highlight color (from a different post on this forum). To get this to work, I override the OnGotSelection and OnLostSelection, and maintain a selected flag in my node. This almost works, except that when the view is invalidated, the default bounding box appears. Any suggestions? Here’s my code:
public override bool OnEnterLeave(GoObject from, GoObject to, GoView view)
{
if (this.isSelected==true)
return true;
if (to == this)
this.HighlightColor = Color.Blue;
else
this.HighlightColor = Color.Empty;
return true;
}
public override void OnGotSelection(GoSelection sel)
{
//base.OnGotSelection (sel);
this.isSelected = true;
HighlightColor = Color.OrangeRed;
}
public override void OnLostSelection(GoSelection sel)
{
//base.OnLostSelection (sel);
this.isSelected = false;
HighlightColor = Color.Empty;
}
Sure, instead of overriding CreateShape to return a new GoEllipse (or instead of just setting the GoBasicNode.Shape property to a new GoEllipse) use a new instance of this instead:
[Serializable]
public class Ellipse : GoEllipse, IGoHandle {
public Ellipse() {}
// Customize the bounding selection handle to be an ellipse just like the node’s Shape, but bigger.
public override IGoHandle CreateBoundingHandle() {
Ellipse h = (Ellipse)Copy();
h.Shadowed = false;
RectangleF r = h.Bounds;
h.Bounds = new RectangleF(r.X-5, r.Y-5, r.Width+10, r.Height+10);
return h;
}
// 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;
}
For some reason, when I select my ellipse and delete it from the diagram, the ellipse disappears, but the handle does not - leaving a ghost handle sitting in the diagram. Any idea why that might be happening?
Never mind - I found the problem.