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();
 }
 public AggregatedStatsOverlay(AggregatedStats stats, bool isSelf)
 {
     InitializeComponent();
     isOwnPlayer = isSelf;
     allStats = new AggregatedChampion();
     championStats = new List<AggregatedChampion>();
     ParseStats(stats);
     selectedStats = allStats;
     HideGrid.Visibility = 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. 4
0
 private void GotStats(AggregatedStats stats)
 {
     Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
     {
         SelectedAggregatedStats = stats;
     
         ViewAggregatedStatsButton.IsEnabled = false;
         List<AggregatedChampion> ChampionStats = new List<AggregatedChampion>();
         int i = 0;
         TopChampionsListView.Items.Clear();
         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)
             {
                 //Show the top 6 champions
                 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);
                 }
             }
         }
     }));
 }
        private void ParseStats(AggregatedStats stats)
        {
            foreach (var stat in stats.LifetimeStatistics)
            {
                var champion =
                    championStats.Find(x => Math.Abs(x.ChampionId - stat.ChampionId) < Math.Abs(x.ChampionId*.00001));
                if (champion == null)
                {
                    champion = new AggregatedChampion
                    {
                        ChampionId = stat.ChampionId
                    };
                    championStats.Add(champion);
                }

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

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

            //AllStats = ChampionStats;

            foreach (var championStat in championStats)
            {
                if (Math.Abs(championStat.ChampionId) < .00001)
                {
                    continue;
                }

                var item = new ListViewItem();
                var championImage = new ProfileChampionImage();
                var champ = champions.GetChampion((int) championStat.ChampionId);
                championImage.ChampImage.Source = champ.icon;
                championImage.ChampName.Content = champ.displayName;
                championImage.Width = 96;
                championImage.Height = 84;
                item.Tag = championStat;
                item.Content = championImage.Content;
                ChampionsListView.Items.Add(item);
            }
        }
Esempio n. 6
0
        private void GotStats(AggregatedStats stats)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                selectedAggregatedStats = stats;

                ViewAggregatedStatsButton.IsEnabled = false;
                TopChampionsListView.Items.Clear();
                var championStats = new List<AggregatedChampion>();
                var i = 0;
                if (selectedAggregatedStats.LifetimeStatistics == null)
                {
                    return;
                }

                if (!selectedAggregatedStats.LifetimeStatistics.Any())
                {
                    return;
                }

                foreach (var stat in selectedAggregatedStats.LifetimeStatistics)
                {
                    var champion = championStats.Find(x => Math.Abs(x.ChampionId - stat.ChampionId) < .00001);
                    if (champion == null)
                    {
                        champion = new AggregatedChampion
                        {
                            ChampionId = stat.ChampionId
                        };
                        championStats.Add(champion);
                    }

                    var type = typeof (AggregatedChampion);
                    var fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", string.Empty);
                    var f = type.GetField(fieldName);
                    if (f == null)
                        Client.Log(fieldName, "NewStatType");
                    else
                        f.SetValue(champion, stat.Value);
                }

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

                foreach (var info in championStats.TakeWhile(info => i++ <= 6))
                {
                    ViewAggregatedStatsButton.IsEnabled = true;
                    if (!(Math.Abs(info.ChampionId) > 0))
                    {
                        continue;
                    }

                    var champion = champions.GetChampion(Convert.ToInt32(info.ChampionId));
                    var player = new ChatPlayer
                    {
                        LevelLabel = {Visibility = Visibility.Hidden},
                        PlayerName = {Content = champion.displayName},
                        PlayerStatus = {Content = info.TotalSessionsPlayed + " games played"},
                        ProfileImage = {Source = champions.GetChampion(champion.id).icon},
                        Background = new SolidColorBrush(Color.FromArgb(102, 80, 80, 80)),
                        Width = 270
                    };

                    TopChampionsListView.Items.Add(player);
                }
            }));
        }