Пример #1
0
        private void loadSmiles()
        {
            try
            {
                using (WebClient webClient = new WebClient()){
                    string text       = webClient.DownloadString(smilesUri);
                    int    startIndex = text.IndexOf('[');
                    int    endIndex   = text.IndexOf(';');
                    string array      = text.Substring(startIndex, endIndex - startIndex);
                    JArray emotions   = JsonConvert.DeserializeObject <JArray>(array);

                    foreach (JObject emote in emotions)
                    {
                        SC2TVSmile s = new SC2TVSmile();
                        s.code   = ":s" + emote["code"].ToString();
                        s.uri    = new Uri(imageUri + emote["img"].ToString());
                        s.width  = int.Parse(emote["width"].ToString());
                        s.height = int.Parse(emote["height"].ToString());
                        smiles.Add(":s" + emote["code"].ToString(), s);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.Print("Exception on loading smiles: " + e.Message);
            }
        }
Пример #2
0
 private void loadSmiles() {
     try
     {
         using(WebClient webClient = new WebClient()){
             string text = webClient.DownloadString(smilesUri);
             int startIndex = text.IndexOf('[');
             int endIndex = text.IndexOf(';');
             string array = text.Substring(startIndex, endIndex - startIndex);
             JArray emotions = JsonConvert.DeserializeObject<JArray>(array);
             
             foreach (JObject emote in emotions)
             {
                 SC2TVSmile s = new SC2TVSmile();
                 s.code = ":s" + emote["code"].ToString();
                 s.uri = new Uri(imageUri + emote["img"].ToString());
                 s.width = int.Parse(emote["width"].ToString());
                 s.height = int.Parse(emote["height"].ToString());
                 smiles.Add(":s" + emote["code"].ToString(), s);
             }
         }
     }
     catch(Exception e)
     {
         Debug.Print("Exception on loading smiles: " + e.Message);
     }
 }