Beispiel #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();
        }
Beispiel #2
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));
        }
        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();
        }
Beispiel #4
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));
 }