Well, you have to override the OnMouseMove() method, naturally. You
could do some pythagorean calculations of your own in that method if
you wanted, but GraphicsPaths and Regions have the IsVisible() method
for checking if a point is contained (is "visible") within the
path/region, so if you just created a GraphicsPath that contains your
circle, you'd have an easier time.
First, create a GraphicsPath object and keep it as a member variable of
your user control. Call AddEllipse() on the GraphicsPath in the same
way you originally drew it on your UserControl using DrawEllipse(). In
your OnPaint() method or Paint Event handler method, call DrawPath() on
your GraphicsPath object rather than DrawEllipse().
For the actual testing, override the OnMouseMove() method, then call
IsVisible(e.X, e.Y) on your GraphicsPath to determine if the point is
inside your circle.
E.g:
public class CircleTest : UserControl
{
private GraphicsPath MyCircle;
public CircleTest()
{
MyCircle = new GraphicsPath();
MyCircle.AddEllipse(5, 5, 5, 5); // circle of radius 2.5 at (5,5)
}
private override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawPath(Pens.Black, MyCircle);
}
private override void OnMouseMove(MouseEventArgs e)
{
if(MyCircle.IsVisible(e.X, e.Y))
{
// hit-test positive... the cursor is over the circle.
}
}
}