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;
                }
            }
        }
示例#3
0
        public void testStoreAndLoadPersistenceObject()
        {
            int TEST_COUNT = 5;

            Dictionary <String, TeamLineup> teamLineups = LineupPersistence.loadDatabase();

            Assert.IsTrue(teamLineups.Count == 0);
            fillWithTestTeams(teamLineups, TEST_COUNT);
            LineupPersistence.saveDatabase(teamLineups);

            Dictionary <String, TeamLineup> lineup2 = LineupPersistence.loadDatabase();

            Assert.IsTrue(lineup2.Count() == TEST_COUNT);
            Assert.IsTrue(lineup2.ContainsKey(TEST_TEAM_NAME + "1"));
            TeamLineup lineup = teamLineups[TEST_TEAM_NAME + "1"];

            Assert.IsTrue(lineup.Lineups.Count == 2);

            Assert.AreEqual(18, lineup2[TEST_TEAM_NAME + "1"].playerByGRID.Count);
            Assert.AreEqual(18, lineup2[TEST_TEAM_NAME + "2"].playerByGRID.Count);
        }
 private void LineupUsageCalculator_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     syncUpTheData(engine.StoredLineups);
     LineupPersistence.saveDatabase(engine.StoredLineups);
 }
示例#5
0
 public void Cleanup()
 {
     LineupPersistence.clearDatabase();
 }
示例#6
0
 public void Initialize()
 {
     LineupPersistence.clearDatabase();
     RecordIndex.resetIndex(RecordIndex.INDEX.TestLineupDataId);
 }