public static void RefreshAll(ListView listView, MeasurementSystemType roadUom, MeasurementSystemType powerUom) { foreach (ListViewItem item in listView.Items) { (item as LapListViewItem).Refresh(roadUom, powerUom); } }
public void Refresh(MeasurementSystemType roadUom, MeasurementSystemType powerUom) { string[] text = SubItemStrings(LapItem, roadUom, powerUom); // Update the speed column header text accordingly this.ListView.Columns[3].Text = roadUom == MeasurementSystemType.Metric ? "km/h" : "mi/h"; this.ListView.Columns[4].Text = roadUom == MeasurementSystemType.Metric ? "km" : "mi"; this.ListView.Columns[5].Text = powerUom == MeasurementSystemType.Metric ? "w/kg" : "Avg"; for (int i = 0; i < text.Length; i++) { this.SubItems[i].Text = text[i]; } }
private static string[] SubItemStrings(LapViewControl.LapDetailItem item, MeasurementSystemType roadUom, MeasurementSystemType powerUom) { return(new string[] { "", // dummy first column item.LapNumber.ToString(), $"{item.LapTime.Minutes:0#}:{item.LapTime.Seconds:0#}", roadUom == MeasurementSystemType.Metric ? $"{item.LapSpeedKph:0.0}" : $"{item.LapSpeedMph:0.0}", roadUom == MeasurementSystemType.Metric ? $"{item.LapDistanceKm:0.0}" : $"{item.LapDistanceMi:0.0}", powerUom == MeasurementSystemType.Metric ? $"{item.LapAvgWkg:0.00}" : $"{item.LapAvgWatts}", $"{item.TotalTime.Hours:0#}:{item.TotalTime.Minutes:0#}:{item.TotalTime.Seconds:0#}" }); }
public LapListViewItem(LapViewControl.LapDetailItem item, MeasurementSystemType roadUom, MeasurementSystemType powerUom) : base(SubItemStrings(item, roadUom, powerUom)) { this.LapItem = item; this.Name = item.LapNumber.ToString(); // this is the Key in the listview.items collection }