本文整理汇总了C#中TheArtOfDev.HtmlRenderer.Core.Dom.CssBox.InheritStyle方法的典型用法代码示例。如果您正苦于以下问题:C# CssBox.InheritStyle方法的具体用法?C# CssBox.InheritStyle怎么用?C# CssBox.InheritStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TheArtOfDev.HtmlRenderer.Core.Dom.CssBox
的用法示例。
在下文中一共展示了CssBox.InheritStyle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateListItemBox
/// <summary>
/// Creates the <see cref="_listItemBox"/>
/// </summary>
/// <param name="g"></param>
private void CreateListItemBox(RGraphics g)
{
if (Display == CssConstants.ListItem && ListStyleType != CssConstants.None)
{
if (_listItemBox == null)
{
_listItemBox = new CssBox(null, null);
_listItemBox.InheritStyle(this);
_listItemBox.Display = CssConstants.Inline;
_listItemBox.HtmlContainer = HtmlContainer;
if (ListStyleType.Equals(CssConstants.Disc, StringComparison.InvariantCultureIgnoreCase))
{
_listItemBox.Text = new SubString("•");
}
else if (ListStyleType.Equals(CssConstants.Circle, StringComparison.InvariantCultureIgnoreCase))
{
_listItemBox.Text = new SubString("o");
}
else if (ListStyleType.Equals(CssConstants.Square, StringComparison.InvariantCultureIgnoreCase))
{
_listItemBox.Text = new SubString("♠");
}
else if (ListStyleType.Equals(CssConstants.Decimal, StringComparison.InvariantCultureIgnoreCase))
{
_listItemBox.Text = new SubString(GetIndexForList().ToString(CultureInfo.InvariantCulture) + ".");
}
else if (ListStyleType.Equals(CssConstants.DecimalLeadingZero, StringComparison.InvariantCultureIgnoreCase))
{
_listItemBox.Text = new SubString(GetIndexForList().ToString("00", CultureInfo.InvariantCulture) + ".");
}
else
{
_listItemBox.Text = new SubString(CommonUtils.ConvertToAlphaNumber(GetIndexForList(), ListStyleType) + ".");
}
_listItemBox.ParseToWords();
_listItemBox.PerformLayoutImp(g);
_listItemBox.Size = new RSize(_listItemBox.Words[0].Width, _listItemBox.Words[0].Height);
}
_listItemBox.Words[0].Left = Location.X - _listItemBox.Size.Width - 5;
_listItemBox.Words[0].Top = Location.Y + ActualPaddingTop; // +FontAscent;
}
}
示例2: CreateBox
/// <summary>
/// Create new css box for the given parent with the given optional html tag and insert it either
/// at the end or before the given optional box.<br/>
/// If no html tag is given the box will be anonymous.<br/>
/// If no before box is given the new box will be added at the end of parent boxes collection.<br/>
/// If before box doesn't exists in parent box exception is thrown.<br/>
/// </summary>
/// <remarks>
/// To learn more about anonymous inline boxes visit: http://www.w3.org/TR/CSS21/visuren.html#anonymous
/// </remarks>
/// <param name="parent">the box to add the new box to it as child</param>
/// <param name="tag">optional: the html tag to define the box</param>
/// <param name="before">optional: to insert as specific location in parent box</param>
/// <returns>the new box</returns>
public static CssBox CreateBox(CssBox parent, HtmlTag tag = null, CssBox before = null)
{
ArgChecker.AssertArgNotNull(parent, "parent");
var newBox = new CssBox(parent, tag);
newBox.InheritStyle();
if (before != null)
{
newBox.SetBeforeBox(before);
}
return newBox;
}
示例3: CascadeApplyStyles
/// <summary>
/// Applies style to all boxes in the tree.<br/>
/// If the html tag has style defined for each apply that style to the css box of the tag.<br/>
/// If the html tag has "class" attribute and the class name has style defined apply that style on the tag css box.<br/>
/// If the html tag has "style" attribute parse it and apply the parsed style on the tag css box.<br/>
/// </summary>
/// <param name="box">the box to apply the style to</param>
/// <param name="cssData">the style data for the html</param>
private void CascadeApplyStyles(CssBox box, CssData cssData)
{
box.InheritStyle();
if (box.HtmlTag != null)
{
// try assign style using all wildcard
AssignCssBlocks(box, cssData, "*");
// try assign style using the html element tag
AssignCssBlocks(box, cssData, box.HtmlTag.Name);
// try assign style using the "class" attribute of the html element
if (box.HtmlTag.HasAttribute("class"))
{
AssignClassCssBlocks(box, cssData);
}
// try assign style using the "id" attribute of the html element
if (box.HtmlTag.HasAttribute("id"))
{
var id = box.HtmlTag.TryGetAttribute("id");
AssignCssBlocks(box, cssData, "#" + id);
}
TranslateAttributes(box.HtmlTag, box);
// Check for the style="" attribute
if (box.HtmlTag.HasAttribute("style"))
{
var block = _cssParser.ParseCssBlock(box.HtmlTag.Name, box.HtmlTag.TryGetAttribute("style"));
if (block != null)
AssignCssBlock(box, block);
}
}
// cascade text decoration only to boxes that actually have text so it will be handled correctly.
if (box.TextDecoration != String.Empty && box.Text == null)
{
foreach (var childBox in box.Boxes)
childBox.TextDecoration = box.TextDecoration;
box.TextDecoration = string.Empty;
}
foreach (var childBox in box.Boxes)
{
CascadeApplyStyles(childBox, cssData);
}
}