예제 #1
0
        public void GetHTMLTable(ref HtmlTable tab, bool merge)
        {
            SetUpSpans();

            for (int r = 0; r < _cells.RowCount; ++r)
            {
                HtmlTableRow row = null;
                if (merge == false || (tab.Rows.Count - 1 < r))
                {
                    row = new HtmlTableRow();
                    tab.Rows.Add(row);
                }
                else
                {
                    row = tab.Rows[r];
                }
                row.Cells.Clear();
                for (int c = 0; c < _cells.ColCount; ++c)
                {
                    CellAdressableCell cell = _cells[r, c];
                    if ((cell.SkippedCell) == false)
                    {
                        if (cell.Cell.InnerHtml == "")
                        {
                            cell.Cell.InnerHtml = "&nbsp;";
                        }
                        row.Cells.Add(cell.Cell);
                    }
                }
            }
        }
예제 #2
0
 internal void SetUpSpans()
 {
     // set up skipped by row or columnspan
     for (int r = 0; r < _cells.RowCount; ++r)
     {
         int c = 0;
         while (c < _cells.ColCount)
         {
             CellAdressableCell cell = _cells[r, c];
             int colSpan             = 1;
             if (cell.Cell.ColSpan > 1)
             {
                 colSpan = cell.Cell.ColSpan;
             }
             for (int c2 = 1; c2 <= colSpan; ++c2)
             {
                 if (c2 > 1)
                 {
                     CellAdressableCell cell2 = _cells[r, c + c2 - 1];
                     if (cell2.Cell.ColSpan > 1)
                     {
                         if (cell2.Cell.ColSpan + c2 - 1 > colSpan)
                         {
                             colSpan           = cell2.Cell.ColSpan + c2 - 1;
                             cell.Cell.ColSpan = colSpan;
                         }
                     }
                     cell2.Cell.ColSpan     = 0;
                     cell2.SkippedByColspan = true;
                 }
                 int rowSpan = 1;
                 if (cell.Cell.RowSpan > 1)
                 {
                     rowSpan = cell.Cell.RowSpan;
                 }
                 for (int r2 = 1; r2 <= rowSpan; ++r2)
                 {
                     if (r2 > 1)
                     {
                         CellAdressableCell cell2 = _cells[r + r2 - 1, c + c2 - 1];
                         if (cell2.Cell.RowSpan > 1)
                         {
                             if (cell2.Cell.RowSpan + r2 - 1 > rowSpan)
                             {
                                 rowSpan           = cell2.Cell.RowSpan + r2 - 1;
                                 cell.Cell.RowSpan = rowSpan;
                             }
                         }
                         cell2.Cell.RowSpan     = 0;
                         cell2.SkippedByRowspan = true;
                     }
                 }
             }
             c = c + colSpan;
         }
     }
 }
예제 #3
0
 internal CellCoordinate FindCell(CellAdressableCell cell)
 {
     foreach (int r in _cells.Keys)
     {
         foreach (int c in _cells[r].Keys)
         {
             if (cell == _cells[r][c])
             {
                 return(new CellCoordinate(r, c));
             }
         }
     }
     return(new CellCoordinate(-1, -1));
 }
예제 #4
0
        internal CellAdressableCell this[int row, int column]
        {
            get
            {
                if (_cells.ContainsKey(row))
                {
                    if (_cells[row].ContainsKey(column))
                    {
                        return(_cells[row][column]);
                    }
                }
                if (column >= ColCount)
                {
                    ColCount = column + 1;
                }
                if (row >= RowCount)
                {
                    RowCount = row + 1;
                }
                this[row, column] = new CellAdressableCell(parentTable);
                return(this[row, column]);
            }
            set
            {
                if (!_cells.ContainsKey(row))
                {
                    _cells.Add(row, new Dictionary <int, CellAdressableCell>());
                }

                if (!_cells[row].ContainsKey(column))
                {
                    _cells[row].Add(column, value);
                }
                else
                {
                    _cells[row][column] = value;
                }
                if (column >= ColCount)
                {
                    ColCount = column + 1;
                }
                if (row >= RowCount)
                {
                    RowCount = row + 1;
                }
            }
        }
예제 #5
0
        public void LoadTable(HtmlTable table)
        {
            int currRow = 0;

            foreach (HtmlTableRow r in table.Rows)
            {
                int currCol = 0;
                foreach (HtmlTableCell c in r.Cells)
                {
                    while (this[currRow, currCol].SkippedCell)
                    {
                        currCol++;
                    }
                    this[currRow, currCol] = new CellAdressableCell(this, c);
                    currCol += c.ColSpan > 0 ? c.ColSpan : 1;
                }
                this.SetUpSpans();
                ++currRow;
            }
        }
예제 #6
0
        internal void InsertColumnAt(int newColNumber)
        {
            parentTable.SetUpSpans();
            foreach (int rowNo in _cells.Keys)
            {
                int maxCol = -1;
                foreach (int i in _cells[rowNo].Keys)
                {
                    if (i > maxCol)
                    {
                        maxCol = i;
                    }
                }
                for (int i = maxCol; i > -1 && i >= newColNumber; --i)
                {
                    if (_cells[rowNo].ContainsKey(i))
                    {
                        CellAdressableCell movedCell = _cells[rowNo][i];
                        _cells[rowNo].Remove(i);
                        this[rowNo, i + 1] = movedCell;
                    }
                }
            }

            if (newColNumber < this.ColCount - 1)
            {
                Column oldCol = parentTable.Columns[newColNumber + 1];
                Column newCol = parentTable.Columns[newColNumber];
                for (int i = 0; i < this.RowCount - 1; ++i)
                {
                    if (oldCol[i].SkippedByColspan)
                    {
                        newCol[i].JoinCell(CellJoinDirection.LEFT);
                        //newCol[i].JoinCell(CellJoinDirection.RIGHT);
                    }
                }
            }
        }
예제 #7
0
 public CellCoordinate FindCell(CellAdressableCell cell)
 {
     return(_cells.FindCell(cell));
 }
예제 #8
0
 internal Row(CellAddressableTable parentTable, int rowNo)
 {
     parent    = parentTable;
     row       = rowNo;
     firstCell = this.parent[this.row, 0];
 }
예제 #9
0
        public CellAdressableCell JoinCell(CellJoinDirection direction)
        {
            CellCoordinate     myCoord   = parentTable.FindCell(this);
            CellAdressableCell otherCell = null;

            try
            {
                switch (direction)
                {
                case CellJoinDirection.DOWN:
                    otherCell = parentTable[myCoord.row + 1, myCoord.column];
                    if (this.Cell.RowSpan < 2)
                    {
                        this.Cell.RowSpan = 2;
                    }
                    else
                    {
                        this.Cell.RowSpan++;
                    }

                    break;

                case CellJoinDirection.LEFT:
                    otherCell = parentTable[myCoord.row, myCoord.column - 1];
                    if (otherCell.Cell.ColSpan < 2)
                    {
                        otherCell.Cell.ColSpan = 2;
                    }
                    else
                    {
                        otherCell.Cell.ColSpan++;
                    }

                    break;

                case CellJoinDirection.RIGHT:
                    otherCell = parentTable[myCoord.row, myCoord.column + 1];
                    if (this.Cell.ColSpan < 2)
                    {
                        this.Cell.ColSpan = 2;
                    }
                    else
                    {
                        this.Cell.ColSpan++;
                    }

                    break;

                case CellJoinDirection.UP:
                    otherCell = parentTable[myCoord.row - 1, myCoord.column];
                    if (otherCell.Cell.RowSpan < 2)
                    {
                        otherCell.Cell.RowSpan = 2;
                    }
                    else
                    {
                        otherCell.Cell.RowSpan++;
                    }

                    break;
                }
            }
            catch (Exception e)
            {
                throw new Exception("Cant Join Cell in that direction.", e);
            }
            return(otherCell);
        }
예제 #10
0
 public CellCoordinate FindCell (CellAdressableCell cell)
 {
     return _cells.FindCell(cell);
 }
예제 #11
0
 internal Row (CellAddressableTable parentTable, int rowNo)
 {
     parent = parentTable;
     row = rowNo;
     firstCell = this.parent[this.row, 0];
 }
예제 #12
0
 internal CellCoordinate FindCell (CellAdressableCell cell)
 {
     foreach (int r in _cells.Keys)
         foreach (int c in _cells[r].Keys)
         {
             if (cell == _cells[r][c])
             {
                 return new CellCoordinate(r, c);
             }
         }
     return new CellCoordinate(-1, -1);
 }
예제 #13
0
        internal CellAdressableCell this[int row, int column]
        {
            get
            {
                if (_cells.ContainsKey(row))
                    if (_cells[row].ContainsKey(column))
                        return _cells[row][column];
                if (column >= ColCount)
                    ColCount = column + 1;
                if (row >= RowCount)
                    RowCount = row + 1;
                this[row, column] = new CellAdressableCell(parentTable);
                return this[row, column];
            }
            set
            {
                if (!_cells.ContainsKey(row))
                    _cells.Add(row, new Dictionary<int, CellAdressableCell>());

                if (!_cells[row].ContainsKey(column))
                    _cells[row].Add(column, value);
                else
                    _cells[row][column] = value;
                if (column >= ColCount)
                    ColCount = column + 1;
                if (row >= RowCount)
                    RowCount = row + 1;
            }
        }
예제 #14
0
 public void LoadTable (HtmlTable table)
 {
     int currRow = 0;
     foreach (HtmlTableRow r in table.Rows)
     {
         int currCol = 0;
         foreach (HtmlTableCell c in r.Cells)
         {
             while (this[currRow, currCol].SkippedCell)
                 currCol++;
             this[currRow, currCol] = new CellAdressableCell(this, c);
             currCol += c.ColSpan > 0 ? c.ColSpan : 1;
         }
         this.SetUpSpans();
         ++currRow;
     }
 }