Double buffering C#
- by LmSNe
Hey,
I'm trying to implement the following method:
void Ball::DrawOn(Graphics g);
The method should draw all previous locations(stored in a queue) of the ball and finally the current location. I don't know if that matters, but I print the previous locations using g.DrawEllipse(...) and the current location using g.FillEllipse(...).
The question is, that as you could imagine there is a lot of drawing to be done and thus the display starts to flicker much. I had searched for a way to double buffer, but all I could find is these 2 ways:
1) System.Windows.Forms.Control.DoubleBuffered = true;
2) SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
while trying to use the first, I get the an error explaining that from in this method the Property DoubleBuffered is inaccessible due to its protection level. While I can't figure how to use the SetStyle method.
Is it possible at all to double buffer while all the access I have is to the Graphics Object I get as input in the method?
Thanks in Advance,