/// <summary> /// Draw a simple outer border. Ignore any inner parts. /// </summary> private void RenderBorder(Demon.Report.Types.Rectangle rect, Border style, Page page) { if (style == null) { return; } BorderPart parts = style.Parts; Demon.PDF.Color color = Convert.Color(style.Color); if ((parts & BorderPart.Left) != 0) { List <Position> path = new List <Position>(); path.Add(new Position(rect.Left, rect.Top)); path.Add(new Position(rect.Left, rect.Bottom)); page.AddPath(path, style.Thickness, color, null); } if ((parts & BorderPart.Bottom) != 0) { List <Position> path = new List <Position>(); path.Add(new Position(rect.Left, rect.Bottom)); path.Add(new Position(rect.Right, rect.Bottom)); page.AddPath(path, style.Thickness, color, null); } if ((parts & BorderPart.Right) != 0) { List <Position> path = new List <Position>(); path.Add(new Position(rect.Right, rect.Top)); path.Add(new Position(rect.Right, rect.Bottom)); page.AddPath(path, style.Thickness, color, null); } if ((parts & BorderPart.Top) != 0) { List <Position> path = new List <Position>(); path.Add(new Position(rect.Left, rect.Top)); path.Add(new Position(rect.Right, rect.Top)); page.AddPath(path, style.Thickness, color, null); } }
/// <inheritdoc/> protected override string GetBoxPart(BorderPart part) { return(part switch { BorderPart.HeaderTopLeft => " ", BorderPart.HeaderTop => " ", BorderPart.HeaderTopSeparator => " ", BorderPart.HeaderTopRight => " ", BorderPart.HeaderLeft => " ", BorderPart.HeaderSeparator => "│", BorderPart.HeaderRight => " ", BorderPart.HeaderBottomLeft => " ", BorderPart.HeaderBottom => "═", BorderPart.HeaderBottomSeparator => "╪", BorderPart.HeaderBottomRight => " ", BorderPart.CellLeft => " ", BorderPart.CellSeparator => "│", BorderPart.CellRight => " ", BorderPart.FooterBottomLeft => " ", BorderPart.FooterBottom => " ", BorderPart.FooterBottomSeparator => " ", BorderPart.FooterBottomRight => " ", _ => throw new InvalidOperationException("Unknown box part."), });
/// <summary> /// Gets the character representing the specified border part. /// </summary> /// <param name="part">The part to get the character representation for.</param> /// <returns>A character representation of the specified border part.</returns> protected abstract string GetBoxPart(BorderPart part);
/// <summary> /// Gets the string representation of a specific border part. /// </summary> /// <param name="part">The part to get a string representation for.</param> /// <returns>A string representation of the specified border part.</returns> public string GetPart(BorderPart part) { return(_lookup[part].ToString(CultureInfo.InvariantCulture)); }
/// <summary> /// Gets the string representation of a specific border part. /// </summary> /// <param name="part">The part to get a string representation for.</param> /// <param name="count">The number of repetitions.</param> /// <returns>A string representation of the specified border part.</returns> public string GetPart(BorderPart part, int count) { // TODO: This need some optimization... return(string.Join(string.Empty, Enumerable.Repeat(GetBoxPart(part)[0], count))); }
/// <inheritdoc/> protected override string GetBoxPart(BorderPart part) { return(" "); }