Hi,
I don't find a solution for my problem. The important classes in my measurement program for this problem are:
public partial class Preview : Form
{
//...
private void Preview_Load(object sender, EventArgs e)
{
CreateZGC(numberOfGraphs); //Creation of the ZedGraphControls.
ShowZGC(); // Adds the ZedGraphControls to the form 'Preview'.
LabelGraph(); // Labels the axes and title of the ZGC.
drawDCMeasPoint(measArr); //measArr = test array, draws the points
//contained in the measArr in the ZGC.
}
//...
}
public class DC_Measurement : Measurement
{
//...
private DCMeasPoint[,] createDCMeasPointArray(DCSetPoint[,] setPointArr,
BackgroundWorker worker, Preview window)
{
//...here the program creates an DCMeasPointArray. This array contains the set voltage
// and the measured current. This is done in a loop.
}
}
public partial class mainWindow : Form
{
//...
private void buttonStart_Click(object sender, EventArgs e)
{
//...
//a new Preview window is created.
previewWindow = new Preview(selectedMeasurement.previewValues, selectedMeasurement, this);
// Start the asynchronous operation -> backgroundWorker1_DoWork()
if (!backgroundWorker1.IsBusy)
{
backgroundWorker1.RunWorkerAsync();
selectedMeasurement.OpenGraph(previewWindow); //THIS OPENS MY PREVIEW WINDOW
}
}
//...
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
// Gets the BackgroundWorker that raised this event.
BackgroundWorker worker = sender as BackgroundWorker;
// Worker starts measuring.
selectedMeasurement.measure(selectedMeasurement.calculatedArray, worker, previewWindow);
//...
}
//...
}
The Preview class creates an empty window. It contains methods which fill the empty window with ZedGraphControls, scales them and labels the axes.
Now the important part is, that when the program starts measuring the Preview window has to appear and WHILE measuring the points have to be dynamically be drawed in the ZedGraphControls. My methods work. I checked it by calling them in the Preview_Load()-method (you can see it in my code).
But when I want to draw it dynamically while measuring, the method drawDCMeasPoint() should be called in the createDCMeasPointArray()-method IN THE LOOP. So that every time a new voltage is set and the current is measured the drawDCMeasPoint()-method gets the array with the new added values.
The drawDCMeasPoint()-method clears all points contained in the ZGC and then draws the new curve with the new added point in it (every time the devices are set and values are measured a new point is drawed in the ZGC).
Maybe I called the methods wrong. This is what I did:
1) Like in the code above I created a new Preview window and showed it in the buttonStart_Click()-method.
2) I called the methods CreateZGC(), ShowZGC() and LabelGraph() still in the Preview_Load()-method.
3) I wrote the drawDCMeasPoint()-method in the loop of the createDCMeasPointArray().
The question is: What did I do wrong?
I also watched it with breakpoints, but I couldn't solve it. The program seems to call every mehtod and to do everything I wanted to do. But there is no curve in my graph.
It's a very complex program. I hope you could understand what I mentioned.
Thanks for reading and try to answer it.