Ejemplo n.º 1
0
        private void SetBackgroundAndBorder(TLDecryptedMessageBase messageCommon)
        {
            var isLightTheme   = (Visibility)Application.Current.Resources["PhoneLightThemeVisibility"] == Visibility.Visible;
            var messageService = messageCommon as TLDecryptedMessageService;
            var sticker        = messageCommon != null && messageCommon.IsSticker();
            var output         = GetOutput(messageCommon);

            Brush border;

            if (messageService != null)
            {
                border = (Brush)Resources["ServiceMessageBorderBrush"];
            }
            else if (sticker)
            {
                border = new SolidColorBrush(Colors.Transparent);
            }
            else
            {
                border = isLightTheme
                    ? (output
                        ? (Brush)Resources["OutputBorderBrushLight"]
                        : (Brush)Resources["InputBorderBrushLight"])
                    : (output
                        ? (Brush)Resources["OutputBorderBrushDark"]
                        : (Brush)Resources["InputBorderBrushDark"]);
            }

            Brush background;

            if (messageService != null)
            {
                background = (Brush)Resources["ServiceMessageBackgroundBrush"];
            }
            else if (sticker)
            {
                background = new SolidColorBrush(Colors.Transparent);
            }
            else
            {
                background = isLightTheme
                    ? (output
                        ? (Brush)Resources["OutputBackgroundBrushLight"]
                        : (Brush)Resources["InputBackgroundBrushLight"])
                    : (output
                        ? (Brush)Resources["OutputBackgroundBrushDark"]
                        : (Brush)Resources["InputBackgroundBrushDark"]);
            }

            Corner.Fill              = background;
            Corner.Stroke            = border;
            CornerBorder.BorderBrush = border;

            MainBorder.Background  = background;
            MainBorder.BorderBrush = border;
            MorePanel.Background   = background;
            Header.Background      = background;
        }
        private DataTemplate GenerateCommonMessageTemplate(TLDecryptedMessageBase message)
        {
            if (message != null)
            {
                if (message.IsSticker())
                {
                    if (message.Out.Value)
                    {
                        return(UserStickerTemplate ?? EmptyMessageTemplate);
                    }

                    return(FriendStickerTemplate ?? EmptyMessageTemplate);
                }

                if (message.Out.Value)
                {
                    return(UserMessageTemplate ?? EmptyMessageTemplate);
                }

                return(FriendMessageTemplate ?? EmptyMessageTemplate);
            }

            return(EmptyMessageTemplate);
        }