Beispiel #1
0
        public static WoWMounts getAllMounts(string accessToken)
        {
            WoWMounts  MountList = null;
            string     address   = @"https://us.api.blizzard.com/wow/mount/?locale=en_US&access_token=" + accessToken;
            WebRequest request   = WebRequest.Create(address);

            try
            {
                Cursor.Current = Cursors.WaitCursor;

                HttpWebResponse httpResponse   = (HttpWebResponse)request.GetResponse();
                Stream          responseStream = httpResponse.GetResponseStream();
                if (responseStream != null)
                {
                    using (StreamReader sr = new StreamReader(responseStream))
                    {
                        string responseJSon = sr.ReadToEnd();
                        MountList = JsonConvert.DeserializeObject <WoWMounts>(responseJSon);
                    }
                }
            }
            catch (WebException)
            {
                MessageBox.Show("Unable to get list of mounts.");
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
            return(MountList);
        }
Beispiel #2
0
        public MountWin()
        {
            DataTable GridTable;

            InitializeComponent();

            dataGridView1.DataSource = new DataTable();
            GridTable = (DataTable)dataGridView1.DataSource;
            GridTable.Columns.Add("Name", typeof(string));
            GridTable.Columns.Add("Ground", typeof(bool));
            GridTable.Columns.Add("Flying", typeof(bool));
            GridTable.Columns.Add("Aquatic", typeof(bool));
            GridTable.Columns.Add("Jumping", typeof(bool));

            // get the access token
            ACCESS_TOKEN = GetToken().Result;

            // Get the list of all the mounts in the system if it hasn't been done yet
            AllMounts = WoWMounts.getAllMounts(ACCESS_TOKEN);
            if (AllMounts == null)
            {
                return;
            }

            AllMounts.mounts.Sort((x, y) => String.Compare(x.name, y.name));

            AllRealms = RealmStatus.getAllRealms(ACCESS_TOKEN);
            if (AllRealms == null)
            {
                return;
            }

            AllRealms.realms.Sort((x, y) => String.Compare(x.name, y.name));

            foreach (Realm realm in AllRealms.realms)
            {
                ServerComboBox.Items.Add(realm.name);
            }


            return;
        }