Beispiel #1
0
        private void StatsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (StatsComboBox.SelectedIndex != -1)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    StatsListView.Items.Clear();
                    PlayerStatSummary GameMode = Summaries[StatsComboBox.SelectedIndex];
                    foreach (SummaryAggStat stat in GameMode.AggregatedStats.Stats)
                    {
                        ProfilePage.KeyValueItem item = new ProfilePage.KeyValueItem
                        {
                            Key   = Client.TitleCaseString(stat.StatType.Replace('_', ' ')),
                            Value = stat.Value.ToString()
                        };
                        StatsListView.Items.Add(item);
                    }

                    //Resize columns
                    if (double.IsNaN(KeyHeader.Width))
                    {
                        KeyHeader.Width = KeyHeader.ActualWidth;
                    }
                    if (double.IsNaN(ValueHeader.Width))
                    {
                        ValueHeader.Width = ValueHeader.ActualWidth;
                    }
                    KeyHeader.Width   = double.NaN;
                    ValueHeader.Width = double.NaN;
                }));
            }
        }
        private void img_MouseMove(object sender, MouseEventArgs e)
        {
            Image item = (Image)sender;

            ProfilePage.KeyValueItem playerItem = (ProfilePage.KeyValueItem)item.Tag;
            if (PlayerItem == null)
            {
                PlayerItem = new LargeChatPlayer();
                Client.MainGrid.Children.Add(PlayerItem);

                items Item = items.GetItem(Convert.ToInt32(playerItem.Value));

                PlayerItem.PlayerName.Content = Item.name;

                PlayerItem.PlayerName.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                if (PlayerItem.PlayerName.DesiredSize.Width > 250) //Make title fit in item
                {
                    PlayerItem.Width = PlayerItem.PlayerName.DesiredSize.Width;
                }
                else
                {
                    PlayerItem.Width = 250;
                }

                PlayerItem.PlayerWins.Content        = Item.price + " gold (" + Item.sellprice + " sell)";
                PlayerItem.PlayerLeague.Content      = "Item ID " + Item.id;
                PlayerItem.LevelLabel.Content        = "";
                PlayerItem.UsingLegendary.Visibility = System.Windows.Visibility.Hidden;

                string ParsedDescription = Item.description;
                ParsedDescription            = ParsedDescription.Replace("<br>", Environment.NewLine);
                ParsedDescription            = Regex.Replace(ParsedDescription, "<.*?>", string.Empty);
                PlayerItem.PlayerStatus.Text = ParsedDescription;

                var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "item", Item.id + ".png"), UriKind.RelativeOrAbsolute);
                PlayerItem.ProfileImage.Source = new BitmapImage(uriSource);

                PlayerItem.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                PlayerItem.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
            }

            Point MouseLocation = e.GetPosition(Client.MainGrid);

            double YMargin = MouseLocation.Y;

            double XMargin = MouseLocation.X;

            if (XMargin + PlayerItem.Width + 10 > Client.MainGrid.ActualWidth)
            {
                XMargin = Client.MainGrid.ActualWidth - PlayerItem.Width - 10;
            }

            PlayerItem.Margin = new Thickness(XMargin + 5, YMargin + 5, 0, 0);
        }
Beispiel #3
0
        private void GamesListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (GamesListView.SelectedIndex != -1)
            {
                var stats = _gameStats[GamesListView.SelectedIndex];
                GameStatsListView.Items.Clear();
                PurpleListView.Items.Clear();
                BlueListView.Items.Clear();
                ItemsListView.Items.Clear();

                /*_matchLinkOnline = "http://matchhistory.na.leagueoflegends.com/en/#match-details/" +
                 *                Client.Region.InternalName + "/" + (int) Math.Round(stats.Game.GameId) + "/" +
                 *                stats.Game.UserId;*/

                //Add self to game players
                var img = new Image
                {
                    Width  = 58,
                    Height = 58,
                    Source = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)).icon
                };
                BlueListView.Items.Add(img);
                foreach (var info in stats.Game.FellowPlayers)
                {
                    img = new Image
                    {
                        Width  = 58,
                        Height = 58,
                        Source = champions.GetChampion((int)Math.Round(info.ChampionId)).icon
                    };
                    if (Math.Abs(info.TeamId - stats.Game.TeamId) < .00001)
                    {
                        BlueListView.Items.Add(img);
                    }
                    else
                    {
                        PurpleListView.Items.Add(img);
                    }

                    BlueListView.Visibility   = BlueListView.Items.Count > 0 ? Visibility.Visible : Visibility.Hidden;
                    PurpleListView.Visibility = PurpleListView.Items.Count > 0 ? Visibility.Visible : Visibility.Hidden;
                }

                var classType = typeof(MatchStats);

                foreach (var field in classType.GetFields(BindingFlags.Public | BindingFlags.Instance))
                {
                    if (field.GetValue(stats) is double)
                    {
                        if (Math.Abs((double)field.GetValue(stats)) < .00001)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        continue;
                    }

                    var 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);
                        if (!File.Exists(uriSource.AbsolutePath))
                        {
                            continue;
                        }

                        img = new Image
                        {
                            Width  = 58,
                            Height = 58,
                            Source = new BitmapImage(uriSource),
                            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;
        }
        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
                var 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;
                    }

                    var 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);
                        if (File.Exists(uriSource.AbsolutePath))
                        {
                            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;
        }
        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 = Path.Combine(Client.ExecutingDirectory, "Assets", "item", item.Value + ".png");
                        img = new Image();
                        img.Width = 58;
                        img.Height = 58;
                        img.Source = Client.GetImage(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;
        }
        private void StatsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (StatsComboBox.SelectedIndex != -1)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    StatsListView.Items.Clear();
                    PlayerStatSummary GameMode = Summaries[StatsComboBox.SelectedIndex];
                    foreach (SummaryAggStat stat in GameMode.AggregatedStats.Stats)
                    {
                        ProfilePage.KeyValueItem item = new ProfilePage.KeyValueItem
                        {
                            Key = Client.TitleCaseString(stat.StatType.Replace('_', ' ')),
                            Value = stat.Value.ToString()
                        };
                        StatsListView.Items.Add(item);
                    }

                    //Resize columns
                    if (double.IsNaN(KeyHeader.Width))
                    {
                        KeyHeader.Width = KeyHeader.ActualWidth;
                    }
                    if (double.IsNaN(ValueHeader.Width))
                    {
                        ValueHeader.Width = ValueHeader.ActualWidth;
                    }
                    KeyHeader.Width = double.NaN;
                    ValueHeader.Width = double.NaN;
                }));
            }
        }
        private void GamesListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (GamesListView.SelectedIndex != -1)
            {
                var stats = gameStats[GamesListView.SelectedIndex];
                GameStatsListView.Items.Clear();
                PurpleListView.Items.Clear();
                BlueListView.Items.Clear();
                ItemsListView.Items.Clear();
                /*_matchLinkOnline = "http://matchhistory.na.leagueoflegends.com/en/#match-details/" +
                                  Client.Region.InternalName + "/" + (int) Math.Round(stats.Game.GameId) + "/" +
                                  stats.Game.UserId;*/

                //Add self to game players
                var img = new Image
                {
                    Width = 58,
                    Height = 58,
                    Source = champions.GetChampion((int) Math.Round(stats.Game.ChampionId)).icon
                };
                BlueListView.Items.Add(img);
                foreach (var info in stats.Game.FellowPlayers)
                {
                    img = new Image
                    {
                        Width = 58,
                        Height = 58,
                        Source = champions.GetChampion((int) Math.Round(info.ChampionId)).icon
                    };
                    if (Math.Abs(info.TeamId - stats.Game.TeamId) < .00001)
                    {
                        BlueListView.Items.Add(img);
                    }
                    else
                    {
                        PurpleListView.Items.Add(img);
                    }

                    BlueListView.Visibility = BlueListView.Items.Count > 0 ? Visibility.Visible : Visibility.Hidden;
                    PurpleListView.Visibility = PurpleListView.Items.Count > 0 ? Visibility.Visible : Visibility.Hidden;
                }

                var classType = typeof (MatchStats);

                foreach (var field in classType.GetFields(BindingFlags.Public | BindingFlags.Instance))
                {
                    if (field.GetValue(stats) is double)
                    {
                        if (Math.Abs((double) field.GetValue(stats)) < .00001)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        continue;
                    }

                    var 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 System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "item", item.Value + ".png"),
                                UriKind.Absolute);
                        if (!File.Exists(UriSource.AbsolutePath))
                        {
                            continue;
                        }

                        img = new Image
                        {
                            Width = 58,
                            Height = 58,
                            Source = new BitmapImage(UriSource),
                            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;
        }