コード例 #1
0
ファイル: Form1.cs プロジェクト: Shuan97/RiotGames_LoLStats
 private void Timer1_Tick(object sender, EventArgs e)
 {
     if (isHide)
     {
         Panel.Location = new Point(Panel.Location.X - 5, Panel.Location.Y);
         if (Panel.Location.X <= 500)
         {
             PanelButton.Text = ">";
             PanelTimer.Stop();
             isHide = false;
             this.Refresh();
         }
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Shuan97/RiotGames_LoLStats
        public async void SearchButton_Click(object sender, EventArgs e)
        {
            nickname = SearchText.Text;

            Task <Summoner> taskGetSummoner = new Task <Summoner>(() => WebServiceHandler.GetSummoner(StringNameToURLCode()));

            taskGetSummoner.Start();
            ResultLabel.Text = "Oczekiwanie...";
            Summoner summoner = await taskGetSummoner;

            if (summoner == null)
            {
                ResultLabel.Text = "Nie znaleziono przywoływacza";
                return;
            }
            ResultLabel.Text = nickname;
            LevelLabel.Text  = "Poziom: " + summoner.SummonerLevel;

            Task <Tuple <LeagueTT, LeagueFlex, LeagueSolo> > taskGetLeague = new Task <Tuple <LeagueTT, LeagueFlex, LeagueSolo> >(() => WebServiceHandler.GetLeague(summoner.Id));

            taskGetLeague.Start();

            Tuple <LeagueTT, LeagueFlex, LeagueSolo> tuple = await taskGetLeague;
            string iconId = summoner.ProfileIconId;
            Image  image  = DownloadImageFromUrl("http://ddragon.leagueoflegends.com/cdn/8.24.1/img/profileicon/" + iconId + ".png");

            IconBox.Image = image;
            try
            {
                TTImage.Image = SetImage(tuple.Item1.Tier);
                TTLabel.Text  = tuple.Item1.Tier + " " + tuple.Item1.Rank;
            }
            catch (Exception)
            {
                TTImage.Image = SetImage("unranked");
                TTLabel.Text  = "UNRANKED";
            }
            try
            {
                FlexImage.Image = SetImage(tuple.Item2.Tier);
                FlexLabel.Text  = tuple.Item2.Tier + " " + tuple.Item2.Rank;
            }
            catch (Exception)
            {
                FlexImage.Image = SetImage("unranked");
                FlexLabel.Text  = "UNRANKED";
            }
            try
            {
                SoloImage.Image = SetImage(tuple.Item3.Tier);
                SoloLabel.Text  = tuple.Item3.Tier + " " + tuple.Item3.Rank;
            }
            catch (Exception)
            {
                SoloImage.Image = SetImage("unranked");
                SoloLabel.Text  = "UNRANKED";
            }

            Task <List <GameIds> > taskGetList = new Task <List <GameIds> >(() => WebServiceHandler.GetMatchesId(summoner.AccountId.ToString()));

            taskGetList.Start();

            List <GameIds> list = await taskGetList;

            for (int i = 0; i < 20; i++)
            {
                Task <Match> taskGetMatch = new Task <Match>(() => WebServiceHandler.GetMatch(list[i].GameId));
                taskGetMatch.Start();

                Match match = await taskGetMatch;
                for (int j = 0; j < 10; j++)
                {
                    if (summoner.AccountId == match.participantIdentities[j].player.accountId)
                    {
                        string score = match.participants[j].stats.kills.ToString() + " / " + match.participants[j].stats.deaths.ToString() + " / "
                                       + match.participants[j].stats.assists.ToString();

                        content[i].SetPanel(match.participants[j].stats.item0, match.participants[j].stats.item1, match.participants[j].stats.item2,
                                            match.participants[j].stats.item3, match.participants[j].stats.item4, match.participants[j].stats.item5,
                                            match.participants[j].championId, GetResult(summoner, match, i), score);
                    }
                }
            }
            PanelTimer.Start();
        }