views:

46

answers:

0

I am using SlimDX's Direct2D API to render a waveform in a Panel control. Unfortunately, resizing the control causes the RenderTarget to not resize itself properly. It resizes in "jumps", meaning that it only resizes after dragging the resize grip on the form a few pixels away. This results in behavior like this:

my form

The panel backcolor is gray to emphasize the problem.

In my code, I handle the Panel's Resize event, and raise a flag to resize the RenderTarget on the next render cycle, like so:

private void pnlVisualize_Resize(object sender, EventArgs e) {
    pendingresize = true;
}
public void RenderFrame() {
    while(pendingresize) {
        wr.Resize(pnlVisualize.Size);
        pendingresize = false;
    }
...

Any ideas? I've looked through the docs on MSDN, but they don't mention anything like this. I do think that the RenderTarget actually changes its size, but it neglects to render anything in the added area for some reason.