Hi there,
i want to display a contextmenu on every Link inside my Diagram.
After creating the link, i am assigning a new instance of Controls.contextmenu.
i implemented a little routine inside MouseRightButtonDown
to change the brush to blue, after right click at this link.
private DiagramLinkCollection formerLinks = new DiagramLinkCollection();
private void ChangeLinkStroke(DiagramLinkCollection lc,
Brush brush)
{
ChangeLinkStroke(lc, brush, null);
}
private void ChangeLinkStroke(DiagramLinkCollection lc,
Brush brush,
DiagramLinkCollection store)
{
foreach (DiagramLink link in lc)
{
link.Stroke = brush;
link.StrokeThickness = 1;
link.HeadStroke = brush;
if (store != null)
{
link.StrokeThickness = 3;
store.Add(link);
}
}
}
private void flowchart_MouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
System.Windows.Point p = Mouse.GetPosition(Element);
System.Windows.IInputElement inp = Element.InputHitTest(p);
DiagramLink link = inp as DiagramLink;
if (link != null)
{
ChangeLinkStroke(formerLinks, Brushes.Black);
formerLinks.Clear();
DiagramLinkCollection lc = new DiagramLinkCollection();
lc.Add(link);
ChangeLinkStroke(lc, Brushes.Blue, formerLinks);
}
}
So far no problem.
But now i really have to hit the link with the right mouse button.
A bit too far left or right and i won't get any result the Link got clicked by right mouse button.
So i thought, let's increase the distance a hit gets recognized by setting
diagram.LinkHitDistance, but that only seems to have effects on left button clicks.
So how could i reach that for right clicks?
Thanks,
Dominic