コード例 #1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            var searchTerm = txtSearch.Text;
            var labelMulti = lblMID.Text;
            var labelEcho  = lblEID.Text;
            var labelName  = lblTheName.Text;
            var labelExp   = lblExpansion.Text;
            var labelSet   = lblSC.Text;

            var json      = new WebClient().DownloadString("https://www.echomtg.com/api/data/card_reference/auth=" + dumbToken);
            var myCardRef = CardRef.FromJson(json);

            Console.WriteLine(myCardRef.Message);
            Console.WriteLine(myCardRef.Status);
            Console.WriteLine(myCardRef.Cards.Count);
            try
            {
                foreach (var item in myCardRef.Cards.Keys)
                {
                    if (myCardRef.Cards[item].Name.Equals(searchTerm, StringComparison.InvariantCultureIgnoreCase)) //TODO check if null
                                                                                                                    //TODO iterate through multiple responses. this is important!
                    {
                        string imagelink = ("https://assets.echomtg.com/magic/cards/original/" + myCardRef.Cards[item].EchoId.ToString() + ".jpg");
                        picBox.ImageLocation = imagelink;
                        picBox.SizeMode      = PictureBoxSizeMode.StretchImage;
                        lblTheName.Text      = myCardRef.Cards[item].Name;
                        lblMID.Text          = myCardRef.Cards[item].MultiverseId.ToString();
                        lblEID.Text          = myCardRef.Cards[item].EchoId.ToString();
                        lblExpansion.Text    = myCardRef.Cards[item].Expansion.ToString();
                        lblSC.Text           = myCardRef.Cards[item].SetCode.ToString();
                        break;
                    }
                }
            } catch (NullReferenceException)
            {
                MessageBox.Show("Card not found, please enter a valid card name.", "Error");
            }
        }
コード例 #2
0
 public static string ToJson(this CardRef self) => JsonConvert.SerializeObject(self, MTG_App.Converter.Settings);