예제 #1
0
        private void BackToMenu(object sender, EventArgs e)
        {
            if (canBackToMatch != true)       //BackToMenu
            {
                SummonerInfoPanel.Hide();
                FIVEvsFIVEpanel.Hide();
                TypeLabel.Visible = false;
                basicPage.Show();
                basicPage.BringToFront();                                                            //BACK BUTTON

                if (!SaveChechBox.Checked)
                {
                    TextBoxSummonerName.Text = string.Empty;
                }
            }
            else                      // BackToMatch
            {
                canBackToMatch = false;
                SummonerInfoPanel.Hide();
                FIVEvsFIVEpanel.Show();
                FIVEvsFIVEpanel.BringToFront();
            }
        }
예제 #2
0
        public void SearchMatch()
        {
            string SummonerName  = "";
            string Region        = "";
            int    MenuListCount = 0;

            TextBoxSummonerName.Invoke(new MethodInvoker(delegate { SummonerName = TextBoxSummonerName.Text; }));
            regionsComboBox.Invoke(new MethodInvoker(delegate { Region = regionsComboBox.Text; }));
            VersionClass ver = GetVersion.ReturnVersion(Region, apiKey);

            version = ver.n.champion;
            this.Invoke((MethodInvoker) delegate
            {
                MenuListCount = MenuControls.Count;
            });

            try
            {
                for (int a = 0; a < MenuListCount; a++)
                {
                    SetControlPropertyThreadSafe(MenuControls[a], "Enabled", false);
                }
                SummonerInfo summonerInfo = GetSummoner.ReturnSummoner(SummonerName, Region, apiKey);
                MatchInfo = MatchSearch.GetMatch(Region, summonerInfo.id, apiKey);
                string[] Keys  = MatchSearch.GetKeys(JSON, MatchInfo);
                string[] Names = MatchSearch.GetName(JSON, MatchInfo);

                SetControlPropertyThreadSafe(Summoner1, "Text", MatchInfo.participants[0].summonerName);
                SetControlPropertyThreadSafe(Summoner2, "Text", MatchInfo.participants[1].summonerName);
                SetControlPropertyThreadSafe(Summoner3, "Text", MatchInfo.participants[2].summonerName);
                SetControlPropertyThreadSafe(Summoner4, "Text", MatchInfo.participants[3].summonerName);
                SetControlPropertyThreadSafe(Summoner5, "Text", MatchInfo.participants[4].summonerName);
                SetControlPropertyThreadSafe(Summoner6, "Text", MatchInfo.participants[5].summonerName);
                SetControlPropertyThreadSafe(Summoner7, "Text", MatchInfo.participants[6].summonerName);
                SetControlPropertyThreadSafe(Summoner8, "Text", MatchInfo.participants[7].summonerName);
                SetControlPropertyThreadSafe(Summoner9, "Text", MatchInfo.participants[8].summonerName);
                SetControlPropertyThreadSafe(Summoner10, "Text", MatchInfo.participants[9].summonerName);


                PictureBox[] pb = new PictureBox[10] {
                    TeamMatePictureBox0, TeamMatePictureBox1, TeamMatePictureBox2, TeamMatePictureBox3, TeamMatePictureBox4, TeamMatePictureBox5, TeamMatePictureBox6, TeamMatePictureBox7, TeamMatePictureBox8, TeamMatePictureBox9
                };

                for (int i = 0; i < 10; i++)
                {
                    pb[i].Load("http://ddragon.leagueoflegends.com/cdn/" + version + "/img/champion/" + Keys[i] + ".png");
                    this.Invoke((MethodInvoker) delegate
                    {
                        LoLToolTip.SetToolTip(pb[i], Names[i]);
                    });
                }
                if (MatchInfo.gameQueueConfigId == 4 || MatchInfo.gameQueueConfigId == 6 || MatchInfo.gameQueueConfigId == 9 || MatchInfo.gameQueueConfigId == 41 || MatchInfo.gameQueueConfigId == 42)
                {
                    PictureBox[] pbBans = new PictureBox[6] {
                        banPB1, banPB2, banPB3, banPB4, banPB5, banPB6
                    };
                    for (int i = 10; i < Keys.Length; i++)
                    {
                        pbBans[i - 10].Load("http://ddragon.leagueoflegends.com/cdn/" + version + "/img/champion/" + Keys[i] + ".png");
                        this.Invoke((MethodInvoker) delegate
                        {
                            LoLToolTip.SetToolTip(pbBans[i - 10], Names[i]);
                        });
                    }
                }
                PictureBox[] summonerSpell_1 = new PictureBox[10] {
                    Summoner1Spell1, Summoner2Spell1, Summoner3Spell1, Summoner4Spell1, Summoner5Spell1, Summoner6Spell1, Summoner7Spell1, Summoner8Spell1, Summoner9Spell1, Summoner10Spell1
                };
                PictureBox[] summonerSpell_2 = new PictureBox[10] {
                    Summoner1Spell2, Summoner2Spell2, Summoner3Spell2, Summoner4Spell2, Summoner5Spell2, Summoner6Spell2, Summoner7Spell2, Summoner8Spell2, Summoner9Spell2, Summoner10Spell2
                };

                List <Spells> summonerSpell = SummonerSpells.GetSpells(Region, apiKey);

                int      x      = 0;
                string[] SummID = new string[10];
                foreach (Participant part in MatchInfo.participants)
                {
                    SummID[x] = part.summonerId.ToString();
                    foreach (var item in summonerSpell)
                    {
                        if (item.Id == part.spell1Id)
                        {
                            summonerSpell_1[x].Load("http://ddragon.leagueoflegends.com/cdn/" + version + "/img/spell/" + item.Key + ".png");

                            this.Invoke((MethodInvoker) delegate
                            {
                                LoLToolTip.SetToolTip(summonerSpell_1[x], item.Name);
                            });
                        }
                        if (item.Id == part.spell2Id)
                        {
                            summonerSpell_2[x].Load("http://ddragon.leagueoflegends.com/cdn/" + version + "/img/spell/" + item.Key + ".png");
                            this.Invoke((MethodInvoker) delegate
                            {
                                LoLToolTip.SetToolTip(summonerSpell_2[x], item.Name);
                            });
                        }
                    }
                    x++;
                }


                PictureBox[] DivisionsPB = new PictureBox[10] {
                    divPb1, divPB2, divPB3, divPB4, divPB5, divPB6, divPB7, divPB8, divPB9, divPB10
                };
                Label[] divLabels = new Label[10] {
                    DivString1, DivString2, DivString3, DivString4, DivString5, DivString6, DivString7, DivString8, DivString9, DivString10
                };

                ReturnDivision divisionsImages = ReturnDivisionInfo.GetDivisions(Region, apiKey, SummID);



                for (int i = 0; i < divisionsImages.divList.Count(); i++)
                {
                    SetControlPropertyThreadSafe(divLabels[i], "Text", divisionsImages.divList[i].Division);
                    SetControlPropertyThreadSafe(DivisionsPB[i], "Image", divisionsImages.image[i]);

                    this.Invoke((MethodInvoker) delegate
                    {
                        LoLToolTip.SetToolTip((Control)DivisionsPB[i], divisionsImages.divList[i].Name);
                    });
                }



                //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
                SetControlPropertyThreadSafe(LoadCircle, "Visible", false);
                for (int a = 0; a < MenuListCount; a++)
                {
                    SetControlPropertyThreadSafe(MenuControls[a], "Enabled", true);
                }
                this.Invoke((MethodInvoker) delegate
                {
                    basicPage.Hide();
                    FIVEvsFIVEpanel.Show();
                    FIVEvsFIVEpanel.BringToFront();
                });
            }
            catch (WebException ex)
            {
                MessageBox.Show(ex.ToString());
                if (ex.Status == WebExceptionStatus.ProtocolError)
                {
                    var response = (HttpWebResponse)ex.Response;
                    if (response.StatusCode == HttpStatusCode.NotFound)
                    {
                        SetControlPropertyThreadSafe(MessageLabel, "Visible", true);
                        SetControlPropertyThreadSafe(MessageLabel, "Text", "The summoner " + SummonerName + " is not currently in a game!");

                        this.Invoke((MethodInvoker) delegate
                        {
                            emptyTextBoxControlTimer.Enabled = true;
                        });

                        SetControlPropertyThreadSafe(LoadCircle, "Visible", false);
                        for (int a = 0; a < MenuListCount; a++)
                        {
                            SetControlPropertyThreadSafe(MenuControls[a], "Enabled", true);
                        }
                    }
                }
                for (int a = 0; a < MenuListCount; a++)
                {
                    SetControlPropertyThreadSafe(MenuControls[a], "Enabled", true);
                }
                SetControlPropertyThreadSafe(LoadCircle, "Visible", false);
            }
        }