MrNobody,
The best way I can think of doing this would be to have a class that
represents the shapes that you are going to perform hit tests against. Of
course, you would start off from an abstract class.
This class would have two methods, one to indicate the max rectangle
that it could represent, given the shapes size, and then a method to see if
the coordinates actually fall within the shape. The reason for two passes
is that some shapes could be overly complex, and finding out if a point
exists in the shape could be a lengthy calc. This way, by saying "the max
area that my shape can take up is this", you can perform a simple calc to
see if the point has a shot of existing in the shape. If it does, you can
then do the second, lengthy calc and see if the point falls in the shape.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
(E-Mail Removed)
"MrNobody" <(E-Mail Removed)> wrote in message
news:81A30F5A-750C-4B51-A197-(E-Mail Removed)...
> I'm going to be creating shapes in a OnPaint method of an extended Panel
> object, and I need mouse event functionality (onClick, onMouseOver) that
> kind
> of stuff... what's the best way to go about doing this? Are there any
> design
> patterns, algorithms for best performance?
>
> Best way to translate mouse's x,y coords into a shape on my Panel