Example #1
0
        private void BuildCellCorners(TableWriter tb, CellInfo cell)
        {
            var pos  = cell.Position;
            var size = cell.CellSize;

            tb.AddConnection(pos.Height, pos.Width, BorderConnection.Up | BorderConnection.Left);
            tb.AddConnection(pos.Height, pos.Width + size.Width - 1, BorderConnection.Up | BorderConnection.Right);
            tb.AddConnection(pos.Height + size.Height - 1, pos.Width, BorderConnection.Down | BorderConnection.Left);
            tb.AddConnection(pos.Height + size.Height - 1, pos.Width + size.Width - 1, BorderConnection.Down | BorderConnection.Right);
        }
Example #2
0
        private void BuildCellContent(TableWriter tb, CellInfo cell)
        {
            var pos    = cell.Position;
            var padTop = (cell.CellSize.Height - cell.Lines.Count) / 2;

            for (var i = 0; i < cell.Lines.Count; i++)
            {
                var line    = cell.Lines[i];
                var padLeft = (cell.CellSize.Width - line.Length) / 2;
                tb.WriteAt(pos.Height + i + padTop, pos.Width + padLeft, line);
            }
        }
Example #3
0
        private void BuildCellWalls(TableWriter tb, CellInfo cell)
        {
            var pos  = cell.Position;
            var size = cell.CellSize;

            for (var i = 1; i < size.Height - 1; i++)
            {
                tb.AddConnection(i + pos.Height, pos.Width, BorderConnection.Vertical);
                tb.AddConnection(i + pos.Height, pos.Width + size.Width - 1, BorderConnection.Vertical);
            }
            for (var i = 1; i < size.Width - 1; i++)
            {
                tb.AddConnection(pos.Height, i + pos.Width, BorderConnection.Horizontal);
                tb.AddConnection(pos.Height + size.Height - 1, i + pos.Width, BorderConnection.Horizontal);
            }
        }
Example #4
0
 public void Build(TableInfo info, TableWriter writer)
 {
     foreach (var row in info.Rows)
     {
         foreach (var cell in row.Cells)
         {
             BuildCellWalls(writer, cell);
         }
     }
     foreach (var row in info.Rows)
     {
         foreach (var cell in row.Cells)
         {
             BuildCellCorners(writer, cell);
         }
     }
     foreach (var row in info.Rows)
     {
         foreach (var cell in row.Cells)
         {
             BuildCellContent(writer, cell);
         }
     }
 }