Mouse-over highlighting

Walter,

I have been trying for sometime now to attempt to change either the background border color, selected rectangle color etc. of a GoTextNode and am having no luck.
Basically, all I want to do is change the color of the currently "moused over" node in a DragDrop/DragOver operation.
My current setup is a custom GoTextNode (called PersonNode) that has an image for a background.
Thanks,
Ami

One can’t just set the color of an Image, so I assume you want to show a different Image during a mouse-over.

Here's the code for regular GoTextNodes, which have a GoShape as the Background object, in a GoView.ObjectEnterLeave event handler:
[code] private Brush savedBrush;
private void goView1_ObjectEnterLeave(object sender, GoObjectEnterLeaveEventArgs e) {
GoTextNode from = (e.From != null ? e.From.ParentNode as GoTextNode : null);
GoTextNode to = (e.To != null ? e.To.ParentNode as GoTextNode : null);
if (from != null) {
((GoShape)from.Background).Brush = savedBrush;
savedBrush = null;
}
if (to != null) {
savedBrush = ((GoShape)to.Background).Brush;
((GoShape)to.Background).Brush = Brushes.Red;
}
}[/code]
In your case, you'll need to cast the Background object to a GoImage, and you'll have to either set the GoImage.Name or the GoImage.Index property, as appropriate.

Walter,

I have tried (unsucessfully) to change either the rectangle border color, or default green "object selected" color for a GoTextNode. When I say "tried" I really don't have any code to show for it b/c I don't even know where to start. Why isn't there some method like "node.rect.ChangeColor()"?
Basically, I am trying to implement a DragDrop operation and while the user is Dragging (i.e. DragOver) a node, I want the rectangle's color to change in order to signify that it is the currently "hovered over" node.
I have a custom GoTextNode called PersonNode that inherits from GoTextNode and uses an image for a background. No shapes.
How can I go about executing code that will draw/show a green (or whatever color I choose) rectangle as a border around the node when a user hovers over it and then reset the rectangle to a transparent color when the user leaves the nodes bounds?
Thanks in advance.
-Ami

I’ve (again) moved your reply from the topic about tooltips to this new topic, since you aren’t asking about tooltips.

The code I've shown in my previous reply is all you need for a regular GoTextNode. If you want to change the outline instead of the fill for the rectangle, you should save and change the GoShape.Pen instead of the GoShape.Brush.
However, if you have replaced the standard Background with a GoImage, then you can't do that, because as I said earlier, you can't change the color of an Image without doing some fancy Image manipulation. (That's quite do-able, but is quite unnecessary.) But if your Image has enough transparent areas, perhaps you can do what the LitIconicNode example class does, in the Demo1 sample.

Sorry, for posting in the wrong place. The reason I reposted was because I though my first post was lost.

As for your suggestion, I have been able to manipulate the background image but I was hoping to not have to create all the images I am using from scratch, each having a transparent border.
Is there no way for me to even place some other random GoTextNode that doesn't use an image for a background in the same location (i.e. X/Y coords) as the currently moused over node that happens to be 2 pixels higher and 2 pixels wider (in order so that I get the effect of a pixel added to the top, bottom, left and right of the moused over node) than the current node I am mousing over?
-Ami

If you do have transparent areas in your image, why don’t you use the LitIconicNode example class’s technique for doing highlighting?

But I don’t have any transparent areas in my images. I would have to recreate all of my images to have a transparent border in order to accomplish this.

Well, you could still use the same technique of overriding Paint – just draw or fill a larger rectangle. You’ll also need to override ExpandPaintBounds, so that the GoView knows that you are painting beyond the Bounds.