public void importChallonge(String apiKey, String subDomain, String specifiedTournamentName, List<Person> playerList) { if (subDomain != null && subDomain.Length > 0) portal = new ChallongePortal(apiKey, subDomain); else portal = new ChallongePortal(apiKey); //Fetch all tournaments for the user account or subdomain tournaments = portal.GetTournaments().ToList(); //If a specific tournament name is provided, look it up individually. if (!string.IsNullOrWhiteSpace(specifiedTournamentName)) { specifiedTournament = portal.ShowTournament(specifiedTournamentName); //Only add it to the list if it's not there from the user account/subdomain. if (!tournaments.Contains(specifiedTournament)) { tournaments.Insert(0, specifiedTournament); } } //Fetch name of first tournament in list or leave blank if no tournaments tournamentName = tournaments.Select(t => t.Name).FirstOrDefault(); //Load current players in leaderboard foreach (Person p in playerList) { currentPlayers.Add(p); playerNames.Add(p.Name); } playerNames.Sort(); //Set event selector eventSelector.DataSource = tournaments; eventSelector.DisplayMember = "Name"; }
public ObservableTournament(Tournament tournament, TournamentContext context) { source = tournament; OwningContext = context; }
public void Update(Tournament newData, IEnumerable<Participant> playerList, IEnumerable<Match> matchList) { var oldData = source; source = newData; //Raise notify event for any property that has changed value foreach (var property in tournamentProperties) { if (!object.Equals(property.GetValue(oldData, null), property.GetValue(newData, null))) this.Raise(property.Name, PropertyChanged); } if (oldData.ProgressMeter != newData.ProgressMeter) { Stations.Instance.ProgressChange(newData.ProgressMeter); } if (oldData.CompletedAt != newData.CompletedAt) { Stations.Instance.CompletionChange(newData.CompletedAt != null, TopFourParticipants()); } //Check if there are any new participants, or if participants have been removed. Also check if match count has changed. var participantIntersect = Participants.Select(kvp => kvp.Key).Intersect(playerList.Select(p => p.Id)); var participantsChanged = Participants.Select(kvp => kvp.Key).Union(playerList.Select(p => p.Id)).Except(participantIntersect).Any(); var matchCountChanged = Matches.Count != matchList.Count(); //If true, re-initialize, else update if (participantsChanged || matchCountChanged) { Initialize(playerList, matchList); } else { //Update all participants foreach (var participant in playerList) Participants[participant.Id].Update(participant); //Update all matches foreach (var match in matchList) Matches[match.Id].Update(match); } }
// Rebuild the list of players in the event whenever the event selector is used. private void eventSelector_SelectedIndexChanged(object sender, EventArgs e) { //Get combo box from sender var cbox = (ComboBox)sender; //Fetch selected tourney curTourney = (Tournament)cbox.SelectedItem; updatePlayerList(); }