Пример #1
0
        // ============================================================================================================
        // Image and href link region handling
        // ============================================================================================================

        void GetAllImages(BlockElement block)
        {
            IResourceProvider provider = Service.Get <IResourceProvider>();

            foreach (AElement atom in block.Children)
            {
                if (atom is ImageElement)
                {
                    if (m_Images == null)
                    {
                        m_Images = new HtmlImageList();
                    }
                    ImageElement img = (ImageElement)atom;
                    if (img.ImageType == ImageElement.ImageTypes.UI)
                    {
                        Texture2D standard = provider.GetUITexture(img.ImgSrc);
                        Texture2D over     = provider.GetUITexture(img.ImgSrcOver);
                        Texture2D down     = provider.GetUITexture(img.ImgSrcDown);
                        m_Images.AddImage(new Rectangle(), standard, over, down);
                    }
                    else if (img.ImageType == ImageElement.ImageTypes.Item)
                    {
                        Texture2D standard, over, down;
                        standard = over = down = provider.GetItemTexture(img.ImgSrc);
                        m_Images.AddImage(new Rectangle(), standard, over, down);
                    }
                    img.AssociatedImage = m_Images[m_Images.Count - 1];
                }
                else if (atom is BlockElement)
                {
                    GetAllImages(atom as BlockElement);
                }
            }
        }
Пример #2
0
        // ======================================================================
        // Ctor and Dipose
        // ======================================================================

        public HtmlDocument(string html, int width, bool collapseBlocks = false)
        {
            m_Root = ParseHtmlToBlocks(html);
            m_CollapseToContent = collapseBlocks;

            Images = new HtmlImageList();
            GetAllImages(Images, m_Root);

            Links = GetAllHrefRegionsInBlock(m_Root);

            DoLayout(m_Root, width);
            if (Ascender != 0)
                m_Root.Height -= Ascender; // ascender is always negative.
            Texture = DoRender(m_Root);
        }
Пример #3
0
        // ======================================================================
        // Ctor and Dipose
        // ======================================================================

        public HtmlDocument(string html, int width, bool collapseBlocks = false)
        {
            m_Root = ParseHtmlToBlocks(html);
            m_CollapseToContent = collapseBlocks;

            Images = new HtmlImageList();
            GetAllImages(Images, m_Root);

            Links = GetAllHrefRegionsInBlock(m_Root);

            DoLayout(m_Root, width);
            if (Ascender != 0)
            {
                m_Root.Height -= Ascender;
            }
            Texture = DoRender(m_Root);
        }
Пример #4
0
        // ======================================================================
        // Image and href link region handling
        // ======================================================================

        private void GetAllImages(HtmlImageList images, BlockElement block)
        {
            IResourceProvider provider = ServiceRegistry.GetService<IResourceProvider>();

            foreach (AElement atom in block.Children)
            {
                if (atom is ImageElement)
                {
                    ImageElement img = (ImageElement)atom;
                    if (img.ImageType == ImageElement.ImageTypes.UI)
                    {
                        Texture2D standard = provider.GetUITexture(img.ImgSrc);
                        Texture2D over = provider.GetUITexture(img.ImgSrcOver);
                        Texture2D down = provider.GetUITexture(img.ImgSrcDown);
                        images.AddImage(new Rectangle(), standard, over, down);
                    }
                    else if (img.ImageType == ImageElement.ImageTypes.Item)
                    {
                        Texture2D standard, over, down;
                        standard = over = down = provider.GetItemTexture(img.ImgSrc);
                        images.AddImage(new Rectangle(), standard, over, down);
                    }
                    img.AssociatedImage = images[images.Count - 1];
                }
                else if (atom is BlockElement)
                {
                    GetAllImages(images, atom as BlockElement);
                }
            }
        }