private void updateScreenTimer_Tick(object sender, EventArgs e) { int count = rFile.ReadOneLine(); if (count > 10) { count = rFile.ParseLine(); } int time = rFile.ms; if (time == 0 || time > 1000) { time = 50; } decimal dTime = time / numericUpDown1.Value; time = System.Convert.ToInt32(dTime); seconds = (float)(rFile.ms2 - 1000) / 1000.0f; string s = seconds.ToString(); secsLabel.Text = s; updateScreenTimer.Interval = time; if (count > 10) { // file end not reached yet updateScreenTimer.Start(); updateGauges(rFile); } else { updateScreenTimer.Enabled = false; } }
private void Simulate_button_Click(object sender, EventArgs e) { DialogResult result; result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { string path1 = openFileDialog1.FileName; try { if ((raceFileStr = openFileDialog1.OpenFile( )) != null) { // Insert code to read the stream here. raceFileStr.Close(); rFile = new raceFileClass(); rFile.Open(openFileDialog1.FileName); int count = rFile.ReadOneLine(); if (count > 10) { count = rFile.ParseLine(); } int time = rFile.ms; if (time == 0 || time > 1000) { time = 50; } updateScreenTimer.Interval = time; updateScreenTimer.Enabled = true; updateScreenTimer.Start(); } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } } }