public AggregatedStatsOverlay(AggregatedStats stats, Boolean IsSelf)
 {
     InitializeComponent();
     IsOwnPlayer = IsSelf;
     AllStats = new AggregatedChampion();
     ChampionStats = new List<AggregatedChampion>();
     ParseStats(stats);
     SelectedStats = AllStats;
     HideGrid.Visibility = System.Windows.Visibility.Visible;
     DisplayStats();
 }
        private void ParseStats(AggregatedStats stats)
        {
            foreach (AggregatedStat stat in stats.LifetimeStatistics)
            {
                AggregatedChampion Champion = null;
                Champion = ChampionStats.Find(x => x.ChampionId == stat.ChampionId);
                if (Champion == null)
                {
                    Champion = new AggregatedChampion();
                    Champion.ChampionId = stat.ChampionId;
                    ChampionStats.Add(Champion);
                }

                var type = typeof(AggregatedChampion);
                string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", "");
                var f = type.GetField(fieldName);
                f.SetValue(Champion, stat.Value);
            }

            ChampionStats.Sort((x, y) => y.TotalSessionsPlayed.CompareTo(x.TotalSessionsPlayed));

            //AllStats = ChampionStats[0];

            foreach (AggregatedChampion ChampionStat in ChampionStats)
            {
                if (ChampionStat.ChampionId != 0)
                {
                    ProfileChampionImage championImage = new ProfileChampionImage();
                    champions champion = champions.GetChampion((int)ChampionStat.ChampionId);
                    championImage.DataContext = champion;

                    championImage.Width = 96;
                    championImage.Height = 84;
                    championImage.Tag = ChampionStat;
                    ChampionsListView.Items.Add(championImage);
                }
            }
        }
Esempio n. 3
0
 public AggregatedStats GetAggregatedStats(double summonerId, string gameMode, string season)
 {
     int Id = Invoke("playerStatsService", "getAggregatedStats", new object[] { summonerId, gameMode, season });
     while (!results.ContainsKey(Id))
         System.Threading.Thread.Sleep(10);
     TypedObject messageBody = results[Id].GetTO("data").GetTO("body");
     AggregatedStats result = new AggregatedStats(messageBody);
     results.Remove(Id);
     return result;
 }
Esempio n. 4
0
 /// 21.)
 public void GetAggregatedStats(double summonerId, string gameMode, string season,
     AggregatedStats.Callback callback)
 {
     AggregatedStats cb = new AggregatedStats(callback);
     InvokeWithCallback("playerStatsService", "getAggregatedStats", new object[] { summonerId, gameMode, season },
         cb);
 }
Esempio n. 5
0
        private void GotStats(AggregatedStats stats)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                SelectedAggregatedStats = stats;

                ViewAggregatedStatsButton.IsEnabled = false;
                TopChampionsListView.Items.Clear();
                List<AggregatedChampion> ChampionStats = new List<AggregatedChampion>();
                int i = 0;

                if (SelectedAggregatedStats.LifetimeStatistics.Count() > 0)
                {
                    foreach (AggregatedStat stat in SelectedAggregatedStats.LifetimeStatistics)
                    {
                        AggregatedChampion Champion = null;
                        Champion = ChampionStats.Find(x => x.ChampionId == stat.ChampionId);
                        if (Champion == null)
                        {
                            Champion = new AggregatedChampion();
                            Champion.ChampionId = stat.ChampionId;
                            ChampionStats.Add(Champion);
                        }

                        var type = typeof(AggregatedChampion);
                        string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", "");
                        var f = type.GetField(fieldName);
                        f.SetValue(Champion, stat.Value);
                    }

                    ChampionStats.Sort((x, y) => y.TotalSessionsPlayed.CompareTo(x.TotalSessionsPlayed));

                    foreach (AggregatedChampion info in ChampionStats)
                    {
                        if (i++ > 6)
                            break;
                        ViewAggregatedStatsButton.IsEnabled = true;
                        if (info.ChampionId != 0.0)
                        {
                            ChatPlayer player = new ChatPlayer();
                            champions Champion = champions.GetChampion(Convert.ToInt32(info.ChampionId));
                            player.LevelLabel.Visibility = System.Windows.Visibility.Hidden;
                            player.PlayerName.Content = Champion.displayName;
                            player.PlayerStatus.Content = info.TotalSessionsPlayed + " games played";
                            player.ProfileImage.Source = champions.GetChampion(Champion.id).icon;
                            TopChampionsListView.Items.Add(player);
                        }
                    }
                }
            }));
        }
 public async Task<AggregatedStats> GetAggregatedStats(Double summonerId, String gameMode, String season)
 {
     int Id = Invoke("playerStatsService", "getAggregatedStats", new object[] { summonerId, gameMode, season });
     while (!results.ContainsKey(Id))
         await Task.Delay(10);
     TypedObject messageBody = results[Id].GetTO("data").GetTO("body");
     AggregatedStats result = new AggregatedStats(messageBody);
     results.Remove(Id);
     return result;
 }