|
Ask you,
// Code 1
Graphic g = panel.CreateGraphics ();
g.DrawEllipse (new Pen (Color.Red), 50, 50, Math.Abs (MousePoint.X-50), Math.Abs (MousePoint.Y-50));
The result of this will be that the place the mouse walks over becomes red, that is, many circles are drawn, but in fact I only need one.
If you modify the code:
// Code 2
Graphic g = panel.CreateGraphics ();
if (oldPoint! = Point.Empty)
g.DrawEllipse (new Pen (panel.BackColor), 50, 50, Math.Abs (MousePoint.X-50), Math.Abs (MousePoint.Y-50));
g.DrawEllipse (new Pen (Color.Red), 50, 50, Math.Abs (MousePoint.X-50), Math.Abs (MousePoint.Y-50));
This is correct, but if the background painting is added to the control, the effect is almost the same as above, but the color is different, and the background painting is not visible.
Ask you how to write the code, but you can't do it in the Paint event of the control.
Thank you in advance for your help |
|