本文整理汇总了C#中HtmlRenderer.Dom.CssBox类的典型用法代码示例。如果您正苦于以下问题:C# CssBox类的具体用法?C# CssBox怎么用?C# CssBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CssBox类属于HtmlRenderer.Dom命名空间,在下文中一共展示了CssBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
}
}
示例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();
}
}
示例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;
}
示例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;
});
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
}