void showLaps() { Driver driver = lbDrivers.SelectedItem as Driver; lbLaps.Items.Clear(); if (driver != null && driver.Laps.Count > 0) { int limit = (int)nudLimit.Value; Lap best = driver.Laps[0]; foreach (Lap lap in driver.Laps) { if (limit > 0) { if (lap.Time > limit) { lbLaps.Items.Add(lap); } } else { lbLaps.Items.Add(lap); } if (lap.Time < best.Time) { best = lap; } } tbBestLap.Text = best.ToString(); } else { tbBestLap.Clear(); } }
private void loadLaps() { Driver d = lstDrivers.SelectedItem as Driver; lstLaps.Items.Clear(); if (d != null && d.Laps.Count > 0) { int limit = (int)numTime.Value; Lap najdobar = d.Laps[0]; int najdobarVreme = najdobar.Minutes * 60 + najdobar.Seconds; foreach (object obj in d.Laps) { Lap l = obj as Lap; int lVreme = l.Minutes * 60 + l.Seconds; if (limit > 0) { if (najdobarVreme > limit) { lstLaps.Items.Add(l); } } else { lstLaps.Items.Add(l); } if (najdobarVreme > lVreme) { najdobar = l; } } tbNajbrz.Text = najdobar.ToString(); } else { lstLaps.Items.Clear(); } if (lstLaps.Items.Count == 0) { tbNajbrz.Text = null; } }
private void ComputeBestLap(int secondsTreshold) { int minSeconds = Int32.MaxValue; Lap minLap = null; foreach (Lap item in lstKrugovi.Items) { int lapSeconds = item.ToSeconds(); if (lapSeconds > secondsTreshold && lapSeconds < minSeconds) { minSeconds = lapSeconds; minLap = item; } } if (minLap != null) { txtNajdobar.Text = minLap.ToString(); } else { txtNajdobar.Text = ""; } }