Beispiel #1
0
        protected override Task <Dictionary <string, string> > GetReplacementSets(UserViewModel user, IEnumerable <string> arguments, Dictionary <string, string> extraSpecialIdentifiers)
        {
            ChatMessageViewModel message = this.messagesToProcess.First();

            Dictionary <string, string> replacementSets = new Dictionary <string, string>();

            replacementSets["WIDTH"] = this.Width.ToString();

            replacementSets["BACKGROUND_COLOR"] = this.BackgroundColor;
            replacementSets["BORDER_COLOR"]     = this.BorderColor;
            replacementSets["TEXT_COLOR"]       = this.TextColor;
            replacementSets["TEXT_FONT"]        = this.TextFont;
            replacementSets["TEXT_SIZE"]        = this.TextSize.ToString();

            replacementSets["USER_IMAGE"] = message.User.AvatarLink;
            replacementSets["USERNAME"]   = message.User.UserName;
            replacementSets["USER_COLOR"] = OverlayChatMessages.userColors[message.User.PrimaryRoleColorName];

            replacementSets["SUB_IMAGE"] = "";
            if (message.User.IsMixerSubscriber && ChannelSession.Channel.badge != null)
            {
                replacementSets["SUB_IMAGE"] = ChannelSession.Channel.badge.url;
            }

            if (message.Skill != null)
            {
                replacementSets["IMAGE"] = message.Skill.ImageUrl;
            }
            else if (message.ChatSkill != null)
            {
                replacementSets["IMAGE"] = message.ChatSkill.icon_url;
            }
            else
            {
                StringBuilder text = new StringBuilder();
                foreach (ChatMessageDataModel messageData in message.MessageComponents)
                {
                    EmoticonImage emoticon = ChannelSession.GetEmoticonForMessage(messageData);
                    if (emoticon != null)
                    {
                        string emoticonText = OverlayChatMessages.EmoticonMessageHTMLTemplate;
                        emoticonText = emoticonText.Replace("{EMOTICON}", emoticon.Uri);
                        emoticonText = emoticonText.Replace("{TEXT_SIZE}", this.TextSize.ToString());
                        emoticonText = emoticonText.Replace("{EMOTICON_SIZE}", emoticon.Width.ToString());
                        emoticonText = emoticonText.Replace("{EMOTICON_X}", (-emoticon.X).ToString());
                        emoticonText = emoticonText.Replace("{EMOTICON_Y}", (-emoticon.Y).ToString());
                        text.Append(emoticonText + " ");
                    }
                    else
                    {
                        text.Append(messageData.text + " ");
                    }
                }
                replacementSets["TEXT"] = text.ToString().Trim();
            }

            return(Task.FromResult(replacementSets));
        }
Beispiel #2
0
        private async void GlobalEvents_OnChatMessageReceived(object sender, ChatMessageViewModel message)
        {
            if (!message.IsAlert && !message.IsWhisper)
            {
                OverlayListIndividualItemModel item = OverlayListIndividualItemModel.CreateAddItem(message.ID.ToString(), message.User, -1, this.HTML);

                string text            = string.Empty;
                string messageTemplate = string.Empty;
                if (message.Skill != null || message.ChatSkill != null)
                {
                    item.TemplateReplacements.Add("MESSAGE", OverlayChatMessagesListItemModel.SkillImageMessageHTMLTemplate);
                    if (message.Skill != null)
                    {
                        item.TemplateReplacements.Add("IMAGE", message.Skill.ImageUrl);
                    }
                    else if (message.ChatSkill != null)
                    {
                        item.TemplateReplacements.Add("IMAGE", message.ChatSkill.icon_url);
                    }
                }
                else
                {
                    item.TemplateReplacements.Add("MESSAGE", OverlayChatMessagesListItemModel.TextMessageHTMLTemplate);

                    text = message.Message;
                    foreach (ChatMessageDataModel messageData in message.MessageComponents)
                    {
                        EmoticonImage emoticon = ChannelSession.GetEmoticonForMessage(messageData);
                        if (emoticon != null)
                        {
                            string emoticonText = OverlayChatMessagesListItemModel.EmoticonMessageHTMLTemplate;
                            emoticonText = emoticonText.Replace("{EMOTICON}", emoticon.Uri);
                            emoticonText = emoticonText.Replace("{EMOTICON_X}", (-emoticon.X).ToString());
                            emoticonText = emoticonText.Replace("{EMOTICON_Y}", (-emoticon.Y).ToString());
                            text         = text.Replace(messageData.text, emoticonText);
                        }
                    }
                    item.TemplateReplacements.Add("TEXT", text);
                }

                item.TemplateReplacements.Add("USERNAME", item.User.UserName);
                item.TemplateReplacements.Add("USER_IMAGE", item.User.AvatarLink);
                item.TemplateReplacements.Add("USER_COLOR", OverlayChatMessagesListItemModel.userColors[item.User.PrimaryRoleColorName]);
                item.TemplateReplacements.Add("SUB_IMAGE", (item.User.IsMixerSubscriber && ChannelSession.Channel.badge != null) ? ChannelSession.Channel.badge.url : string.Empty);
                item.TemplateReplacements.Add("TEXT_SIZE", this.Height.ToString());

                await this.listSemaphore.WaitAndRelease(() =>
                {
                    this.Items.Add(item);
                    this.SendUpdateRequired();
                    return(Task.FromResult(0));
                });
            }
        }
Beispiel #3
0
        private void SelectIntellisenseEmoticon()
        {
            EmoticonImage emoticon = EmoticonIntellisenseListBox.SelectedItem as EmoticonImage;

            if (emoticon != null)
            {
                if (this.indexOfTag == 0)
                {
                    this.ChatMessageTextBox.Text = emoticon.Name + " ";
                }
                else
                {
                    this.ChatMessageTextBox.Text = this.ChatMessageTextBox.Text.Substring(0, this.indexOfTag) + emoticon.Name + " ";
                }

                this.ChatMessageTextBox.CaretIndex = this.ChatMessageTextBox.Text.Length;
            }
            HideIntellisense();
        }
Beispiel #4
0
        private void ChatMessageControl_Loaded(object sender, RoutedEventArgs e)
        {
            this.MessageWrapPanel.Children.Clear();

            if (!this.Message.IsAlert)
            {
                this.MessageWrapPanel.Children.Add(this.messageHeader);
            }

            if (this.Message.IsSkill)
            {
                SkillControl skillControl = new SkillControl(this.Message.Skill);
                this.MessageWrapPanel.Children.Add(skillControl);
            }

            foreach (ChatMessageDataModel messageData in this.Message.MessageComponents)
            {
                EmoticonImage emoticon = ChannelSession.GetEmoticonForMessage(messageData);
                if (emoticon != null)
                {
                    EmoticonControl emoticonControl = new EmoticonControl(emoticon);
                    this.MessageWrapPanel.Children.Add(emoticonControl);
                }
                else if (messageData.type.Equals("image"))
                {
                    StickerControl stickerControl = new StickerControl(this.Message.ChatSkill);
                    this.MessageWrapPanel.Children.Add(stickerControl);
                }
                else
                {
                    foreach (string word in messageData.text.Split(new string[] { " " }, StringSplitOptions.None))
                    {
                        TextBlock textBlock = new TextBlock();
                        textBlock.Text = word + " ";
                        textBlock.VerticalAlignment = VerticalAlignment.Center;
                        if (this.Message.IsAlert)
                        {
                            textBlock.FontWeight = FontWeights.Bold;
                            if (!string.IsNullOrEmpty(this.Message.AlertMessageBrush) && !this.Message.AlertMessageBrush.Equals(ColorSchemes.DefaultColorScheme))
                            {
                                textBlock.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom(this.Message.AlertMessageBrush));
                            }
                            else
                            {
                                textBlock.Foreground = (App.AppSettings.IsDarkBackground) ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Black);
                            }
                        }

                        bool isWhisperToStreamer = this.Message.IsWhisper && ChannelSession.User.username.Equals(this.Message.TargetUsername, StringComparison.InvariantCultureIgnoreCase);
                        bool isStreamerTagged    = messageData.type == "tag" && word.Equals("@" + ChannelSession.User.username, StringComparison.InvariantCultureIgnoreCase);
                        if (isWhisperToStreamer || isStreamerTagged)
                        {
                            textBlock.Background = (Brush)FindResource("PrimaryHueLightBrush");
                            textBlock.Foreground = (Brush)FindResource("PrimaryHueLightForegroundBrush");
                        }

                        this.textBlocks.Add(textBlock);
                        this.MessageWrapPanel.Children.Add(textBlock);
                    }
                }
            }

            this.UpdateSizing();

            if (!string.IsNullOrEmpty(this.Message.ModerationReason))
            {
                this.DeleteMessage();
            }
        }
 public EmoticonControl(EmoticonImage emoticon) : this()
 {
     InitializeComponent();
     this.DataContext = emoticon;
 }