public static DataTable GetTimesOfDay(TimeType type) { DataTable timeTable = new DataTable("TimeOfDay"); timeTable.Columns.Add(new DataColumn("TimeType")); timeTable.Columns.Add(new DataColumn("Time")); if (type == TimeType.Hour) { for (int i = 0; i < 24; i++) { DataRow row = timeTable.NewRow(); row["TimeType"] = type.ToString(); row["Time"] = i.ToString("d2"); timeTable.Rows.Add(row); } } if (type == TimeType.Minute) { for (int i = 0; i < 60; i += 15) { DataRow row = timeTable.NewRow(); row["TimeType"] = type.ToString(); row["Time"] = i.ToString("d2"); timeTable.Rows.Add(row); } } if (type == TimeType.Second) { for (int i = 0; i < 60; i += 15) { DataRow row = timeTable.NewRow(); row["TimeType"] = type.ToString(); row["Time"] = i.ToString("d2"); timeTable.Rows.Add(row); } } if (type == TimeType.All) { for (int i = 0; i < 24; i++) { for (int j = 0; j < 60; j += 15) { DataRow row = timeTable.NewRow(); row["TimeType"] = type.ToString(); row["Time"] = i.ToString("d2") + ":" + j.ToString("d2") + ":00"; timeTable.Rows.Add(row); } } } return timeTable; }
protected string PrintTimeValue( double v, TimeType t ) { return (t == TimeType.Time ? v.ToString() : (t == TimeType.NLaps) ? v + " Laps" : t.ToString()); }