private void dgRaces_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex != 0 && e.RowIndex != -1) { Race race = this.dgRaces.Rows[e.RowIndex].DataBoundItem as Race; this.ShowSingleRaceResults(race); } }
private void ShowSingleRaceResults(Race race) { if (race != null) { frmRaceResults fRaceResults = new frmRaceResults(race); fRaceResults.ShowDialog(); } }
private void dgRaces_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0 && e.RowIndex != -1) { bool selected = (bool)this.dgRaces.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; Race race = (Race)this.bsRaces[e.RowIndex]; this.rdp.SelectRace(race, selected); } }
public async Task <Race> GetRaceDetailsAsync(Race race) { try { var raceIds = new List <int>(); raceIds.Add(race.Id); var dto = await this.nratingsApiClient.GetRacesDetailsAsync(raceIds); Race result = race; IList <Driver> drivers = dto.Drivers.Select(d => new Driver() { Id = d.Id, Name = d.Name }).ToList(); IList <Car> cars = dto.Cars.Select(d => new Car() { Id = d.Id, Name = d.Name }).ToList(); IList <RaceState> raceStates = dto.RaceStates.Select(rs => new RaceState() { Id = rs.Id, Name = rs.Name, IsDNFMechanical = rs.IsDNFMechanical, IsDNFCrash = rs.IsDNFCrash }).ToList(); race.RaceResults = dto.RaceResults.Select(rr => this.ToDomainRaceResult(rr, drivers, cars, raceStates)).ToList(); race.PitStopDatas = dto.RacePitStopDataList.Select(p => this.ToDomainPitStopData(p, drivers, new List <Race>() { race })).ToList(); race.LoopDatas = dto.RaceLoopDataList.Select(l => this.ToDomainLoopData(l, drivers, new List <Race>() { race })).ToList(); return(result); } catch (Exception ex) { return(null); } }
private void CorrectRaceSelections() { foreach (DataGridViewRow dgr in this.dgRaces.Rows) { Race race = dgr.DataBoundItem as Race; if (race != null && this.rdp.SelectedRaces.Contains(race)) { dgr.Cells["Select"].Value = true; } else { dgr.Cells["Select"].Value = false; } } }
private void dgRaces_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { Race race = this.dgRaces.Rows[e.RowIndex].DataBoundItem as Race; this.ShowSingleRaceResults(race); }
private void chkSeasons_ItemCheck(object sender, ItemCheckEventArgs e) { if (e.NewValue == CheckState.Checked && this.chkSeasons.CheckedItems.Count >= maxSeasons) { MessageBox.Show("You have reached the maximum of " + maxSeasons.ToString() + " selected seasons. Uncheck another season first.", "Season limit reached", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); if (!this.seasonIndicesToUncheck.Contains(e.Index)) { this.seasonIndicesToUncheck.Add(e.Index); } } else { Season season = this.chkSeasons.Items[e.Index] as Season; if (season != null) { if (e.NewValue == CheckState.Checked) { IList <Race> seasonRaces = this.rdp.GetRaces(season); if (seasonRaces != null) { foreach (Race race in seasonRaces) { this.bsRaces.Add(race); this.dgRaces.Rows[this.bsRaces.IndexOf(race)].Cells["Select"].Value = false; } } } else { List <Race> racesToRemove = new List <Race>(); foreach (object o in bsRaces) { Race race = o as Race; if (race != null) { if (race.Season.Id == season.Id) { racesToRemove.Add(race); } } } foreach (Race race in racesToRemove) { this.bsRaces.Remove(race); this.rdp.SelectRace(race, false); } if (this.chkSeasons.CheckedItems.Count == 0) { this.CleanUpRaces(); } } //SORT THE RACES BY DATE List <Race> allRaces = this.bsRaces.DataSource as List <Race>; if (allRaces != null) { allRaces.Sort(); this.dgRaces.Refresh(); this.CorrectRaceSelections(); } //READJUST THE COLUMN WIDTHS this.dgRaces.AutoResizeColumns(); } if (this.bsRaces.Count > 0) { this.EnableRaceSelectionButtons(true); } else { this.EnableRaceSelectionButtons(false); } } }