private void BTN_MANAGE_LINEUPS_Click(object sender, RoutedEventArgs e) { Object item = CB_LIST_OF_TEAMS.SelectedItem; if (item is Team) { Team team = (Team)item; LineupListDlg dlg = new LineupListDlg(team, engine.StoredLineups[team.Abrv]); System.Windows.Forms.DialogResult result = dlg.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK && dlg.ApplyAsTemplate) { List <Team> teams = engine.TeamReportFile.getTeams(); foreach (Team otherTeam in teams) { if (team == otherTeam) { continue; } TeamLineup otherTeamLineup = LineupPersistence.lookupTeamLineup(engine.StoredLineups, otherTeam); dlg.applyConfigurationToAnotherTeam(otherTeamLineup); syncUpTheData(engine.StoredLineups); LineupPersistence.saveDatabase(engine.StoredLineups); } //Update the table! CB_LIST_OF_TEAMS_SelectionChanged(this, null); } else if (result == System.Windows.Forms.DialogResult.OK) { //Update the table! CB_LIST_OF_TEAMS_SelectionChanged(this, null); } } }
private void CB_LIST_OF_TEAMS_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (dialogInitialized) { if (CB_LIST_OF_TEAMS.SelectedItem is Team) { currentlySelectedTeam = (Team)CB_LIST_OF_TEAMS.SelectedItem; TeamLineup selectedTeamLineup = LineupPersistence.lookupTeamLineup(engine.StoredLineups, currentlySelectedTeam); System.Console.WriteLine(currentlySelectedTeam.Abrv + " contains " + selectedTeamLineup.Lineups.Count + " lineups."); List <Player> players = engine.TeamReportFile.getTeamBatters(currentlySelectedTeam); batterInfo.setPlayers(players); IUsageCalculator calculator = CalculatorFactory.getCalculator(USAGE_CALCULATOR, engine.TeamReportFile, currentlySelectedTeam); calculator.setOptions(CalculatorOptions.OPTION_IN_DIVISION_GAMES, engine.TeamLineupData.InDivisionGameCount); calculator.setOptions(CalculatorOptions.OPTION_OUT_DIVISION_GAMES, engine.TeamLineupData.OutofDivisionGameCount); //TODO: Add UI element for Target At Bats calculator.setOptions(CalculatorOptions.OPTION_TARGET_AT_BAT, 615); engine.BalanceAtBats = balanceUsage.buildTable(calculator); updateWorkbook(currentlySelectedTeam, players); fillBoxesWithSavedDataData(); BTN_MANAGE_LINEUPS.IsEnabled = true; } } }