예제 #1
0
        async void LoadInfo()
        {
            try
            {
                ReportProgress(20, "Идет загрузка информации о игроке...");
                Program.MyPlayerProfile = await player.GetPlayerInfoAsync(ClashRoyaleClanMonitorWF.Properties.Settings.Default.PlayerID);

                ReportProgress(30, "Идет загрузка информации о предстоящих сундуках...");
                Program.MyChests = await player.GetChestsInfoAsync(Program.MyPlayerProfile.tag);

                Program.ClanInfo = await clan.GetClanInfoAsync(Program.MyPlayerProfile.clan.tag);

                ReportProgress(40, "Идет загрузка информации о войнах...");
                Program.ClanCurrentWar = await clan.GetCurrentClanWarAsync(Program.MyPlayerProfile.clan.tag);

                Program.ClanWarLog = await clan.GetClanWarLogAsync(Program.MyPlayerProfile.clan.tag);

                ReportProgress(50, "Идет загрузка информации о клане...");
                Program.ClanMembers = await clan.GetClanMembersInfoAsync(Program.MyPlayerProfile.clan.tag);

                int value = (100 - Program.ClanMembers.items.Length);
                ReportProgress(value, "Идет загрузка информации о клане...");
                Program.ClanMembersDetailInfo = new Player[Program.ClanMembers.items.Length];
                Program.ClanMembersChests     = new UpcomingChests[Program.ClanMembers.items.Length];
                for (int i = 0; i < Program.ClanMembers.items.Length; i++)
                {
                    Program.ClanMembersDetailInfo[i] = await player.GetPlayerInfoAsync(Program.ClanMembers.items[i].tag);

                    Program.ClanMembersDetailInfo[i].trophies = Program.ClanMembers.items[i].trophies;
                    Program.ClanMembersDetailInfo[i].lastSeen = Program.ClanMembers.items[i].lastSeen;
                    Program.ClanMembersChests[i] = await player.GetChestsInfoAsync(Program.ClanMembers.items[i].tag);

                    ReportProgress(value, $"Идет загрузка информации о {Program.ClanMembers.items[i].name}...");
                    value++;
                }
                ReportProgress(value, "Информация загружена...");
                if (mainUC != null)
                {
                    mainUC.Dispose();
                    mainUC      = new MainUC();
                    mainUC.Dock = DockStyle.Fill;
                    MainPanel.Controls.Add(mainUC);
                }
                else
                {
                    mainUC      = new MainUC();
                    mainUC.Dock = DockStyle.Fill;
                    MainPanel.Controls.Add(mainUC);
                }
                if (clanCoreUC != null)
                {
                    clanCoreUC.Dispose();
                    clanCoreUC      = new ClanCoreUC();
                    clanCoreUC.Dock = DockStyle.Fill;
                }
                else
                {
                    clanCoreUC      = new ClanCoreUC();
                    clanCoreUC.Dock = DockStyle.Fill;
                }
                settingsUC.Dock = DockStyle.Fill;
            }
            catch (ClashRoyaleAPIException e)
            {
                MetroFramework.MetroMessageBox.Show(this, e.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception e)
            {
                MetroFramework.MetroMessageBox.Show(this, e.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }