예제 #1
0
 private void loadSmiles()
 {
     using (var wc = new WebClient())
     {
         wc.DownloadStringCompleted += (o, a) =>
         {
             if (a.Error == null)
             {
                 JObject stream = (JObject)JsonConvert.DeserializeObject(a.Result.ToString());
                 if (stream["emoticons"].HasValues)
                 {
                     foreach (JObject jobj in stream["emoticons"])
                     {
                         if (isStopped)
                         {
                             wc.CancelAsync();
                         }
                         TwitchSmile smile = new TwitchSmile();
                         smile.regex = jobj["regex"].ToString();
                         JArray imgopt = (JArray)JsonConvert.DeserializeObject(jobj["images"].ToString());
                         smile.width  = int.Parse(imgopt[0]["width"].ToString());
                         smile.height = int.Parse(imgopt[0]["height"].ToString());
                         smile.uri    = new Uri(imgopt[0]["url"].ToString());
                         if (imgopt[0]["emoticon_set"] != null)
                         {
                             smile.emoticon_set = imgopt[0]["emoticon_set"].ToString();
                         }
                         smile.key = smile.regex;
                         smiles.Add(smile.regex, smile);
                     }
                 }
                 if (smilesLoaded != null)
                 {
                     smilesLoaded(this, new EventArgs());
                 }
             }
         };
         wc.DownloadStringAsync(new Uri(@"https://api.twitch.tv/kraken/chat/emoticons"));
     }
 }
예제 #2
0
 private void loadSmiles()
 {
     using (var wc = new WebClient())
     {
         wc.DownloadStringCompleted += (o, a) =>
         {
             if (a.Error == null) {
                 JObject stream = (JObject)JsonConvert.DeserializeObject(a.Result.ToString());
                 if (stream["emoticons"].HasValues)
                 {
                     foreach (JObject jobj in stream["emoticons"])
                     {
                         if (isStopped)
                         {
                             wc.CancelAsync();
                         }
                         TwitchSmile smile = new TwitchSmile();
                         smile.regex = jobj["regex"].ToString();
                         JArray imgopt = (JArray)JsonConvert.DeserializeObject(jobj["images"].ToString());
                         smile.width = int.Parse(imgopt[0]["width"].ToString());
                         smile.height = int.Parse(imgopt[0]["height"].ToString());
                         smile.uri = new Uri(imgopt[0]["url"].ToString());
                         if(imgopt[0]["emoticon_set"]!=null)
                             smile.emoticon_set = imgopt[0]["emoticon_set"].ToString();
                         smile.key = smile.regex;
                         smiles.Add(smile.regex, smile);
                     }
                 }
                 if (smilesLoaded != null)
                     smilesLoaded(this, new EventArgs());
             }
         };
         wc.DownloadStringAsync(new Uri(@"https://api.twitch.tv/kraken/chat/emoticons"));
     }
 }