I have a panel on a form. On this panel there are drawn a few lines. I would like to know how to detect when the Mouse is above one of the lines and get the details of the line.
>Solution :
-
Keep track of your lines in a data structure, e.g. an array, as you draw them.
-
Create a handler for the panel’s MouseMove event.
-
In the handler, iterate over the (array of) lines and compute the distance from the mouse’s position to the nearest point on the line (see this article for the math).
-
If the distance is below a certain threshold, display the information.