Hi,
I want to show a highlighted part of a node when another node is being dragged close to it.
So far, I've done that by adding the following method to UpdateModify and CompleteModify of the node
protected virtual void HighlightConnectionPointOfClosestNode(Point current, InteractionState ist)
{
if (ist.AdjustmentHandle == 8)
{
var nearbyNode = Parent.GetNearestNode(current, 25, this);
if (nearbyNode != null && nearbyNode is BR_Shape)
{
BR_Shape nearby_Node = nearbyNode as BR_Shape;
nearby_Node.highlightConnectionPoint();
}
else
{
doNotHighlightConnectionPoint();
}
}
}
The other methods needed are
bool shouldHighlight = false;
private void highlightConnectionPoint()
{
shouldHighlight = true;
Repaint();
}
private void doNotHighlightConnectionPoint()
{
shouldHighlight = false;
Repaint();
}
In the override of Draw I have
double highlightmargin = 2;
bottomFittingCorner = new PathFigure(new Point(width, height + highlightmargin), new[]
{
new LineSegment(new Point(15, height + highlightmargin), true),
new LineSegment(new Point(10, height-7 + highlightmargin), true),
new LineSegment(new Point(5, height + highlightmargin), true),
new LineSegment(new Point(0, height + highlightmargin), true),
new LineSegment(new Point(10, height-7 + highlightmargin), false),
new LineSegment(new Point(15, height + highlightmargin), false)
}, false);
if (shouldHighlight)
{
graphics.DrawGeometry(Brush, drawingPen, shape);
drawingPen = new Pen(Brushes.White, StrokeThickness * 3);
var highlightedShape = new PathGeometry();
highlightedShape.Figures.Add(bottomFittingCorner);
graphics.DrawGeometry(Brushes.Transparent, drawingPen, highlightedShape);
}
else
{
graphics.DrawGeometry(Brush, drawingPen, shape);
}
When I drag a node close, the highlighted part is shown but when I drag the node away, the other node does not go back to the default shape (without highlighting). Any ideas why this is happening?
Thanks in advance!
Vincent