internal TableStyle(TableBordersStyle borderStyle, TableVisibleBorders shownBorders, bool escapeXml, int leftMargin, string prompt) { BorderStyle = borderStyle; _shownBorders = shownBorders; _escapeXml = escapeXml; _prompt = prompt ?? (leftMargin > 0 ? Filler.GetFiller(leftMargin) : string.Empty); }
private string AlignCenter(string txt, int width) { var diff = width - GetWidth(txt); var diffLeft = diff / 2; var diffRight = diff - diffLeft; return(Filler.GetFiller(diffLeft) + txt + Filler.GetFiller(diffRight)); }
private string RenderHorizontalSeparator(IList <Column> columns, string left, string cross, string right, string horizontal, Row upperRow, Row lowerRow, string upperColSpan, string lowerColSpan, int centerWidth) { var sb = new StringBuilder(); // Upper Left Corner if (IsLeftBorderVisible) { sb.Append(left); } // Cells var totalColumns = columns.Count; for (var j = 0; j < totalColumns; j++) { // cell separator var upperSep = upperRow != null && upperRow.HasCellSeparatorInPosition(j); var lowerSep = lowerRow != null && lowerRow.HasCellSeparatorInPosition(j); if (j != 0) { if ((j > 1 && j < totalColumns - 1) && IsCenterSeparatorVisible || ((j == 1) && (IsLeftSeparatorVisible)) || ((j == (totalColumns - 1)) && (IsRightSeparatorVisible))) { if (upperSep) { sb.Append(lowerSep ? cross : upperColSpan); } else { if (lowerSep) { sb.Append(lowerColSpan); } else { for (var i = 0; i < centerWidth; i++) { sb.Append(horizontal); } } } } } // Cell content var col = columns[j]; sb.Append(Filler.GetFiller(horizontal, col.Width)); } // Right border if (IsRightBorderVisible) { sb.Append(right); } return(sb.ToString()); }
private static string Adjuststring(string txt, int width) { if (txt == null) { return(Filler.GetFiller(width)); } if (txt.Length == width) { return(txt); } if (txt.Length > width) { return(txt.Substring(0, width)); } var diff = width - txt.Length; return(txt + Filler.GetFiller(diff)); }
internal static string RenderNullCell(int width) { return(Filler.GetFiller(width)); }
private string AlignRight(string txt, int width) { var diff = width - GetWidth(txt); return(Filler.GetFiller(diff) + txt); }
private string AlignLeft(string txt, int width) { var diff = width - GetWidth(txt); return(txt + Filler.GetFiller(diff)); }