Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

WaveformGraph Print Problems

Hello,

I am having trouble printing WaveformGraphs using C#. I have two WaveformGraphs with each on a different tab page. If I start my application and load a file, only the first WaveformGraph tab is displayed. If I print this WaveformGraph, everything works fine. If I print the second WaveformGraph *without* viewing it first, the print out is incorrect. See attached screenshot "BadWaveformGraphPrintout.png". If I select the second WaveformGraph tab and print, it works. See attached screenshot "GoodWaveformGraphPrintout.png".

My code is very simple and was borrowed from the printing samples provided with Measurement Studio .NET:

Graphics g = e.Graphics;
Rectangle bounds = e.MarginBounds;
waveformGraphOne.Draw
( new ComponentDrawArgs( g, bounds ) ) ;
//waveformGraphTwo.Draw( new ComponentDrawArgs( g, bounds ) ) ;

I know I can programmatically select the tab and then print, but this seems like a hack. Any ideas on how to get this working?

Thanks in advance!
Derek
Download All
0 Kudos
Message 1 of 3
(3,949 Views)
This is a bug in the Measurement Studio 7.0 version of the graph. The problem is that the Draw method on the graph doesn't work properly when the Visible property is false. The control's container (the containing tab page in this case) sets the Visible property to false when the tab page is not visible, then sets the Visible property to true when it becomes visible. This will be fixed in a future version of Measurement Studio.

There are a couple of workarounds in the meantime. Ultimately, you need to call Draw on a WaveformGraph whose Visible property is true. One way you could accomplish that would be to dynamically create a graph, configure it the way you want, then call Draw. This works because the default value of Visible is true, and it doesn't
get altered and the graph is not actually shown on screen because it's not added to a form's or child control's Controls collection.

You could also set the Visible property on the graph on the second tab page to true, but first you have to remove it from the tab page's controls collection since setting it will not actually take effect until the tab page is shown. After you call Draw, you could add it back to the controls collection, like this:

tabPage2.Controls.Remove(waveformGraph2);
waveformGraph2.Visible = true;
waveformGraph2.Draw(new ComponentDrawArgs(e.Graphics, e.MarginBounds));
tabPage2.Controls.Add(waveformGraph2);

This is a hack, too, but not as bad as showing the tab page since there's no visible change at runtime. Sorry for the inconvenience.

- Elton
Message 2 of 3
(3,949 Views)
Hi Elton,

As usual you came to the rescue!

Thanks again!
Derek
0 Kudos
Message 3 of 3
(3,949 Views)