Drawing graphics and responding to events
Peter Osucha <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
I'm looking for 'better' ways to handle/track mouse events for the following... I have a panel on which I have drawn a 20x20 array of small circles using Graphics.DrawEllipse(). For each of the circles, I created an object (myCircle) that holds information about the circles location within the panel (the rectangle it is within and the actual circle center and radius). I am then handling the MouseMove event of the panel to effect a 'hover' type action (ie, I just change the color of the circle if the mouse moves over it). To do this, I get the mouse coordinates inside the panel and then loop through all the myCircle objects looking for a coordinate match. If one is found, then I change the color of the circle, etc. Although this works, it certainly doesn't seem that efficient. Can anyone suggest another direction I might want to try to create this behavior? Other actions will be added as I move forward - like the ability to change the color of a many circles by 'dragging' a box around them etc. It just seems that this 'loop over all myCircle objects checking for coordinate matches' isn't the best approach. Sincerely, Peter