/// <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; }
/// <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; } }