コード例 #1
0
 /// <summary>
 /// Gets the white space width of the specified box
 /// </summary>
 /// <param name="g"></param>
 /// <param name="box"></param>
 /// <returns></returns>
 public static double WhiteSpace(RGraphics g, CssBoxProperties box)
 {
     double w = box.ActualFont.GetWhitespaceWidth(g);
     if (!(String.IsNullOrEmpty(box.WordSpacing) || box.WordSpacing == CssConstants.Normal))
     {
         w += CssValueParser.ParseLength(box.WordSpacing, 0, box, true);
     }
     return w;
 }
コード例 #2
0
ファイル: CssBox.cs プロジェクト: verdesgrobert/HTML-Renderer
        /// <summary>
        /// Gets the result of collapsing the vertical margins of the two boxes
        /// </summary>
        /// <param name="prevSibling">the previous box under the same parent</param>
        /// <returns>Resulting top margin</returns>
        protected double MarginTopCollapse(CssBoxProperties prevSibling)
        {
            double value;
            if (prevSibling != null)
            {
                value = Math.Max(prevSibling.ActualMarginBottom, ActualMarginTop);
                CollapsedMarginTop = value;
            }
            else if (_parentBox != null && ActualPaddingTop < 0.1 && ActualPaddingBottom < 0.1 && _parentBox.ActualPaddingTop < 0.1 && _parentBox.ActualPaddingBottom < 0.1)
            {
                value = Math.Max(0, ActualMarginTop - Math.Max(_parentBox.ActualMarginTop, _parentBox.CollapsedMarginTop));
            }
            else
            {
                value = ActualMarginTop;
            }

            // fix for hr tag
            if (value < 0.1 && HtmlTag != null && HtmlTag.Name == "hr")
            {
                value = GetEmHeight() * 1.1f;
            }

            return value;
        }
コード例 #3
0
 /// <summary>
 /// Get the border style for the given box border.
 /// </summary>
 private static string GetStyle(Border border, CssBoxProperties box)
 {
     switch (border)
     {
         case Border.Top:
             return box.BorderTopStyle;
         case Border.Right:
             return box.BorderRightStyle;
         case Border.Bottom:
             return box.BorderBottomStyle;
         case Border.Left:
             return box.BorderLeftStyle;
         default:
             throw new ArgumentOutOfRangeException("border");
     }
 }
コード例 #4
0
 /// <summary>
 /// Get the border width for the given box border.
 /// </summary>
 private static double GetWidth(Border border, CssBoxProperties box)
 {
     switch (border)
     {
         case Border.Top:
             return box.ActualBorderTopWidth;
         case Border.Right:
             return box.ActualBorderRightWidth;
         case Border.Bottom:
             return box.ActualBorderBottomWidth;
         case Border.Left:
             return box.ActualBorderLeftWidth;
         default:
             throw new ArgumentOutOfRangeException("border");
     }
 }
コード例 #5
0
 /// <summary>
 /// Get the border color for the given box border.
 /// </summary>
 private static RColor GetColor(Border border, CssBoxProperties box, string style)
 {
     switch (border)
     {
         case Border.Top:
             return style == CssConstants.Inset ? Darken(box.ActualBorderTopColor) : box.ActualBorderTopColor;
         case Border.Right:
             return style == CssConstants.Outset ? Darken(box.ActualBorderRightColor) : box.ActualBorderRightColor;
         case Border.Bottom:
             return style == CssConstants.Outset ? Darken(box.ActualBorderBottomColor) : box.ActualBorderBottomColor;
         case Border.Left:
             return style == CssConstants.Inset ? Darken(box.ActualBorderLeftColor) : box.ActualBorderLeftColor;
         default:
             throw new ArgumentOutOfRangeException("border");
     }
 }