I use the code below to change the color of the link and its nodes when mouse hoovers on link:
public override bool OnEnterLeave(GoObject from, GoObject to, GoView view)
{
// When on link
if (to == this)
{
oldPen = this.Pen;
oldColor = ((GoTextNode)this.ToNode).Shape.BrushColor;
this.Pen = new Pen(Color.YellowGreen, oldPen.Width);
this.Pen.DashStyle = oldPen.DashStyle;
((GoTextNode)this.FromNode).Shape.BrushColor = Color.YellowGreen;
((GoTextNode)this.ToNode).Shape.BrushColor = Color.YellowGreen;
}
else
{
this.Pen = oldPen;
((GoTextNode)this.FromNode).Shape.BrushColor = oldColor;
((GoTextNode)this.ToNode).Shape.BrushColor = oldColor;
}
return true;
}
However, the problem is that when I select a link, delete it by pressing the “Delete” button on keyboard and then move the mouse, this triggers the OnEnterLeave method which changes the colors of the nodes. (Note that I dont move the mouse until after I press the delete button). How can I make sure that this method is not called or at least it does not execute color changing statements when it no longer exists ? I tried to use BeingRemoved property but it is false everytime. Any ideas ?