private async void EmoticonControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { try { if (this.DataContext != null) { if (this.DataContext is TwitchV5API.EmoteModel) { TwitchV5API.EmoteModel emote = (TwitchV5API.EmoteModel) this.DataContext; this.Image.Source = await this.DownloadImageUrl(emote.URL); this.Image.ToolTip = this.AltText.Text = emote.code; } else if (this.DataContext is BetterTTVEmoteModel) { BetterTTVEmoteModel emote = (BetterTTVEmoteModel)this.DataContext; if (emote.imageType.Equals("gif")) { this.ProcessGifImage(emote.url); } else { this.Image.Source = await this.DownloadImageUrl(emote.url); } this.Image.ToolTip = this.AltText.Text = emote.code; } else if (this.DataContext is FrankerFaceZEmoteModel) { FrankerFaceZEmoteModel emote = (FrankerFaceZEmoteModel)this.DataContext; this.Image.Source = await this.DownloadImageUrl(emote.url); this.Image.ToolTip = this.AltText.Text = emote.name; } else if (this.DataContext is TwitchBitsCheerViewModel) { TwitchBitsCheerViewModel bitsCheer = (TwitchBitsCheerViewModel)this.DataContext; this.Image.Source = await this.DownloadImageUrl((ChannelSession.AppSettings.IsDarkBackground)?bitsCheer.Tier.DarkImage : bitsCheer.Tier.LightImage); this.Image.ToolTip = this.AltText.Text = bitsCheer.Text; this.Text.Visibility = Visibility.Visible; this.Text.Text = bitsCheer.Amount.ToString(); } else if (this.DataContext is string) { string imageUrl = (string)this.DataContext; this.Image.Source = await this.DownloadImageUrl(imageUrl); } if (this.Image.Source != null) { this.Image.MaxWidth = this.Image.MaxHeight = this.Image.Width = this.Image.Height = ChannelSession.Settings.ChatFontSize * 2; } } } catch (Exception ex) { Logger.Log(ex); } }
public ChatImageControl(TwitchV5API.EmoteModel emote) : this() { this.DataContext = emote; }