I've got the following problem: I'm drawing a high-resoultion real-time graph. I fetch a floating-point value in my main loop and I want do draw this value to an existing instance structure (It is the graphics instance of the form).
To do this I must translate the whole graphics content by 1 in x-direction to draw my new point. The problem is, that the translation seems to effect the new points, but not the existing content.
The code (shortened) looks like this:
float oldval = 0;
Graphics gr = this.CreateGraphics();
public void IndependentThread(...)
{
float h = (float)this.Height;
Pen p = Pens.Pink;
while (condition_to_exit_loop)
{
float current = 0;
this.Invoke(new MethodInvoker(() => current = getVal())); //<-- funtion witch fetches the current value
gr.TranslateTransform(1, 0); //<--- I want to translate the existing content - not the new one
gr.DrawLine(p, 0, h * current, 1, h * oldval);
oldval = current;
}
}