Esempio n. 1
0
        private void UpdateView(WebPageInstantView instantView)
        {
            var              processed       = 0;
            PageBlock        previousBlock   = null;
            FrameworkElement previousElement = null;

            foreach (var block in instantView.PageBlocks)
            {
                var element = ProcessBlock(block);
                var spacing = SpacingBetweenBlocks(previousBlock, block);
                var padding = PaddingForBlock(block);

                if (element != null)
                {
                    if (block is PageBlockChatLink && previousBlock is PageBlockCover)
                    {
                        if (previousElement is StackPanel stack && element is Button)
                        {
                            element.Style  = Resources["CoverChannelBlockStyle"] as Style;
                            element.Margin = new Thickness(padding, -40, padding, 0);
                            stack.Children.Insert(1, element);
                        }
                    }
                    else
                    {
                        element.Margin = new Thickness(padding, spacing, padding, 0);
                        ScrollingHost.Items.Add(element);
                    }
                }

                previousBlock   = block;
                previousElement = element;
                processed++;
            }
        }
        private static GalleryContent CountBlock(IProtoService protoService, WebPageInstantView webPage, PageBlock pageBlock)
        {
            if (pageBlock is PageBlockPhoto photoBlock)
            {
                return(new GalleryPhoto(protoService, photoBlock.Photo, photoBlock.Caption.ToPlainText()));
            }
            else if (pageBlock is PageBlockVideo videoBlock)
            {
                return(new GalleryVideo(protoService, videoBlock.Video, videoBlock.Caption.ToPlainText()));
            }
            else if (pageBlock is PageBlockAnimation animationBlock)
            {
                return(new GalleryAnimation(protoService, animationBlock.Animation, animationBlock.Caption.ToPlainText()));
            }

            return(null);
        }