• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Dom.CssBox类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中HtmlRenderer.Dom.CssBox的典型用法代码示例。如果您正苦于以下问题:C# CssBox类的具体用法?C# CssBox怎么用?C# CssBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CssBox类属于HtmlRenderer.Dom命名空间,在下文中一共展示了CssBox类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CssBoxWord

 /// <summary>
 /// Init.
 /// </summary>
 /// <param name="owner">the CSS box owner of the word</param>
 /// <param name="word">the word chars </param>
 /// <param name="hasSpaceBefore">was there a whitespace before the word chars (before trim)</param>
 /// <param name="hasSpaceAfter">was there a whitespace after the word chars (before trim)</param>
 public CssBoxWord(CssBox owner, string word, bool hasSpaceBefore, bool hasSpaceAfter)
 {
     _ownerBox = owner;
     _word = word;
     _hasSpaceBefore = hasSpaceBefore;
     _hasSpaceAfter = hasSpaceAfter;
 }
开发者ID:Alister742,项目名称:ParseKit,代码行数:14,代码来源:CssBoxWord.cs


示例2: ClipGraphicsByOverflow

 /// <summary>
 /// Clip the region the graphics will draw on by the overflow style of the containing block.<br/>
 /// Recursively travel up the tree to find containing block that has overflow style set to hidden. if not
 /// block found there will be no clipping and null will be returned.
 /// </summary>
 /// <param name="g">the graphics to clip</param>
 /// <param name="box">the box that is rendered to get containing blocks</param>
 /// <returns>the prev region if clipped, otherwise null</returns>
 public static RectangleF ClipGraphicsByOverflow(IGraphics g, CssBox box)
 {
     var containingBlock = box.ContainingBlock;
     while (true)
     {
         if (containingBlock.Overflow == CssConstants.Hidden)
         {
             var prevClip = g.GetClip();
             var rect = box.ContainingBlock.ClientRectangle;
             rect.X -= 2; // atodo: find better way to fix it
             rect.Width += 2;
             rect.Offset(box.HtmlContainer.ScrollOffset);
             rect.Intersect(prevClip);
             g.SetClip(rect);
             return prevClip;
         }
         else
         {
             var cBlock = containingBlock.ContainingBlock;
             if (cBlock == containingBlock)
                 return RectangleF.Empty;
             containingBlock = cBlock;
         }
     }
 }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:33,代码来源:RenderUtils.cs


示例3: CssBoxFrame

        /// <summary>
        /// Init.
        /// </summary>
        /// <param name="parent">the parent box of this box</param>
        /// <param name="tag">the html tag data of this box</param>
        public CssBoxFrame(CssBox parent, HtmlTag tag)
            : base(parent, tag)
        {
            _imageWord = new CssRectImage(this);
            Words.Add(_imageWord);

            Uri uri;
            if (Uri.TryCreate(GetAttribute("src"),UriKind.Absolute, out uri))
            {
                if(uri.Host.IndexOf("youtube.com",StringComparison.InvariantCultureIgnoreCase) > -1)
                {
                    _isVideo = true;
                    LoadYoutubeDataAsync(uri);
                }
                else if (uri.Host.IndexOf("vimeo.com",StringComparison.InvariantCultureIgnoreCase) > -1)
                {
                    _isVideo = true;
                    LoadVimeoDataAsync(uri);
                }
            }

            if (!_isVideo)
            {
                SetErrorBorder();
            }
        }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:31,代码来源:CssBoxFrame.cs


示例4: CssRectWord

 /// <summary>
 /// Init.
 /// </summary>
 /// <param name="owner">the CSS box owner of the word</param>
 /// <param name="text">the word chars </param>
 /// <param name="hasSpaceBefore">was there a whitespace before the word chars (before trim)</param>
 /// <param name="hasSpaceAfter">was there a whitespace after the word chars (before trim)</param>
 public CssRectWord(CssBox owner, string text, bool hasSpaceBefore, bool hasSpaceAfter)
     : base(owner)
 {
     _text = text;
     _hasSpaceBefore = hasSpaceBefore;
     _hasSpaceAfter = hasSpaceAfter;
 }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:14,代码来源:CssRectWord.cs


示例5: ApplyTableBorder

 /// <summary>
 /// Cascades to the TD's the border spacified in the TABLE tag.
 /// </summary>
 /// <param name="table"></param>
 /// <param name="border"></param>
 private static void ApplyTableBorder(CssBox table, string border)
 {
     SetForAllCells(table, cell =>
     {
         cell.BorderLeftStyle = cell.BorderTopStyle = cell.BorderRightStyle = cell.BorderBottomStyle = CssConstants.Solid;
         cell.BorderLeftWidth = cell.BorderTopWidth = cell.BorderRightWidth = cell.BorderBottomWidth = border;
     });
 }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:13,代码来源:DomParser.cs


示例6: CssLineBox

 /// <summary>
 /// Creates a new LineBox
 /// </summary>
 public CssLineBox(CssBox ownerBox)
 {
     _rects = new Dictionary<CssBox, RectangleF>();
     _relatedBoxes = new List<CssBox>();
     _words = new List<CssBoxWord>();
     _ownerBox = ownerBox;
     _ownerBox.LineBoxes.Add(this);
 }
开发者ID:Alister742,项目名称:ParseKit,代码行数:11,代码来源:CssLineBox.cs


示例7: CssSpacingBox

        public CssSpacingBox(CssBox tableBox, ref CssBox extendedBox, int startRow)
            : base(tableBox, new HtmlTag("none",new Dictionary<string, string>{{"colspan","1"}} ))
        {
            _extendedBox = extendedBox;
            Display = CssConstants.None;

            _startRow = startRow;
            _endRow = startRow + Int32.Parse(extendedBox.GetAttribute("rowspan", "1")) - 1;
        }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:9,代码来源:CssSpacingBox.cs


示例8: GenerateHtml

 /// <summary>
 /// Generate html from the given dom tree.<br/>
 /// Generate all the tyle inside the html.
 /// </summary>
 /// <param name="root">the box of the html generate html from</param>
 /// <param name="styleGen">Optional: controls the way styles are generated when html is generated</param>
 /// <param name="onlySelected">Optional: true - generate only selected html subset, false - generate all (default - false)</param>
 /// <returns>generated html</returns>
 public static string GenerateHtml(CssBox root, HtmlGenerationStyle styleGen = HtmlGenerationStyle.Inline, bool onlySelected = false)
 {
     var sb = new StringBuilder();
     if (root != null)
     {
         WriteHtml(sb, root, 0, styleGen, onlySelected ? CollectSelectedHtmlTags(root) : null);
     }
     return sb.ToString();
 }
开发者ID:Alister742,项目名称:ParseKit,代码行数:17,代码来源:DomUtils.cs


示例9: CssBox

 /// <summary>
 /// Init.
 /// </summary>
 /// <param name="parentBox">optional: the parent of this css box in html</param>
 /// <param name="tag">optional: the html tag associated with this css box</param>
 internal CssBox(CssBox parentBox = null, HtmlTag tag = null)
 {
     if(parentBox != null)
     {
         _parentBox = parentBox;
         _parentBox.Boxes.Add(this);
     }
     _htmltag = tag;
 }
开发者ID:Alister742,项目名称:ParseKit,代码行数:14,代码来源:CssBox.cs


示例10: AssignCssBlocks

 /// <summary>
 /// Asigns the given css style blocks to the given css box checking if matching.
 /// </summary>
 /// <param name="box">the css box to assign css to</param>
 /// <param name="cssData">the css data to use to get the matching css blocks</param>
 /// <param name="className">the class selector to search for css blocks</param>
 private static void AssignCssBlocks(CssBox box, CssData cssData, string className)
 {
     var blocks = cssData.GetCssBlock(className);
     foreach (var block in blocks)
     {
         if (IsBlockAssignableToBox(box, block))
         {
             AssignCssBlock(box, block);
         }
     }
 }
开发者ID:Alister742,项目名称:ParseKit,代码行数:17,代码来源:DomParser.cs


示例11: ContainsInlinesOnly

        /// <summary>
        /// Check if the given box contains only inline child boxes.
        /// </summary>
        /// <param name="box">the box to check</param>
        /// <returns>true - only inline child boxes, false - otherwise</returns>
        public static bool ContainsInlinesOnly(CssBox box)
        {
            foreach (CssBox b in box.Boxes)
            {
                if (b.Display != CssConstants.Inline)
                {
                    return false;
                }
            }

            return true;
        }
开发者ID:Alister742,项目名称:ParseKit,代码行数:17,代码来源:DomUtils.cs


示例12: ContainsInlinesOnly

        /// <summary>
        /// Check if the given box contains only inline child boxes.
        /// </summary>
        /// <param name="box">the box to check</param>
        /// <returns>true - only inline child boxes, false - otherwise</returns>
        public static bool ContainsInlinesOnly(CssBox box)
        {
            foreach (CssBox b in box.Boxes)
            {
                if (!b.IsInline)
                {
                    return false;
                }
            }

            return true;
        }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:17,代码来源:DomUtils.cs


示例13: CssTable

        public CssTable(CssBox tableBox, Graphics g)
            : this()
        {
            if (!(tableBox.Display == CssConstants.Table || tableBox.Display == CssConstants.InlineTable))
                throw new ArgumentException("Box is not a table", "tableBox");

            _tableBox = tableBox;

            MeasureWords(tableBox, g);

            Analyze(g);
        }
开发者ID:Alister742,项目名称:ParseKit,代码行数:12,代码来源:CssTable.cs


示例14: AssignCssBlock

 /// <summary>
 /// Asigns the given css style block properties to the given css box.
 /// </summary>
 /// <param name="box">the css box to assign css to</param>
 /// <param name="block">the css block to assign</param>
 private static void AssignCssBlock(CssBox box, CssBlock block)
 {
     foreach (var prop in block.Properties)
     {
         var value = prop.Value;
         if (prop.Value == CssConstants.Inherit && box.ParentBox != null)
         {
             value = CssUtils.GetPropertyValue(box.ParentBox, prop.Key);
         }
         CssUtils.SetPropertyValue(box, prop.Key, value);
     }
 }
开发者ID:Alister742,项目名称:ParseKit,代码行数:17,代码来源:DomParser.cs


示例15: FindParent

 /// <summary>
 /// Recursively searches for the parent with the specified HTML Tag name
 /// </summary>
 /// <param name="root"></param>
 /// <param name="tagName"></param>
 /// <param name="box"></param>
 public static CssBox FindParent(CssBox root, string tagName, CssBox box)
 {
     if (box == null)
     {
         return root;
     }
     else if (box.HtmlTag != null && box.HtmlTag.Name.Equals(tagName, StringComparison.CurrentCultureIgnoreCase))
     {
         return box.ParentBox ?? root;
     }
     else
     {
         return FindParent(root, tagName, box.ParentBox);
     }
 }
开发者ID:Alister742,项目名称:ParseKit,代码行数:21,代码来源:DomUtils.cs


示例16: ApplyCellVerticalAlignment

        /// <summary>
        /// Applies special vertical alignment for table-cells
        /// </summary>
        /// <param name="g"></param>
        /// <param name="cell"></param>
        public static void ApplyCellVerticalAlignment(IGraphics g, CssBox cell)
        {
            ArgChecker.AssertArgNotNull(g, "g");
            ArgChecker.AssertArgNotNull(cell, "cell");

            if (cell.VerticalAlign == CssConstants.Top || cell.VerticalAlign == CssConstants.Baseline) return;

            float cellbot = cell.ClientBottom;
            float bottom = cell.GetMaximumBottom(cell, 0f);
            float dist = 0f;

            if (cell.VerticalAlign == CssConstants.Bottom)
            {
                dist = cellbot - bottom;
            }
            else if (cell.VerticalAlign == CssConstants.Middle)
            {
                dist = (cellbot - bottom) / 2;
            }

            foreach (CssBox b in cell.Boxes)
            {
                b.OffsetTop(dist);
            }

            //float top = cell.ClientTop;
            //float bottom = cell.ClientBottom;
            //bool middle = cell.VerticalAlign == CssConstants.Middle;

            //foreach (LineBox line in cell.LineBoxes)
            //{
            //    for (int i = 0; i < line.RelatedBoxes.Count; i++)
            //    {

            //        float diff = bottom - line.RelatedBoxes[i].Rectangles[line].Bottom;
            //        if (middle) diff /= 2f;
            //        RectangleF r = line.RelatedBoxes[i].Rectangles[line];
            //        line.RelatedBoxes[i].Rectangles[line] = new RectangleF(r.X, r.Y + diff, r.Width, r.Height);

            //    }

            //    foreach (BoxWord word in line.Words)
            //    {
            //        float gap = word.Top - top;
            //        word.Top = bottom - gap - word.Height;
            //    }
            //}
        }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:53,代码来源:CssLayoutEngine.cs


示例17: DrawBackgroundImage

        /// <summary>
        /// Draw the background image of the given box in the given rectangle.<br/>
        /// Handle background-repeat and background-position values.
        /// </summary>
        /// <param name="g">the device to draw into</param>
        /// <param name="box">the box to draw its background image</param>
        /// <param name="imageLoadHandler">the handler that loads image to draw</param>
        /// <param name="rectangle">the rectangle to draw image in</param>
        public static void DrawBackgroundImage(IGraphics g, CssBox box, ImageLoadHandler imageLoadHandler, RectangleF rectangle)
        {
            // image size depends if specific rectangle given in image loader
            var imgSize = new Size(imageLoadHandler.Rectangle == Rectangle.Empty ? imageLoadHandler.Image.Width : imageLoadHandler.Rectangle.Width,
                                   imageLoadHandler.Rectangle == Rectangle.Empty ? imageLoadHandler.Image.Height : imageLoadHandler.Rectangle.Height);

            // get the location by BackgroundPosition value
            var location = GetLocation(box.BackgroundPosition, rectangle, imgSize);

            var srcRect = imageLoadHandler.Rectangle == Rectangle.Empty
                              ? new Rectangle(0, 0, imgSize.Width, imgSize.Height)
                              : new Rectangle(imageLoadHandler.Rectangle.Left, imageLoadHandler.Rectangle.Top, imgSize.Width, imgSize.Height);

            // initial image destination rectangle
            var destRect = new Rectangle(location, imgSize);

            // need to clip so repeated image will be cut on rectangle
            var prevClip = g.GetClip();
            var lRectangle = rectangle;
            lRectangle.Intersect(prevClip);
            g.SetClip(lRectangle);

            switch( box.BackgroundRepeat )
            {
                case "no-repeat":
                    g.DrawImage(imageLoadHandler.Image, destRect, srcRect);
                    break;
                case "repeat-x":
                    DrawRepeatX(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
                    break;
                case "repeat-y":
                    DrawRepeatY(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
                    break;
                default:
                    DrawRepeat(g, imageLoadHandler, rectangle, srcRect, destRect, imgSize);
                    break;
            }

            g.SetClip(prevClip);
        }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:48,代码来源:BackgroundImageDrawHandler.cs


示例18: DrawBoxBorders

 /// <summary>
 /// Draws all the border of the box with respect to style, width, etc.
 /// </summary>
 /// <param name="g">the device to draw into</param>
 /// <param name="box">the box to draw borders for</param>
 /// <param name="rect">the bounding rectangle to draw in</param>
 /// <param name="isFirst">is it the first rectangle of the element</param>
 /// <param name="isLast">is it the last rectangle of the element</param>
 public static void DrawBoxBorders(IGraphics g, CssBox box, RectangleF rect, bool isFirst, bool isLast)
 {
     if( rect.Width > 0 && rect.Height > 0 )
     {
         if (!(string.IsNullOrEmpty(box.BorderTopStyle) || box.BorderTopStyle == CssConstants.None || box.BorderTopStyle == CssConstants.Hidden) && box.ActualBorderTopWidth > 0)
         {
             DrawBorder(Border.Top, box, g, rect, isFirst, isLast);
         }
         if (isFirst && !(string.IsNullOrEmpty(box.BorderLeftStyle) || box.BorderLeftStyle == CssConstants.None || box.BorderLeftStyle == CssConstants.Hidden) && box.ActualBorderLeftWidth > 0)
         {
             DrawBorder(Border.Left, box, g, rect, true, isLast);
         }
         if (!(string.IsNullOrEmpty(box.BorderBottomStyle) || box.BorderBottomStyle == CssConstants.None || box.BorderBottomStyle == CssConstants.Hidden) && box.ActualBorderBottomWidth > 0)
         {
             DrawBorder(Border.Bottom, box, g, rect, isFirst, isLast);
         }
         if (isLast && !(string.IsNullOrEmpty(box.BorderRightStyle) || box.BorderRightStyle == CssConstants.None || box.BorderRightStyle == CssConstants.Hidden) && box.ActualBorderRightWidth > 0)
         {
             DrawBorder(Border.Right, box, g, rect, isFirst, true);
         }
     }
 }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:30,代码来源:BordersDrawHandler.cs


示例19: CssRect

 /// <summary>
 /// Init.
 /// </summary>
 /// <param name="owner">the CSS box owner of the word</param>
 protected CssRect(CssBox owner)
 {
     _ownerBox = owner;
 }
开发者ID:havlenapetr,项目名称:HTMLRenderer,代码行数:8,代码来源:CssRect.cs


示例20: IsBlockAssignableToBox

        /// <summary>
        /// Check if the given css block is assignable to the given css box.<br/>
        /// the block is assignable if it has no hierarchial selectors or if the hierarchy matches.<br/>
        /// </summary>
        /// <param name="box">the box to check assign to</param>
        /// <param name="block">the block to check assign of</param>
        /// <returns>true - the block is assignable to the box, false - otherwise</returns>
        private static bool IsBlockAssignableToBox(CssBox box, CssBlock block)
        {
            if (block.Selectors != null)
            {
                foreach (var selector in block.Selectors)
                {
                    bool matched = false;
                    while (!matched)
                    {
                        box = box.ParentBox;
                        while (box != null && box.HtmlTag == null)
                            box = box.ParentBox;

                        if (box == null)
                            return false;

                        if (box.HtmlTag.Name == selector.Class)
                            matched = true;

                        if (!matched && box.HtmlTag.HasAttribute("class"))
                        {
                            var className = box.HtmlTag.Attributes["class"];
                            if (selector.Class == "." + className || selector.Class == box.HtmlTag.Name + "." + className)
                                matched = true;
                        }

                        if (!matched && box.HtmlTag.HasAttribute("id"))
                        {
                            var id = box.HtmlTag.Attributes["id"];
                            if (selector.Class == "#" + id)
                                matched = true;
                        }

                        if (!matched && selector.DirectParent)
                            return false;
                    }
                }
            }

            return true;
        }
开发者ID:Alister742,项目名称:ParseKit,代码行数:48,代码来源:DomParser.cs



注:本文中的HtmlRenderer.Dom.CssBox类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# HtmlTags.HtmlTag类代码示例发布时间:2022-05-26
下一篇:
C# HtmlAgilityPack.HtmlWeb类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap