Nez.Portable/UI/Containers/Table.cs
/// <summary>
/// Adds a new cell to the table with the specified element.
/// </summary>
/// <param name="element">element.</param>
Adds a new cell to the table with the specified element.
Adds a new cell to the table with the specified element .
public Cell add(Element element)
        {
            var cell = obtainCell();
            cell.element = element;
            if (_implicitEndRow)
            {
                _implicitEndRow = false;
                _rows--;
                _cells.Last().endRow = false;
            }
            var cellCount = _cells.Count;
            if (cellCount > 0)
            {
                var lastCell = _cells.Last();
                if (!lastCell.endRow)
                {
                    cell.column = lastCell.column + lastCell.colspan.Value;
                    cell.row = lastCell.row;
                }
                else
                {
                    cell.column = 0;
                    cell.row = lastCell.row + 1;
                }
                if (cell.row > 0)
                {
                    for (var i = cellCount - 1; i >= 0; i--)
                    {
                        var other = _cells[i];
                        for (int column = other.column, nn = column + other.colspan.Value; column < nn; column++)
                        {
                            if (column == cell.column)
                            {
                                cell.cellAboveIndex = i;
                                goto outer;
                            }
                        }
                    }
                    outer:
                    {
                    }
                }
            }
            else
            {
                cell.column = 0;
                cell.row = 0;
            }
            _cells.Add(cell);
            cell.set(_cellDefaults);
            if (cell.column < _columnDefaults.Count)
            {
                var columnCell = _columnDefaults[cell.column];
                if (columnCell != null)
                    cell.merge(columnCell);
            }
            cell.merge(_rowDefaults);
            if (element != null)
                addElement(element);
            return cell;
        }
public Cell add ( Element element ) { var cell = obtainCell ( ) ; cell . element = element ; if ( _implicitEndRow ) { _implicitEndRow = false ; _rows -- ; _cells . Last ( ) . endRow = false ; } var cellCount = _cells . Count ; if ( cellCount > 0 ) { var lastCell = _cells . Last ( ) ; if ( ! lastCell . endRow ) { cell . column = lastCell . column + lastCell . colspan . Value ; cell . row = lastCell . row ; } else { cell . column = 0 ; cell . row = lastCell . row + 1 ; } if ( cell . row > 0 ) { for ( var i = cellCount - 1 ; i >= 0 ; i -- ) { var other = _cells [ i ] ; for ( int column = other . column , nn = column + other . colspan . Value ; column < nn ; column ++ ) { if ( column == cell . column ) { cell . cellAboveIndex = i ; goto outer ; } } } outer : { } } } else { cell . column = 0 ; cell . row = 0 ; } _cells . Add ( cell ) ; cell . set ( _cellDefaults ) ; if ( cell . column < _columnDefaults . Count ) { var columnCell = _columnDefaults [ cell . column ] ; if ( columnCell != null ) cell . merge ( columnCell ) ; } cell . merge ( _rowDefaults ) ; if ( element != null ) addElement ( element ) ; return cell ; }
Adds a new cell to the table with the specified element.
Adds a new cell to the table with the specified element .
// the row was ended for layout, not by the user, so revert it. // Set cell column and row. // set the index of the cell above.
element
Element
None