Ejemplo n.º 1
0
 public void UpdateSizing()
 {
     this.messageHeader.UpdateSizing();
     foreach (var item in this.MessageWrapPanel.Children)
     {
         if (item is TextBlock)
         {
             TextBlock textBlock = (TextBlock)item;
             textBlock.FontSize = ChannelSession.Settings.ChatFontSize;
         }
         else if (item is EmoticonControl)
         {
             EmoticonControl emoticon = (EmoticonControl)item;
             emoticon.Height = emoticon.Width = ChannelSession.Settings.ChatFontSize + 2;
         }
         else if (item is StickerControl)
         {
             StickerControl sticker = (StickerControl)item;
             sticker.UpdateSizing();
         }
         else if (item is SkillControl)
         {
             SkillControl skill = (SkillControl)item;
             skill.UpdateSizing();
         }
     }
 }
Ejemplo n.º 2
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();
            }
        }