-4

Visual studio says there is an OverflowException unhandled

//draws the point.
public void Draw(Graphics g)
{
    float radius = 3; //radius of the circle which describes the point.

    // draws the circle of the point, with parameters of the square which bounds the circle.
    g.DrawEllipse(new Pen(Color.Black, 6F), float.Parse((this.X - radius).ToString()), float.Parse((this.Y - radius).ToString()), 2 * radius, 2 * radius);
}
Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
  • 2
    Why are you parsing the result of `ToString()` here? Or to put that a different way, what is the type of `this.X` and `this.Y` that is causing you to need to do that? – Rowland Shaw Jan 14 '16 at 16:37
  • the X,Y were double, but the g object takes float type parameters. I found the problem. thank you for helping! :) – فادي الصفدي Jan 17 '16 at 12:29

1 Answers1

-1

you're ending up with point values outside graphic boundaries. check your this.X and this.Y values. see What are the hard bounds for drawing coordinates in GDI+?

Community
  • 1
  • 1
ZagNut
  • 1,431
  • 15
  • 20