public void GotRecentGames(RecentGames result) { GameStats.Clear(); result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); foreach (PlayerGameStats Game in result.GameStatistics) { Game.GameType = Client.TitleCaseString(Game.GameType.Replace("_GAME", "").Replace("MATCHED", "NORMAL")); MatchStats Match = new MatchStats(); foreach (RawStat Stat in Game.Statistics) { var type = typeof(MatchStats); string fieldName = Client.TitleCaseString(Stat.StatType.Replace('_', ' ')).Replace(" ", ""); var f = type.GetField(fieldName); f.SetValue(Match, Stat.Value); } Match.Game = Game; GameStats.Add(Match); } Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { GamesListView.Items.Clear(); BlueListView.Items.Clear(); ItemsListView.Items.Clear(); PurpleListView.Items.Clear(); GameStatsListView.Items.Clear(); foreach (MatchStats stats in GameStats) { RecentGameOverview item = new RecentGameOverview(); champions GameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); item.ChampionImage.Source = GameChamp.icon; item.ChampionNameLabel.Content = GameChamp.displayName; item.ScoreLabel.Content = string.Format("{0}/{1}/{2} ({3})", stats.ChampionsKilled, stats.NumDeaths, stats.Assists, stats.Game.GameType); item.CreepScoreLabel.Content = stats.MinionsKilled + " minions"; item.DateLabel.Content = stats.Game.CreateDate; item.IPEarnedLabel.Content = "+" + stats.Game.IpEarned + " IP"; item.PingLabel.Content = stats.Game.UserServerPing + "ms"; BrushConverter bc = new BrushConverter(); Brush brush = (Brush)bc.ConvertFrom("#FF609E74"); if (stats.Lose == 1) { brush = (Brush)bc.ConvertFrom("#FF9E6060"); } else if (stats.Game.IpEarned == 0) { brush = (Brush)bc.ConvertFrom("#FFE27100"); } item.GridView.Background = brush; item.GridView.Width = 250; GamesListView.Items.Add(item); } if (GamesListView.Items.Count > 0) { GamesListView.SelectedIndex = 0; } })); }
private void GamesListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (GamesListView.SelectedIndex != -1) { MatchStats stats = GameStats[GamesListView.SelectedIndex]; GameStatsListView.Items.Clear(); PurpleListView.Items.Clear(); BlueListView.Items.Clear(); ItemsListView.Items.Clear(); //Add self to game players Image img = new Image(); img.Width = 58; img.Height = 58; img.Source = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)).icon; BlueListView.Items.Add(img); foreach (FellowPlayerInfo info in stats.Game.FellowPlayers) { img = new Image(); img.Width = 58; img.Height = 58; img.Source = champions.GetChampion((int)Math.Round(info.ChampionId)).icon; if (info.TeamId == stats.Game.TeamId) { BlueListView.Items.Add(img); } else { PurpleListView.Items.Add(img); } } Type classType = typeof(MatchStats); foreach (FieldInfo field in classType.GetFields(BindingFlags.Public | BindingFlags.Instance)) { if (field.GetValue(stats) is double) { if ((double)field.GetValue(stats) == 0) { continue; } } else { continue; } ProfilePage.KeyValueItem item = new ProfilePage.KeyValueItem { Key = Client.TitleCaseString(string.Concat(field.Name.Select(fe => Char.IsUpper(fe) ? " " + fe : fe.ToString())).TrimStart(' ')), Value = field.GetValue(stats) }; if (((string)item.Key).StartsWith("Item")) { var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "item", item.Value + ".png"), UriKind.Absolute); img = new Image(); img.Width = 58; img.Height = 58; img.Source = new BitmapImage(uriSource); img.Tag = item; img.MouseMove += img_MouseMove; img.MouseLeave += img_MouseLeave; ItemsListView.Items.Add(img); } else { GameStatsListView.Items.Add(item); } } } if (double.IsNaN(GameKeyHeader.Width)) { GameKeyHeader.Width = GameKeyHeader.ActualWidth; } if (double.IsNaN(GameValueHeader.Width)) { GameValueHeader.Width = GameValueHeader.ActualWidth; } GameKeyHeader.Width = double.NaN; GameValueHeader.Width = double.NaN; }