Hi everyone!
I have a question about GDI+.
float deltaY = 0;
// the onPaint handler of my control
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.TranslateTransform(0, deltaY);
GenerateGraphics(e.Graphics);
}
In an OnClick event, I change the value of deltaY, and invalidate the
control.
Everything works fine - the graphics is then moved upwards or downwards -
depending
what the deltaY is set to, but it's very slow.
So I figured I should use BufferedGraphics and do something like this:
BufferedGraphics buff;
float deltaY = 0;
....somewhere in the code...
InitializeBufferedGraphics(buff);
....elsewhere in the code...
GenerateGraphics(buff.Graphics);
// this draws strings and rectangles and stuff on the buffered graphics
// this happens only when graphics needs to be changed, and not in the
OnPaint handler like it used
// to be earlier
// the onPaint handler of my control
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.TranslateTransform(0, deltaY);
buff.Render(e.Graphics);
}
However, the TranslateTransform has absolutely no effect on buff.Render. -
the graphics rendered
from bufferedGraphics is not moved anywhere.
Is there a way to render the BufferedGraphics object over the OnPaint's
Graphics object, but translated?