private void ChampPlayer_MouseLeave(object sender, MouseEventArgs e)
 {
     if (stats != null)
     {
         Client.MainGrid.Children.Remove(stats);
         stats = null;
     }
 }
        private void ChampPlayer_MouseLeave(object sender, MouseEventArgs e)
        {
            if (_stats == null)
            {
                return;
            }

            Client.MainGrid.Children.Remove(_stats);
            _stats = null;
        }
        private async void ChampPlayer_MouseOver(object sender, MouseEventArgs e)
        {
            if (Client.TrueCurrentPage.GetType() != typeof(ChampSelectPage) ||
                PlayerName.Content.ToString().StartsWith("Summoner "))
            {
                return;
            }

            try
            {
                if (_stats == null)
                {
                    _stats = new PlayerStatisticsChampSelect();
                    PublicSummoner summoner = await Client.PVPNet.GetSummonerByName(PlayerName.Content.ToString());

                    if (summoner == null || _stats == null || summoner.InternalName.Contains("bot"))
                    {
                        _stats = null;
                        return;
                    }
                    ChampionStatInfo[] topChampions =
                        await Client.PVPNet.RetrieveTopPlayedChampions(summoner.AcctId, "CLASSIC");

                    _stats.PlayerName.Content = summoner.Name;

                    if (topChampions.Length > 0)
                    {
                        _stats.MostPlayed.Source = champions.GetChampion((int)topChampions[0].ChampionId).icon;
                        _stats.Champion1.Content =
                            champions.GetChampion((int)topChampions[0].ChampionId).displayName + " - Games: " +
                            topChampions[0].TotalGamesPlayed;
                        double wins  = 0.0;
                        double total = 0.0;
                        foreach (AggregatedStat stat in topChampions[0].Stats)
                        {
                            switch (stat.StatType)
                            {
                            case "TOTAL_SESSIONS_WON":
                                wins = stat.Value;
                                break;

                            case "TOTAL_SESSIONS_PLAYED":
                                total = stat.Value;
                                break;
                            }
                        }

                        if ((Math.Abs(wins / total * 100.0) > 0) && Math.Abs(total) > 0)
                        {
                            _stats.Champ1ProgressBar.Value = wins / total * 100.0;
                        }
                        else
                        {
                            _stats.Champ1ProgressBar.Visibility = Visibility.Hidden;
                        }
                    }
                    else
                    {
                        _stats.Champ1ProgressBar.Visibility = Visibility.Hidden;
                        _stats.Champion1.Visibility         = Visibility.Hidden;
                    }

                    if (topChampions.Length > 1)
                    {
                        _stats.Champion2.Content =
                            champions.GetChampion((int)topChampions[1].ChampionId).displayName + " - Games: " +
                            topChampions[1].TotalGamesPlayed;
                        double wins  = 0.0;
                        double total = 0.0;
                        foreach (AggregatedStat stat in topChampions[1].Stats)
                        {
                            if (stat.StatType == "TOTAL_SESSIONS_WON")
                            {
                                wins = stat.Value;
                            }
                            else if (stat.StatType == "TOTAL_SESSIONS_PLAYED")
                            {
                                total = stat.Value;
                            }
                        }

                        if ((Math.Abs(wins / total * 100.0) > 0) && Math.Abs(total) > 0)
                        {
                            _stats.Champ2ProgressBar.Value = wins / total * 100.0;
                        }
                        else
                        {
                            _stats.Champ2ProgressBar.Visibility = Visibility.Hidden;
                        }
                    }
                    else
                    {
                        _stats.Champ2ProgressBar.Visibility = Visibility.Hidden;
                        _stats.Champion2.Visibility         = Visibility.Hidden;
                    }

                    if (topChampions.Length > 2)
                    {
                        _stats.Champion3.Content =
                            champions.GetChampion((int)topChampions[2].ChampionId).displayName + " - Games: " +
                            topChampions[2].TotalGamesPlayed;
                        double wins  = 0.0;
                        double total = 0.0;
                        foreach (AggregatedStat stat in topChampions[2].Stats)
                        {
                            if (stat.StatType == "TOTAL_SESSIONS_WON")
                            {
                                wins = stat.Value;
                            }
                            else if (stat.StatType == "TOTAL_SESSIONS_PLAYED")
                            {
                                total = stat.Value;
                            }
                        }

                        if ((Math.Abs(wins / total * 100.0) > 0) && Math.Abs(total) > 0)
                        {
                            _stats.Champ3ProgressBar.Value = wins / total * 100.0;
                        }
                        else
                        {
                            _stats.Champ3ProgressBar.Visibility = Visibility.Hidden;
                        }
                    }
                    else
                    {
                        _stats.Champ3ProgressBar.Visibility = Visibility.Hidden;
                        _stats.Champion3.Visibility         = Visibility.Hidden;
                    }
                    Client.MainGrid.Children.Add(_stats);
                }
                Point  mouseLocation = e.GetPosition(Client.MainGrid);
                double yMargin       = mouseLocation.Y - 25;
                if (Mouse.GetPosition(Client.MainGrid).X < 200)
                {
                    _stats.HorizontalAlignment = HorizontalAlignment.Left;
                    _stats.VerticalAlignment   = VerticalAlignment.Top;
                    _stats.Margin = new Thickness(142, yMargin, 0, 0);
                }
                else
                {
                    _stats.HorizontalAlignment = HorizontalAlignment.Right;
                    _stats.VerticalAlignment   = VerticalAlignment.Top;
                    _stats.Margin = new Thickness(0, yMargin, 155, 0);
                }
            }
            catch (Exception)
            {
            }
        }
        private async void ChampPlayer_MouseOver(object sender, MouseEventArgs e)
        {
            if (Client.TrueCurrentPage.GetType() == typeof(ChampSelectPage) && !PlayerName.Content.ToString().StartsWith("Summoner ")) //Need to check if on your team incase you have a teammate such as Summoner I am a summoner... etc
            {
                try
                {
                    if (stats == null)
                    {
                        PublicSummoner summoner = await Client.PVPNet.GetSummonerByName(PlayerName.Content.ToString());

                        if (summoner == null)
                        {
                            return;
                        }
                        ChampionStatInfo[] TopChampions = await Client.PVPNet.RetrieveTopPlayedChampions(summoner.AcctId, "CLASSIC");

                        stats = new PlayerStatisticsChampSelect();
                        stats.PlayerName.Content = summoner.Name;

                        if (TopChampions[1] != null)
                        {
                            stats.MostPlayed.Source = champions.GetChampion((int)TopChampions[1].ChampionId).icon;
                            stats.Champion1.Content = champions.GetChampion((int)TopChampions[1].ChampionId).displayName + " - Games: " + TopChampions[1].TotalGamesPlayed;
                            double wins  = 0.0;
                            double total = 0.0;
                            foreach (var stat in TopChampions[1].Stats)
                            {
                                if (stat.StatType == "TOTAL_SESSIONS_WON")
                                {
                                    wins = stat.Value;
                                }
                                else if (stat.StatType == "TOTAL_SESSIONS_PLAYED")
                                {
                                    total = stat.Value;
                                }
                            }

                            if ((wins / total * 100.0 != 0) && total != 0.0)
                            {
                                stats.Champ1ProgressBar.Value = wins / total * 100.0;
                            }
                            else
                            {
                                stats.Champ1ProgressBar.Visibility = Visibility.Hidden;
                            }
                        }
                        if (TopChampions[2] != null)
                        {
                            stats.Champion2.Content = champions.GetChampion((int)TopChampions[2].ChampionId).displayName + " - Games: " + TopChampions[2].TotalGamesPlayed;
                            double wins  = 0.0;
                            double total = 0.0;
                            foreach (var stat in TopChampions[2].Stats)
                            {
                                if (stat.StatType == "TOTAL_SESSIONS_WON")
                                {
                                    wins = stat.Value;
                                }
                                else if (stat.StatType == "TOTAL_SESSIONS_PLAYED")
                                {
                                    total = stat.Value;
                                }
                            }

                            if ((wins / total * 100.0 != 0) && total != 0.0)
                            {
                                stats.Champ2ProgressBar.Value = wins / total * 100.0;
                            }
                            else
                            {
                                stats.Champ2ProgressBar.Visibility = Visibility.Hidden;
                            }
                        }
                        if (TopChampions[3] != null)
                        {
                            stats.Champion3.Content = champions.GetChampion((int)TopChampions[3].ChampionId).displayName + " - Games: " + TopChampions[3].TotalGamesPlayed;
                            double wins  = 0.0;
                            double total = 0.0;
                            foreach (var stat in TopChampions[3].Stats)
                            {
                                if (stat.StatType == "TOTAL_SESSIONS_WON")
                                {
                                    wins = stat.Value;
                                }
                                else if (stat.StatType == "TOTAL_SESSIONS_PLAYED")
                                {
                                    total = stat.Value;
                                }
                            }

                            if ((wins / total * 100.0 != 0) && total != 0.0)
                            {
                                stats.Champ3ProgressBar.Value = wins / total * 100.0;
                            }
                            else
                            {
                                stats.Champ3ProgressBar.Visibility = Visibility.Hidden;
                            }
                        }
                        Client.MainGrid.Children.Add(stats);
                    }
                    Point  MouseLocation = e.GetPosition(Client.MainGrid);
                    double YMargin       = MouseLocation.Y - 25;
                    if (Mouse.GetPosition(Client.MainGrid).X < 200)
                    {
                        stats.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                        stats.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                        stats.Margin = new Thickness(142, YMargin, 0, 0);
                    }
                    else
                    {
                        stats.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                        stats.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                        stats.Margin = new Thickness(0, YMargin, 155, 0);
                    }
                }
                catch { }
            }
        }
Example #5
0
        private async void ChampPlayer_MouseOver(object sender, MouseEventArgs e)
        {
            if (!KnownPar)
            {
                return;
            }


            if (_stats == null)
            {
                _stats = new PlayerStatisticsChampSelect();
                var summoner = await Client.PVPNet.GetSummonerByName(_sumName);

                if (summoner.SummonerLevel < 30)
                {
                    _stats.Rank.Content = "Level " + summoner.SummonerLevel;
                }
                else
                {
                    SummonerLeaguesDTO playerLeagues = await Client.PVPNet.GetAllLeaguesForPlayer(summoner.SummonerId);

                    _stats.Rank.Content = playerLeagues.SummonerLeagues;

                    foreach (LeagueListDTO x in playerLeagues.SummonerLeagues.Where(x => x.Queue == "RANKED_SOLO_5x5"))
                    {
                        _stats.Rank.Content = x.Tier + " " + x.RequestorsRank;
                    }

                    if (String.IsNullOrEmpty(_stats.Rank.Content.ToString()))
                    {
                        _stats.Rank.Content = "Unranked";
                    }
                }
                if (summoner == null || _stats == null || summoner.InternalName.Contains("bot"))
                {
                    _stats = null;
                    return;
                }
                var topChampions = await Client.PVPNet.RetrieveTopPlayedChampions(summoner.AcctId, "CLASSIC");

                foreach (var x in topChampions)
                {
                    Debugger.Log(0, "CHAMPS", x.ChampionId + Environment.NewLine);
                }
                //_stats.PlayerName.Content = PlayerName.Content;
                GetKDA kda;
                if (topChampions.Length > 0 && KnownPar)
                {
                    if (topChampions[0].ChampionId != 0)
                    {
                        _stats.MostPlayed.Source = champions.GetChampion((int)topChampions[0].ChampionId).icon;
                        _stats.Champion1.Content = champions.GetChampion((int)topChampions[0].ChampionId).displayName +
                                                   " - Games: " + topChampions[0].TotalGamesPlayed;
                        var wins  = 0.0;
                        var total = 0.0;
                        kda = new GetKDA((int)summoner.AcctId, (int)topChampions[0].ChampionId);
                        kda.stats.ChampID = (int)topChampions[0].ChampionId;

                        string[] xz = await kda.stats.Load((int)summoner.AcctId);

                        _stats.MPChamp.Content = xz[0];
                        foreach (var stat in topChampions[0].Stats)
                        {
                            switch (stat.StatType)
                            {
                            case "TOTAL_SESSIONS_WON":
                                wins = stat.Value;
                                break;

                            case "TOTAL_SESSIONS_PLAYED":
                                total = stat.Value;
                                break;
                            }
                        }

                        if ((Math.Abs(wins / total * 100.0) > 0) && Math.Abs(total) > 0)
                        {
                            _stats.Champ1ProgressBar.Value = wins / total * 100.0;
                        }
                    }
                    else if (topChampions[1].ChampionId != 0 && topChampions.Length > 1)
                    {
                        if (topChampions[1].ChampionId != 0)
                        {
                            try
                            {
                                _stats.MostPlayed.Source = champions.GetChampion((int)topChampions[1].ChampionId).icon;
                                _stats.Champion1.Content = champions.GetChampion((int)topChampions[1].ChampionId).displayName +
                                                           " - Games: " + topChampions[1].TotalGamesPlayed;
                                var wins  = 0.0;
                                var total = 0.0;
                                kda = new GetKDA((int)summoner.AcctId, (int)topChampions[1].ChampionId);
                                kda.stats.ChampID = (int)topChampions[1].ChampionId;
                                string[] x = await kda.stats.Load((int)summoner.AcctId);

                                _stats.MPChamp.Content = x[0];
                                foreach (var stat in topChampions[1].Stats)
                                {
                                    switch (stat.StatType)
                                    {
                                    case "TOTAL_SESSIONS_WON":
                                        wins = stat.Value;
                                        break;

                                    case "TOTAL_SESSIONS_PLAYED":
                                        total = stat.Value;
                                        break;
                                    }
                                }

                                if ((Math.Abs(wins / total * 100.0) > 0) && Math.Abs(total) > 0)
                                {
                                    _stats.Champ1ProgressBar.Value = wins / total * 100.0;
                                }
                                else
                                {
                                    _stats.Champ1ProgressBar.Visibility = Visibility.Hidden;
                                }
                            }
                            catch { }
                        }
                    }
                    else
                    {
                        _stats.Champ1ProgressBar.Visibility = Visibility.Hidden;
                        _stats.Champion1.Visibility         = Visibility.Hidden;
                    }

                    kda = new GetKDA((int)summoner.AcctId, 103);
                    kda.stats.ChampID = 103;
                    string[] xm = await kda.stats.Load((int)summoner.AcctId);

                    try
                    {
                        _stats.Overall.Content         = xm[1];
                        _stats.Champ3ProgressBar.Value = kda.stats.WinLossRatio;
                    }
                    catch { }

                    //
                    if (_champID != 0)
                    {
                        kda = new GetKDA((int)summoner.AcctId, _champID);
                        kda.stats.ChampID = _champID;
                        string[] xmt = await kda.stats.Load((int)summoner.AcctId);

                        if (!String.IsNullOrEmpty(xmt[0]))
                        {
                            try
                            {
                                _stats.Champ2ProgressBar.Value = kda.stats.WinLossChampRatio;
                                _stats.CurrentChamp.Content    = xmt[0];
                            }
                            catch
                            {
                                try
                                {
                                    _stats.Champ2ProgressBar.Visibility = Visibility.Hidden;
                                    _stats.CurrentChamp.Content         = "NO GAMES!";
                                }
                                catch { }
                            }
                        }
                        else
                        {
                            try
                            {
                                _stats.Champ2ProgressBar.Value = 0;
                                _stats.CurrentChamp.Content    = "NO GAMES!";
                            }
                            catch { }
                        }
                    }


                    Client.MainGrid.Children.Add(_stats);
                }
                try
                {
                    var mouseLocation = e.GetPosition(Client.MainGrid);
                    var yMargin       = mouseLocation.Y - 25;
                    if (Mouse.GetPosition(Client.MainGrid).X < 200)
                    {
                        _stats.HorizontalAlignment = HorizontalAlignment.Left;
                        _stats.VerticalAlignment   = VerticalAlignment.Top;
                        _stats.Margin = new Thickness(142, yMargin, 0, 0);
                    }
                    else
                    {
                        _stats.HorizontalAlignment = HorizontalAlignment.Right;
                        _stats.VerticalAlignment   = VerticalAlignment.Top;
                        _stats.Margin = new Thickness(0, yMargin, 155, 0);
                    }
                }
                catch { }
            }
        }