Border Style and Links

I want the ability to change the color of the border style and link with the mouse hovers over a goIconicNode or goLink.
Anyone know how to do this?
Thanks

Implement a GoView.ObjectEnterLeave event handler, or override GoObject.OnEnterLeave. For example, IconicApp does this to select the object that the mouse is over. Note that the GoView event handler needs to look at the Parent or TopLevelObject, since the mouse might be over a part of a GoGroup.
To change the color of a link, set its Pen. Alternatively you can prespecify a HighlightPen for the link, and then just toggle the appearance of that pen by setting the Highlight property.
You’ll probably want to temporarily turn on GoObject.SkipsUndoManager when making a change to an object, so that such changes are not recorded for undo/redo.
GoIconicNode doesn’t have a GoShape whose Pen or Brush you could set to give the Icon a “border”. You’ll either need to add a GoRectangle behind the Icon, or override Paint to draw the “border”. I’ll see if there’s any example of this you can use.

[Serializable]
public class LitNode : GoIconicNode {
public LitNode() {
GoRoundedRectangle r = new GoRoundedRectangle();
r.Selectable = false;
r.Pen = null; // don’t show anything at first
r.Brush = null;
r.Corner = new SizeF(5, 5);
InsertBefore(null, r); // add behind everything else in node
AddChildName(“highlight”, r); // give the rectangle a name for future reference
LayoutChildren(null);
}
public override void LayoutChildren(GoObject childchanged) {
base.LayoutChildren(childchanged);
GoObject r = FindChild(“highlight”);
if (r != null && this.Icon != null) {
RectangleF b = this.Icon.Bounds;
b.Inflate(3, 3);
r.Bounds = b;
}
}
public override bool OnEnterLeave(GoObject from, GoObject to, GoView view) {
if (to == this)
this.HighlightColor = Color.Red;
else
this.HighlightColor = Color.Empty;
return true;
}
public Color HighlightColor {
get { return myHighlightColor; }
set {
if (myHighlightColor != value) {
myHighlightColor = value;
GoShape s = FindChild(“highlight”) as GoShape;
if (s != null) {
s.SkipsUndoManager = true;
if (myHighlightColor == Color.Empty)
s.Pen = null;
else
s.Pen = new Pen(myHighlightColor, 5);
s.SkipsUndoManager = false;
}
}
}
}
private Color myHighlightColor = Color.Empty;
}

Walter,
I have the link working nicely. I need to set the hover delay to a smaller value (10). I keep a static variable to keep track of the link that is hilighted so that I can turn the hilight off when the event occurs again. I actualy don’t use the hilight property but just change switch the Pen with a Pen of a different color. That gets the effect I want.
I have not been able to get the code sample to work yet. I have not played with this much. I’m not sure where it gets called as I’m not getting any effect when I hover over an goIconicNode. Do I call HilightColor from some event?

Actually, it just occurs to me that you are probably using version 2.3, so you can make use of the new GoView.ObjectEnterLeave event and corresponding GoObject.OnEnterLeave method, instead of using GoView.ObjectHover and GoView.BackgroundHover events, GoObject.OnHover method, and maybe setting GoView.HoverDelay.
You needed to add an OnEnterLeave method override. The class just demonstrated how to add a highlight effect to a GoIconicNode by using a GoRoundedRectangle with a thick Pen. I have updated the code, above.

Walter,
I am using the express product so the example code above will not work. Apparently, you are using groups which is not part of express. Can this be done (hilighting of the node) without groups.
I get the following compile errors with your code:

C:\projects\DiagramView\SbIconicNode.cs(30): ‘Northwoods.Go.GoGroup.InsertBefore(Northwoods.Go.GoObject, Northwoods.Go.GoObject)’ is inaccessible due to its protection level

C:\projects\DiagramView\SbIconicNode.cs(31): The name ‘AddChildName’ does not exist in the class or namespace ‘DiagramView.SbIconicNode’

Yes, you can instead override Paint to draw the “highlight” before calling the base method, if the HighlightColor isn’t Color.Empty, or if some boolean property that you define instead of HighlightColor is true.
You’ll also need to override ExpandPaintBounds to account for the fact that you are painting beyond the bounds of the node–i.e. beyond the union of the bounds of all of the child objects of the node.
I’m a little busy now, so I can’t whip up this little code delicacy, but it’s quite simple. I suppose you could look at the other classes that override Paint and ExpandPaintBounds.

[Serializable]
public class LitNode2 : GoIconicNode {
public LitNode2() {}
public override void Paint(Graphics g, GoView view) {
Color c = this.HighlightColor;
if (c != Color.Empty && this.Icon != null) {
RectangleF r = this.Icon.Bounds;
r.Inflate(myBorder, myBorder);
SolidBrush b = new SolidBrush©;
g.FillRectangle(b, r);
b.Dispose();
}
base.Paint(g, view);
}
public override RectangleF ExpandPaintBounds(RectangleF rect, GoView view) {
if (this.Icon != null) {
RectangleF r = this.Icon.Bounds;
r.Inflate(myBorder, myBorder);
return RectangleF.Union(r, base.ExpandPaintBounds(rect, view));
} else {
return base.ExpandPaintBounds(rect, view);
}
}
public override bool OnEnterLeave(GoObject from, GoObject to, GoView view) {
if (to == this)
this.HighlightColor = Color.Red;
else
this.HighlightColor = Color.Empty;
return true;
}
public Color HighlightColor {
get { return myHighlightColor; }
set {
if (myHighlightColor != value) {
myHighlightColor = value;
InvalidateViews();
}
}
}
private const float myBorder = 3;
private Color myHighlightColor = Color.Empty;
}