Re: Drawing graphics and responding to events
John Brett <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
> Thanks for the reply. The case I have is a very simple one - all the > shapes are on a grid and there is no overlap. The circles cannot be > moved at runtime. You should be able to identify the candidate circle programmatically, in that case - i.e. work out the grid cell the mouse occupies, and then do a single comparison to find out if it is within the circle. So you'd adjust your mouse location to be relative to the top left of the grid, then divide by the grid size, rounding down. This will give you the grid reference for the mouse, then you can use the method I posted earlier to calculate the distance between the mouse and the centre of the circle. More air-code: Point mousePos; mousePos = mousePos - gridRectangle.TopLeft; int gridX= mousePos.X / gridSize.X; int gridY= mousePos.Y / gridSize.Y; Circle c= m_Circles[gridX][gridY]; &c.