private static Image GetImage(TwitchEmoticon emote) { BitmapImage src; if (!s_emotes.TryGetValue(emote, out src)) { if (string.IsNullOrWhiteSpace(emote.LocalFile) || !File.Exists(emote.LocalFile)) { return(null); } try { src = new BitmapImage(); src.BeginInit(); src.UriSource = new Uri(emote.LocalFile, UriKind.RelativeOrAbsolute); src.EndInit(); } catch { try { File.Delete(emote.LocalFile); } catch { } return(null); } } Image img = new Image(); img.Source = src; if (emote.Height != null) { img.Height = (int)emote.Height; } if (emote.Width != null) { img.Width = (int)emote.Width; } img.Stretch = Stretch.Uniform; return(img); }
private static Image GetImage(TwitchEmoticon emote) { BitmapImage src; if (!s_emotes.TryGetValue(emote, out src)) { if (string.IsNullOrWhiteSpace(emote.LocalFile) || !File.Exists(emote.LocalFile)) return null; try { src = new BitmapImage(); src.BeginInit(); src.UriSource = new Uri(emote.LocalFile, UriKind.RelativeOrAbsolute); src.EndInit(); } catch { try { File.Delete(emote.LocalFile); } catch { } return null; } } Image img = new Image(); img.Source = src; if (emote.Height != null) img.Height = (int)emote.Height; if (emote.Width != null) img.Width = (int)emote.Width; img.Stretch = Stretch.Uniform; return img; }