public void newScores() { _turnScores.Clear(); foreach (Player player in this.endTurn.HumanPlayers) { dynamic dynamicScore = new System.Dynamic.ExpandoObject(); dynamicScore.position = 0; dynamicScore.name = player.Username; dynamicScore.score = player.score.scoreTurn; _turnScores.Add(dynamicScore); } _turnScores = new BindableCollection <dynamic>(_turnScores.OrderByDescending(i => i.score)); int rank = 1; foreach (dynamic score in _turnScores) { score.position = rank + "."; score.score = ": +" + score.score + " points"; rank++; } // _turnScores = new BindableCollection<dynamic>(_turnScores.OrderBy(i => i.position)); turnScores.Refresh(); NotifyOfPropertyChange(() => turnScores); }
public static void SortDescending <TSource, TKey>(this BindableCollection <TSource> source, Func <TSource, TKey> keySelector) { List <TSource> sorted = source.OrderByDescending(keySelector).ToList(); source.Clear(); foreach (var item in sorted) { source.Add(item); } }
public void Handle(endMatchEvent message) { _matchScores.Clear(); foreach (Player player in message.players) { dynamic dynamicScore = new System.Dynamic.ExpandoObject(); dynamicScore.position = 0; dynamicScore.name = player.Username; dynamicScore.score = player.score.scoreTotal; _matchScores.Add(dynamicScore); } _matchScores = new BindableCollection <dynamic>(_matchScores.OrderByDescending(i => i.score)); if (this._userData.matchMode == Models.MatchMode.sprintSolo || this._userData.matchMode == Models.MatchMode.sprintCoop) { foreach (dynamic score in _matchScores) { score.position = ""; score.score = ": " + score.score + " points"; } } else { int rank = 1; foreach (dynamic score in _matchScores) { score.position = rank + "."; score.score = ": " + score.score + " points"; rank++; } } // _matchScores = new BindableCollection<dynamic>(_matchScores.OrderBy(i => i.position)); endTurn.players = new BindableCollection <Player>(); NotifyOfPropertyChange(() => joueurs); _winnerMessage = "The winner is " + _matchScores[0].name; if (this._userData.matchMode == Models.MatchMode.sprintSolo || this._userData.matchMode == Models.MatchMode.sprintCoop) { _winnerMessage = ""; } NotifyOfPropertyChange(() => winnerMessage); matchScores.Refresh(); NotifyOfPropertyChange(() => matchScores); this._timer.Stop(); }
//this returns seasons populated down to the category level. public async Task <BindableCollection <Season> > GetSortedSeasons() { TeamResponse response = await ServiceAccessor.GetTeams(); if (response.status == SERVICE_RESPONSE.SUCCESS) { BindableCollection <Team> teams = response.teams; BindableCollection <Season> seasons = new BindableCollection <Season>(); foreach (Team team in teams) { BindableCollection <Season> teamSeason = await GetPopulatedSeasons(team); if (teamSeason != null) { seasons.AddRange(teamSeason); } } return(new BindableCollection <Season>(seasons.OrderByDescending(s => s.year))); } return(null); }
//this returns seasons populated down to the category level. public async Task<BindableCollection<Season>> GetSortedSeasons() { TeamResponse response = await ServiceAccessor.GetTeams(); if (response.status == SERVICE_RESPONSE.SUCCESS) { BindableCollection<Team> teams = response.teams; BindableCollection<Season> seasons = new BindableCollection<Season>(); foreach (Team team in teams) { BindableCollection<Season> teamSeason = await GetPopulatedSeasons(team); if (teamSeason != null) { seasons.AddRange(teamSeason); } } return new BindableCollection<Season>(seasons.OrderByDescending(s => s.year)); } return null; }