private void LoadContent()
        {
            Cursor = Cursors.Wait;
            this.MediaContentPanel.Children.Clear();

            switch (Category)
            {
                case "entertainment":
                    SectionMediaContent = App.EntertainmentContent.ToList();
                    break;
                case "games":
                    SectionMediaContent = App.GamesContent.ToList();
                    break;
                case "education":
                    SectionMediaContent = App.EducationContent.ToList();
                    break;
                default:
                    break;
            }

            foreach (aladdinService.MediaContent content in SectionMediaContent)
            {
                MediaContentControl mediaContentControl = new MediaContentControl();
                mediaContentControl.Title = content.title;
                mediaContentControl.MediaContent = content;
                this.MediaContentPanel.Children.Add(mediaContentControl);
            }

            Cursor = Cursors.Arrow;
        }
Example #2
0
        private void SetFooter(TLDecryptedMessageBase messageBase)
        {
            var isLightTheme = (Visibility)Application.Current.Resources["PhoneLightThemeVisibility"] == Visibility.Visible;

            var message = messageBase as TLDecryptedMessage;
            var service = messageBase as TLDecryptedMessageService;
            var output  = GetOutput(messageBase);

            var isGroupedMedia = message != null && message.Media is TLDecryptedMessageMediaGroup;
            var isPhoto        = message != null && message.Media is TLDecryptedMessageMediaPhoto;
            var isVideo        = message != null && message.IsVideo();
            var isGeoPoint     = message != null && message.Media is TLDecryptedMessageMediaGeoPoint;
            var isVenue        = message != null && message.Media is TLDecryptedMessageMediaVenue;
            var isDocument     = message != null && IsDocument(message);
            var isVoice        = message != null && message.IsVoice();
            var isSticker      = message != null && message.IsSticker();
            var isWebPage      = message != null && message.Media is TLDecryptedMessageMediaWebPage;
            var isEmptyMedia   = message != null && (message.Media == null || message.Media is TLDecryptedMessageMediaEmpty);

            //var isGif = message != null && message.IsGif();
            var isShortFooter = IsShortFooter(message, isGroupedMedia, isPhoto, isVideo, isGeoPoint, isDocument, isVoice, isSticker, isWebPage, isEmptyMedia);

            Brush background = new SolidColorBrush(Colors.Transparent);

            if (service != null)
            {
                background = (Brush)Resources["ServiceMessageBackgroundBrush"];
            }
            else if (!isSticker)
            {
                background = isLightTheme
                    ? (output
                        ? (Brush)Resources["OutputBackgroundBrushLight"]
                        : (Brush)Resources["InputBackgroundBrushLight"])
                    : (output
                        ? (Brush)Resources["OutputBackgroundBrushDark"]
                        : (Brush)Resources["InputBackgroundBrushDark"]);
            }

            Brush footerForeground;

            if (isSticker)
            {
                footerForeground = isLightTheme
                    ? (Brush)Resources["StickerFooterSubtleBrushLight"]
                    : (Brush)Resources["StickerFooterSubtleBrushDark"];
            }
            else if (isShortFooter && (isGroupedMedia || isPhoto || (isGeoPoint && !isVenue) || isVideo))
            {
                footerForeground = new SolidColorBrush(Colors.White);
            }
            else
            {
                footerForeground = isLightTheme
                ? (output
                    ? (Brush)Resources["OutputSubtleBrushLight"]
                    : (Brush)Resources["InputSubtleBrushLight"])
                : (output
                    ? (Brush)Resources["OutputSubtleBrushDark"]
                    : (Brush)Resources["InputSubtleBrushDark"]);
            }

            Brush footerBackground;

            if (isSticker)
            {
                footerBackground = isLightTheme
                    ? (Brush)Resources["StickerFooterBackgroundBrushLight"]
                    : (Brush)Resources["StickerFooterBackgroundBrushDark"];
            }
            else if (isShortFooter && (isGroupedMedia || isPhoto || (isGeoPoint && !isVenue) || isVideo))
            {
                footerBackground = new SolidColorBrush(Color.FromArgb(128, 0, 0, 0));
            }
            else
            {
                footerBackground = new SolidColorBrush(Colors.Transparent);
            }

            FooterContent.Foreground     = footerForeground;
            FooterContentGrid.Background = footerBackground;
            Footer.MaxWidth = message != null ? message.MediaWidth : 12.0 + 311.0 + 12.0;
            Status.Fill     = footerForeground;
            //ViewsIcon.Stroke = footerForeground;

            if (messageBase != null && messageBase.Reply != null && (isGroupedMedia || isPhoto || isVideo))
            {
                MediaContentControl.Margin = new Thickness(12.0, 3.0, 12.0, 0.0);
            }
            else
            {
                MediaContentControl.Margin = new Thickness(12.0, 0.0, 12.0, 0.0);
            }

            // setup message and media position
            //MessageGrid.Visibility = message != null && !TLString.IsNullOrEmpty(message.Message) || showAsServiceMessage
            //    ? Visibility.Visible
            //    : Visibility.Collapsed;
            //Panel.Children.Remove(MessageGrid);
            //Panel.Children.Remove(MediaGrid);
            //if (message != null && (message.Media is TLMessageMediaWebPage || message.Media is TLMessageMediaEmpty) || showAsServiceMessage)
            //{
            //    MessageGrid.Margin = new Thickness(0.0, 6.0, 0.0, 0.0);
            //    MediaGrid.Margin = new Thickness(0.0, 0.0, 0.0, 0.0);

            //    Panel.Children.Add(MessageGrid);
            //    Panel.Children.Add(MediaGrid);
            //}
            //else
            //{
            //    MessageGrid.Margin = new Thickness(0.0, 0.0, 0.0, 0.0);
            //    MediaGrid.Margin = new Thickness(0.0, 6.0, 0.0, 0.0);

            //    Panel.Children.Add(MediaGrid);
            //    Panel.Children.Add(MessageGrid);
            //}

            // setup footer position
            Panel.Children.Remove(Footer);
            MediaGrid.Children.Remove(Footer);
            MessageGrid.Children.Remove(Footer);
            if (service != null)
            {
                // remove footer
            }
            else if (!isShortFooter)
            {
                Footer.Margin              = new Thickness(0.0, -1.0, 0.0, 0.0);
                Footer.Background          = background;
                Footer.HorizontalAlignment = HorizontalAlignment.Stretch;
                Footer.VerticalAlignment   = VerticalAlignment.Stretch;
                Panel.Children.Add(Footer);
                MessageGrid.Margin = new Thickness(0.0, 6.0, 0.0, 0.0);
            }
            else
            {
                if (isSticker)
                {
                    Footer.Margin              = new Thickness(0.0, -1.0, 0.0, 0.0);
                    Footer.Background          = new SolidColorBrush(Colors.Transparent);
                    Footer.HorizontalAlignment = HorizontalAlignment.Right;
                    Footer.VerticalAlignment   = VerticalAlignment.Bottom;
                    MediaGrid.Children.Add(Footer);
                    MessageGrid.Margin = new Thickness(0.0, 0.0, 0.0, 0.0);
                }
                else if (isEmptyMedia)
                {
                    Footer.Margin              = new Thickness(0.0, -1.0, 0.0, -11.0);
                    Footer.Background          = new SolidColorBrush(Colors.Transparent);
                    Footer.HorizontalAlignment = HorizontalAlignment.Stretch;
                    Footer.VerticalAlignment   = VerticalAlignment.Bottom;
                    MessageGrid.Children.Add(Footer);
                    MessageGrid.Margin = new Thickness(0.0, 6.0, 0.0, 11.0);
                }
                else if (isGroupedMedia || isPhoto || isGeoPoint || isVideo || isVoice || isDocument)
                {
                    Footer.Margin              = new Thickness(0.0, -1.0, 0.0, 0.0);
                    Footer.Background          = new SolidColorBrush(Colors.Transparent);
                    Footer.HorizontalAlignment = HorizontalAlignment.Right;
                    Footer.VerticalAlignment   = VerticalAlignment.Bottom;
                    MediaGrid.Children.Add(Footer);
                    MessageGrid.Margin = new Thickness(0.0, 6.0, 0.0, 0.0);
                }
                else
                {
                    Footer.Margin              = new Thickness(0.0, -1.0, 0.0, 0.0);
                    Footer.Background          = background;
                    Footer.HorizontalAlignment = HorizontalAlignment.Stretch;
                    Footer.VerticalAlignment   = VerticalAlignment.Stretch;
                    Panel.Children.Add(Footer);
                    MessageGrid.Margin = new Thickness(0.0, 6.0, 0.0, 0.0);
                }
            }

            if (message != null &&
                (message.Media == null || message.Media is TLDecryptedMessageMediaEmpty))
            {
                var messageDateTimeConverter = (IValueConverter)Application.Current.Resources["MessageDateTimeConverter"];
                var dateText = messageDateTimeConverter.Convert(message.Date, null, null, null);

                var footerBuilder = new StringBuilder();
                if (FlowDirection == FlowDirection.RightToLeft)
                {
                    footerBuilder.Append("د");
                }
                else
                {
                    footerBuilder.Append("a");
                }
                footerBuilder.Append("/ " + dateText);
                if (message.Out.Value)
                {
                    footerBuilder.Append(" W");
                }

                InputMessage.Footer = footerBuilder.ToString();
            }
            else
            {
                InputMessage.Footer = string.Empty;
            }

            if (isVoice)
            {
                MediaContentControl.Foreground = footerForeground;
            }
            else
            {
                MediaContentControl.SetValue(Control.ForegroundProperty, DependencyProperty.UnsetValue);
            }
        }