Basically I have to make a Dispatcher timer, store the variable in the array as it counts then display the history array in a text box when I click the rawDataButton. For some reason my array only shows the most recent ones and never stores in the array, here's my code
DispatcherTimer timer = new DispatcherTimer();
MeasureLengthDevice dg = new MeasureLengthDevice();
int mostRecnet = 0;
int[] arr = new int[10];
private void StartCollectingDataButton_Click(object sender, RoutedEventArgs e)
{
timer.Interval = new TimeSpan(0, 0, 1);
timer.Start();
timer.Tick += timer_Tick;
}
private void timer_Tick(object sender, object e)
{
mostRecnet = dg.GetMeasurement();
recentDataTextBlock.Text = mostRecnet.ToString();
for(int i = 0; i < arr.Length; i++)
{
arr[i] = mostRecnet;
}
}
private void stopCollectingDataButton_Click(object sender, RoutedEventArgs e)
{
timer.Stop();
}
private void rawDataButton_Click(object sender, RoutedEventArgs e)
{
for (int i = 0; i < arr.Length; i++)
{
mostRecnet = arr[i];
rawDataTextBox.Text += arr[i].ToString() + "\n";
}
}