public static string getRaceFromID(string AccessToken, int RaceID) { WoWRace WoWRace = null; string address = @"https://us.api.blizzard.com/data/wow/playable-race/" + RaceID + "?namespace=static-us&locale=en_US&access_token=" + AccessToken; address = System.Uri.EscapeUriString(address); 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(); WoWRace = JsonConvert.DeserializeObject <WoWRace>(responseJSon); } } } catch (WebException) { MessageBox.Show("Unable to get race name for race: <" + RaceID + ">."); return("Unknown Race " + RaceID); } finally { Cursor.Current = Cursors.Default; } return(WoWRace.name); }
private void button1_Click(object sender, EventArgs e) { CharData CurrentChar; string url; CurrentChar = CharData.getCharacterDescription(ServerComboBox.Text, CharacterTextBox.Text, ACCESS_TOKEN); if (CurrentChar == null) { return; } BattleGroup.Text = CurrentChar.battlegroup; Class.Text = ClassData.getClassNameFromID(AllClasses, CurrentChar.@class); Race.Text = WoWRace.getRaceFromID(ACCESS_TOKEN, CurrentChar.race); if (CurrentChar.gender == 0) { Gender.Text = "Male"; } else { Gender.Text = "Female"; } Level.Text = CurrentChar.level.ToString(); url = "http://render-us.worldofwarcraft.com/character/" + CurrentChar.thumbnail; pictureBox1.ImageLocation = url; return; }