Пример #1
0
        public ExploreItem(FeedItemData item, ThemeConfig theme)
        {
            this.HAnchor = HAnchor.Absolute;
            this.Width   = 400 * GuiWidget.DeviceScale;
            //this.Border = spacing;
            this.Padding = ItemSpacing;
            this.item    = item;

            if (item.icon != null)
            {
                ImageBuffer image = new ImageBuffer(IconSize, IconSize);

                var imageWidget = new ImageWidget(image)
                {
                    Selectable = false,
                    VAnchor    = VAnchor.Top,
                    Margin     = new BorderDouble(right: ItemSpacing)
                };

                imageWidget.Load += (s, e) => ApplicationController.Instance.DownloadToImageAsync(image, item.icon, true, new BlenderPreMultBGRA());
                this.AddChild(imageWidget);
            }
            else if (item.widget_url != null)
            {
                ImageBuffer image = new ImageBuffer(IconSize, IconSize);

                var whiteBackground = new GuiWidget(IconSize, IconSize)
                {
                    // these images expect to be on white so change the background to white
                    BackgroundColor = Color.White,
                    Margin          = new BorderDouble(right: ItemSpacing)
                };
                this.AddChild(whiteBackground);

                var imageWidget = new ImageWidget(image)
                {
                    Selectable = false,
                    VAnchor    = VAnchor.Center,
                };

                imageWidget.Load += (s, e) => ApplicationController.Instance.DownloadToImageAsync(image, item.widget_url, true, new BlenderPreMultBGRA());
                whiteBackground.AddChild(imageWidget);
            }

            var wrappedText = new WrappedTextWidget(item.title, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: theme.DefaultFontSize)
            {
                Selectable = false,
                VAnchor    = VAnchor.Center | VAnchor.Fit,
                Margin     = 3
            };

            this.AddChild(wrappedText);
            wrappedText.Load += (s, e) =>
            {
                wrappedText.VAnchor = VAnchor.Top | VAnchor.Fit;
            };

            this.Cursor = Cursors.Hand;
        }
Пример #2
0
        public ArticleItem(FeedItemData item, ThemeConfig theme)
        {
            this.HAnchor = HAnchor.Absolute;
            this.Width   = 400 * GuiWidget.DeviceScale;
            //this.Border = spacing;
            this.Padding = ItemSpacing;
            this.item    = item;
            this.theme   = theme;

            var image = new ImageBuffer(IconSize, IconSize);

            if (item.icon != null)
            {
                var imageWidget = new ImageWidget(image)
                {
                    Selectable = false,
                    VAnchor    = VAnchor.Top,
                    Margin     = new BorderDouble(right: ItemSpacing)
                };

                Load += (s, e) => WebCache.RetrieveImageAsync(image, item.icon, true);
                this.AddChild(imageWidget);
            }
            else if (item.widget_url != null)
            {
                var whiteBackground = new GuiWidget(IconSize, IconSize)
                {
                    // these images expect to be on white so change the background to white
                    BackgroundColor = Color.White,
                    Margin          = new BorderDouble(right: ItemSpacing)
                };
                this.AddChild(whiteBackground);

                var imageWidget = new ImageWidget(image)
                {
                    Selectable = false,
                    VAnchor    = VAnchor.Center,
                };

                Load += (s, e) => WebCache.RetrieveImageAsync(image, item.widget_url, true);
                whiteBackground.AddChild(imageWidget);
            }

            var wrappedText = new WrappedTextWidget(item.title, textColor: theme.TextColor, pointSize: theme.DefaultFontSize)
            {
                Selectable = false,
                VAnchor    = VAnchor.Center | VAnchor.Fit,
                Margin     = 3
            };

            this.AddChild(wrappedText);
            wrappedText.Load += (s, e) =>
            {
                wrappedText.VAnchor = VAnchor.Top | VAnchor.Fit;
            };

            this.Cursor = Cursors.Hand;
        }
Пример #3
0
        public ProductItem(FeedItemData item, ThemeConfig theme)
            : base(FlowDirection.TopToBottom)
        {
            this.Padding = ItemSpacing;
            this.item    = item;
            this.theme   = theme;

            var image = new ImageBuffer(IconSize, IconSize);

            image.SetRecieveBlender(new BlenderPreMultBGRA());
            BackgroundRadius = 5 * GuiWidget.DeviceScale;

            if (item.widget_url != null)
            {
                var whiteBackground = new GuiWidget(IconSize, IconSize)
                {
                    // these images expect to be on white so change the background to white
                    BackgroundColor  = Color.White,
                    BackgroundRadius = 5 * GuiWidget.DeviceScale,
                    Margin           = new BorderDouble(3, 0, 3, 3),
                    Selectable       = false
                };
                this.AddChild(whiteBackground);

                var imageWidget = new ImageWidget(image)
                {
                    Selectable = false,
                    VAnchor    = VAnchor.Center,
                };

                Load += (s, e) => WebCache.RetrieveImageAsync(image, item.widget_url, true);
                whiteBackground.AddChild(imageWidget);
            }

            var titleText = new FlowLeftRightWithWrapping()
            {
                Selectable = false,
                VAnchor    = VAnchor.Fit,
                HAnchor    = HAnchor.Stretch,
                Margin     = new BorderDouble(3, 3, 3, 9),
                Center     = true
            };

            titleText.AddText(item.title, textColor: theme.TextColor, pointSize: theme.FontSize14);

            this.AddChild(titleText);

            var descriptionText = new FlowLeftRightWithWrapping()
            {
                Selectable = false,
                VAnchor    = VAnchor.Fit,
                HAnchor    = HAnchor.Stretch,
                Margin     = 3,
                Center     = true
            };

            descriptionText.AddText(item.subtitle, textColor: theme.TextColor.WithAlpha(.7), pointSize: theme.FontSize8);

            this.AddChild(descriptionText);

            this.Cursor = Cursors.Hand;

            this.VAnchor = VAnchor.Fit | VAnchor.Top;
        }