Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
 internal static string RenderNullCell(int width)
 {
     return(Filler.GetFiller(width));
 }
Ejemplo n.º 6
0
        private string AlignRight(string txt, int width)
        {
            var diff = width - GetWidth(txt);

            return(Filler.GetFiller(diff) + txt);
        }
Ejemplo n.º 7
0
        private string AlignLeft(string txt, int width)
        {
            var diff = width - GetWidth(txt);

            return(txt + Filler.GetFiller(diff));
        }