private BitmapImage LoadEmojiUnlocked(PartialEmoji e) { try { var b = new BitmapImage(); b.BeginInit(); b.CacheOption = BitmapCacheOption.OnLoad; b.CreateOptions = BitmapCreateOptions.IgnoreImageCache; b.UriSource = new Uri(FromCache(e)); b.EndInit(); return(b); } catch { return(null); } }
public async Task <BitmapImage> EmojiFromCache(PartialEmoji e) { if (File.Exists(FromCache(e))) { return(LoadEmojiUnlocked(e)); } WebClient w = new WebClient(); try { await w.DownloadFileTaskAsync(e.url, FromCache(e)); } catch (WebException ex) { HandleError(ex, "Emoji download"); return(null); } return(LoadEmojiUnlocked(e)); }
public string FromCache(PartialEmoji e) { return(Path.Combine(Cache, e.id + (e.animated ? ".gif" : ".png"))); }