/// <summary> /// Each method below displays the appropriate /// table that correponds to each MainWindow button. /// The only exception is the DisplayCompare method. /// That method displays the compare window. /// </summary> private void DisplayPassingStats(object sender, RoutedEventArgs e) { List <object> stats = new List <object>(); if (searchBar.Text.Equals("")) { List <Player> players = controller.PlayerSort(4); for (int i = players.Count - 1; i >= 0; i--) { int passingYds = players[i].SeasonStats.PassingYds; int passingTds = players[i].SeasonStats.PassingTds; int interceptions = players[i].SeasonStats.Interceptions; if (passingYds != 0 || passingTds != 0 || interceptions != 0) { stats.Add(new PassingStats(players[i].Name, passingYds, passingTds, interceptions)); } } } else { try { Player player = controller.GetPlayer(searchBar.Text); stats.Add(new PassingStats(player.Name, player.SeasonStats.PassingYds, player.SeasonStats.PassingTds, player.SeasonStats.Interceptions)); } catch (Exception) { MessageBox.Show("Player not found", "Error"); } } DataContext = new DataGridTable(stats); }
private void DisplayReceivingStats(object sender, RoutedEventArgs e) { List <object> stats = new List <object>(); if (searchBar.Text.Equals("")) { List <Player> players = controller.PlayerSort(8); for (int i = players.Count - 1; i >= 0; i--) { int recYds = players[i].SeasonStats.RecYds; int recTds = players[i].SeasonStats.RecTds; int catches = players[i].SeasonStats.Catches; if (recYds != 0 || recTds != 0 || catches != 0) { stats.Add(new ReceivingStats(players[i].Name, recYds, recTds, catches)); } } } else { try { Player player = controller.GetPlayer(searchBar.Text); stats.Add(new ReceivingStats(player.Name, player.SeasonStats.RecYds, player.SeasonStats.RecTds, player.SeasonStats.Catches)); } catch (Exception) { MessageBox.Show("Player not found", "Error"); } } DataContext = new DataGridTable(stats); }
private void DisplayDefenseStats(object sender, RoutedEventArgs e) { List <Team> teams = controller.TeamSort(1); List <object> stats = new List <object>(); bool foundSearch = false; if (searchBar.Text.Equals("")) { foundSearch = true; foreach (Team team in teams) { int interceptions = team.Interceptions; int sacks = team.Sacks; int points = team.Points; int tds = team.TD; if (interceptions != 0 || sacks != 0 || points != 0 || tds != 0) { stats.Add(new DefenseStats(team.Name, interceptions, sacks, points, tds)); } } } else { foreach (Team team in teams) { if (string.Equals(searchBar.Text, team.Name, StringComparison.OrdinalIgnoreCase)) { int interceptions = team.Interceptions; int sacks = team.Sacks; int points = team.Points; int tds = team.TD; stats.Add(new DefenseStats(team.Name, interceptions, sacks, points, tds)); foundSearch = true; break; } } } if (foundSearch) { DataContext = new DataGridTable(stats); } else { MessageBox.Show("Team not found", "Error"); } }