I have 2 (VisualBasic.PowerPacks)LineShapes on my form:
When I click on one of them, a specific context menu appears. The lines can be moved by the user. A context Menu is associated with a line. However, if the user clicks in the intersection point(if exists) I need to display an other menu, that will select one of intersection lines to perform an action.
Now, I wonder how to detect that 2 (or more) lines are intersected in the click point, because an other context-menu should appear in this case.
What I tried to do:
private void shapeContainer1_MouseDown(object sender, MouseEventArgs e)
{
// right click only
if (e.Button == MouseButtons.Right)
{
LineShape target =
(shapeContainer1.GetChildAtPoint(e.Location) as LineShape);
if (target != null)
{
Console.WriteLine(new Point(target.X1, target.Y1));
}
}
}
I suppose I have only LineShapes in the container. This told, the ShapeContainer will not raise a MouseDown event if any LineShape will be under the mouse.
But this code gives me only the mostTop line, but I want a list of others too.