コード例 #1
0
        private void tileRefresh_Click(object sender, EventArgs e)
        {
            tileRefresh.Enabled = false;
            //Get Match History
            List <GameData> gameDataList = new List <GameData>();
            int             matchIndex   = 0;

            //TODO: Not hit the endpoint so hard and spawn it in a new Thread or background worker
            while (true)
            {
                bool         breakout     = false;
                ACSMatchList MatchHistory = _leagueClient.GetMatchHistory(matchIndex * 20, (matchIndex + 1) * 20);
                foreach (GameData gameData in MatchHistory.games.games)
                {
                    if ((DateTime.Now - FromUnixTime(Convert.ToInt64(gameData.gameCreation))).Days > 30)
                    {
                        breakout = true;
                        break;
                    }

                    gameDataList.Add(gameData);
                }

                if (breakout)
                {
                    break;
                }

                matchIndex++;
            }
            //Clear the Current Panel
            panelMatchHistory.Controls.Clear();

            //Generate The UI
            //MatchHistory List is in reverse, oldest to newest
            //So Panel is set to show in reverse
            foreach (GameData gameData in gameDataList.OrderBy(g => g.gameCreation))
            {
                Application.DoEvents();
                MatchInfo matchInfoControl = new MatchInfo(_leagueClient, gameData.participants[0].championId, gameData.participants[0].spell1Id, gameData.participants[0].spell2Id,
                                                           gameData.participants[0].stats.item0, gameData.participants[0].stats.item1, gameData.participants[0].stats.item2, gameData.participants[0].stats.item3, gameData.participants[0].stats.item4, gameData.participants[0].stats.item5, gameData.participants[0].stats.item6,
                                                           gameData.participants[0].stats.kills, gameData.participants[0].stats.deaths, gameData.participants[0].stats.assists, _leagueClient.GetShareableMatchHistoryURL(gameData.gameId), gameData.gameId, GetDownloadUrl, FromUnixTime(Convert.ToInt64(gameData.gameCreation)), gameData.gameDuration);

                //Add it to the panel
                panelMatchHistory.Controls.Add(matchInfoControl);
            }

            tileRefresh.Enabled = true;
        }