c# - Is the drawing surface of the Graphics object in PaintEventArgs relative to the ClipRectangle? -


Overriding OnPaint in my control Sometimes, the control rectangle ( E.ClipRectangle ) becomes invalid, which is smaller than the control size.

In my OnPaint method, when I attract the GDI + surface (by object), will I start to relate or control? For example, suppose my control is 800 x 600 pixels. If I call:

  invalid (new rectangle (42, 0, 100, 600)); I drag a string in   

and then on OnPaint :

  e.Graphics.DrawString ("no panic.", New font ("Aerial", 12), New brush (Color. Red), 0, 0);   

Is the string visible on my left hand control, or 42 pixels from the left?

The drawing should always be relative to the client rectangle of control. This e There is a common bug in relation to Kleperracktengal, it also works for a long time on the arrow, because it does not invalidate any window, when you drag it to another window. When Aero closes, it produces very interesting graphics effects, it seems that the graphics are equal to an echo.

To customize your drawing code, you should only use E. ClipRectangal, when you completely exit outside the clipping area, leave its share. Graphics already does a great job of automatic clipping, paying such a clip test is not easy. And it is very difficult when everything is not cut, then never optimize it. There is a little bit left with Arrow.

Comments