I have 2 (VisualBasic.PowerPacks) LineShapes in my form:
alt text http://lh4.ggpht.com/_1TPOP7DzY1E/S2cIJan7eHI/AAAAAAAADAw/qwA0jFHEbBM/s800/intersection.png
When I click on one of them, a specific context menu appears. Lines can be moved by the user. The context menu is associated with the line. However, if the user clicks at the intersection point (if exists), I need to display another menu that will select one of the intersection lines to perform the action.
Now itβs interesting how to detect that 2 (or more) lines intersect at the click point, because in this case another context menu should appear.
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 assume that in the container there are only LineShapes. This said that ShapeContainer would not raise a MouseDown event if any LineShape was under the mouse.
But this code only gives me the largest line, but I need a list of others as well.
source share