void FileLoad() { ReadWriteMainFile.Input(Properties.Settings.Default.FileMain, players, history, weights); SCBfixedmatchplayers.SortBy = (obj, str) => Search.RelevanceToSearch(obj as Player, str); RefreshPageMatchesPlayers(); RefreshFullListOfPlayers(); RefreshHistoryList(); BindWeights(); if (players.Count == 0) { BTNmainPlayers.PerformClick(); } else { BTNplayers.PerformClick(); } }
bool GetParameters(out DayGeneratorParameters parameters, bool validate, bool fromScratch) { parameters = null; GetNumPlayers(out HashSet <Player> playersFree, out Counter <MatchSize> numMatchSizes); if (validate) { // Make sure all the players are correct if (playersSelectedForDay.Count == 0) { BTNplayers.PerformClick(); MessageBox.Show("Please select players", "Not enough players"); return(false); } if (Tools.SumOfPlayersInMatchSizes(numMatchSizes) != playersFree.Count) { BTNconfirmbeforecreating.PerformClick(); MessageBox.Show("Please make sure that the number of matches is correct for the number of players", "Wrong number of players"); return(false); } for (int matchIndex = 0; matchIndex < fixedMatchesDay?.matches.Count; matchIndex++) { Match match = fixedMatchesDay.matches[matchIndex]; foreach (Team team in match.teams) { bool errorFound = false; int size = 0; foreach (Player player in team.players) { if (player != null) { size++; } } for (int position = 0; position < Team.MaxSize; position++) { if (Match.PositionShouldBeFilled((Position)position, size) != (team.players[position] != null)) { errorFound = true; } } if (errorFound) { BTNfixedMatches.PerformClick(); MessageBox.Show($"Please make sure that all the positions in the fixed matches have been filled"); return(false); } } } // Adjust anything that needs to be fixed for (int matchIndex = 0; matchIndex < fixedMatchesDay?.matches.Count; matchIndex++) { Match match = fixedMatchesDay.matches[matchIndex]; foreach (Team team in match.teams) { int size = 0; foreach (Player player in team.players) { if (player != null) { size++; } } team.size = size; } } } parameters = new DayGeneratorParameters { players = new List <Player>(playersFree), history = history, weights = weights, numMatchSizes = numMatchSizes, existingDay = fromScratch ? null : generatedDay, }; return(true); }