Пример #1
0
        public override void Write(TextWriter textWriter, ITextTableLayout textTableLayout)
        {
            textWriter.Write("|");
            foreach (var column in textTableLayout.Columns)
            {
                switch (column.HorizontalAlignment)
                {
                case HorizontalAlignment.Default:
                    textWriter.Write(new string('-', textTableLayout.GetColumnWidth(column)));
                    break;

                case HorizontalAlignment.Left:
                    textWriter.Write(':');
                    textWriter.Write(new string('-', textTableLayout.GetColumnWidth(column) - 1));
                    break;

                case HorizontalAlignment.Center:
                    textWriter.Write(':');
                    textWriter.Write(new string('-', textTableLayout.GetColumnWidth(column) - 2));
                    textWriter.Write(':');
                    break;

                case HorizontalAlignment.Right:
                    textWriter.Write(new string('-', textTableLayout.GetColumnWidth(column) - 1));
                    textWriter.Write(':');
                    break;
                }
                textWriter.Write("|");
            }
            textWriter.WriteLine();
        }
Пример #2
0
        public void Write(
            TextWriter textWriter,
            int rowHeight,
            int lineNumber,
            ITextTableLayout textTableLayout)
        {
            ICellLine cellLine;

            switch (_column.VerticalAlignment)
            {
            case VerticalAlignment.Top:
                cellLine = GetTopCellLine();
                break;

            case VerticalAlignment.Center:
                cellLine = GetCenterCellLine();
                break;

            case VerticalAlignment.Bottom:
                cellLine = GetBottomCellLine();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            cellLine.Write(textWriter, textTableLayout, _column);

            ICellLine GetTopCellLine()
            {
                return(lineNumber < Height
                    ? _cellLines[lineNumber]
                    : CellLine.BlankCellLine);
            }

            ICellLine GetCenterCellLine()
            {
                var indent          = (rowHeight - Height) / 2;
                var localLineNumber = lineNumber - indent;

                if (localLineNumber < 0)
                {
                    return(CellLine.BlankCellLine);
                }

                return(Height <= localLineNumber
                    ? CellLine.BlankCellLine
                    : _cellLines[localLineNumber]);
            }

            ICellLine GetBottomCellLine()
            {
                var indent          = rowHeight - Height;
                var localLineNumber = lineNumber - indent;

                return(localLineNumber < 0
                    ? CellLine.BlankCellLine
                    : _cellLines[localLineNumber]);
            }
        }
Пример #3
0
        public void Write(
            TextWriter textWriter,
            ITextTableLayout textTableLayout,
            IColumn column)
        {
            int columnWidth = textTableLayout.GetColumnWidth(column);
            int leftPadding;
            int rightPadding;

            switch (column.HorizontalAlignment)
            {
            case HorizontalAlignment.Default:
            case HorizontalAlignment.Left:
                leftPadding  = textTableLayout.Paddings.Left.Width;
                rightPadding = columnWidth - Width - leftPadding;
                break;

            case HorizontalAlignment.Center:
                leftPadding  = (columnWidth - Width) / 2;
                rightPadding = columnWidth - Width - leftPadding;
                break;

            case HorizontalAlignment.Right:
                rightPadding = textTableLayout.Paddings.Right.Width;
                leftPadding  = columnWidth - Width - rightPadding;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            textWriter.Write(new string(' ', leftPadding));
            textWriter.Write(_value);
            textWriter.Write(new string(' ', rightPadding));
        }
Пример #4
0
        public void Write(TextWriter textWriter, ITextTableLayout textTableLayout)
        {
            textTableLayout.Margins.Left.Write(textWriter);
            textTableLayout.Borders.Left.Write(textWriter);

            Columns[0].Write(textWriter, textTableLayout);

            for (var i = 1; i < Columns.Count; i++)
            {
                textTableLayout.Borders.InsideVertical.Write(textWriter);
                Columns[i].Write(textWriter, textTableLayout);
            }

            textTableLayout.Borders.Right.Write(textWriter);
            textTableLayout.Margins.Right.Write(textWriter);

            textWriter.WriteLine();
        }
Пример #5
0
        public void Write(TextWriter textWriter, ITextTableLayout textTableLayout)
        {
            for (var lineNumber = 0; lineNumber < _height; lineNumber++)
            {
                textTableLayout.Margins.Left.Write(textWriter);
                textTableLayout.Borders.Left.Write(textWriter);

                _cells[textTableLayout.Columns[0]].Write(textWriter, _height, lineNumber, textTableLayout);

                for (var i = 1; i < textTableLayout.Columns.Count; i++)
                {
                    var column = textTableLayout.Columns[i];
                    textTableLayout.Borders.InsideVertical.Write(textWriter);
                    _cells[column].Write(textWriter, _height, lineNumber, textTableLayout);
                }

                textTableLayout.Borders.Right.Write(textWriter);
                textTableLayout.Margins.Right.Write(textWriter);

                textWriter.WriteLine();
            }
        }
Пример #6
0
        public virtual void Write(TextWriter textWriter, ITextTableLayout textTableLayout)
        {
            if(!_isEnable) return;

            textTableLayout.Margins.Left.Write(textWriter);
            
            if(_leftVerticalBorder.IsEnable) textWriter.Write(_leftStyle);
            
            var items = textTableLayout
                .Columns
                .Select(column => string.Concat(Enumerable.Repeat(_lineStyle, textTableLayout.GetColumnWidth(column) / _lineStyle.GetWidth())))
                .ToList();

            textWriter.Write(_insideVerticalBorder.IsEnable
                ? string.Join(_intersectionStyle, items)
                : string.Join(string.Empty, items));

            if(_rightVerticalBorder.IsEnable) textWriter.Write(_rightStyle);

            textTableLayout.Margins.Right.Write(textWriter);

            textWriter.WriteLine();
        }
Пример #7
0
 public void Write(TextWriter textWriter, ITextTableLayout textTableLayout)
 {
     textWriter.Write(new string(' ', textTableLayout.Paddings.Left.Width));
     textWriter.Write(_name);
     textWriter.Write(new string(' ', textTableLayout.GetColumnWidth(this) - Width - textTableLayout.Paddings.Left.Width));
 }