Exemple #1
0
        public TableSelection(MarkupRange markupRange)
        {
            // calculate the begin and end cells
            IHTMLTableCell beginCell;
            IHTMLTableCell endCell;
            ArrayList      selectedCells;

            FindCellRange(markupRange, out selectedCells, out beginCell, out endCell);

            // see if the two cells have a single containing table
            IHTMLTable table = GetSelectedTable(beginCell, endCell, markupRange) as IHTMLTable;

            // if we have a table then calculate the rest of our states
            if (table != null)
            {
                // validate the table selection
                if (ValidateTableSelection(table, markupRange, out _entireTableSelected))
                {
                    _table = table;

                    _beginCell = beginCell;
                    _endCell   = endCell;

                    // filter selected cells to only include direct descendents of this table (no
                    // cells from nested tables)
                    _selectedCells = new ArrayList();
                    foreach (IHTMLElement cell in selectedCells)
                    {
                        if (HTMLElementHelper.ElementsAreEqual(TableHelper.GetContainingTableElement(cell) as IHTMLElement, _table as IHTMLElement))
                        {
                            _selectedCells.Add(cell);
                        }
                    }

                    _hasContiguousSelection = !HTMLElementHelper.ElementsAreEqual(_beginCell as IHTMLElement, _endCell as IHTMLElement);

                    _beginRow = GetContainingRowForCell(beginCell);
                    _endRow   = GetContainingRowForCell(endCell);

                    _beginColumn = new HTMLTableColumn(_table, beginCell);
                    _endColumn   = new HTMLTableColumn(_table, endCell);
                }
            }
        }
        public TableSelection(MarkupRange markupRange)
        {
            // calculate the begin and end cells
            IHTMLTableCell beginCell;
            IHTMLTableCell endCell;
            ArrayList selectedCells;
            FindCellRange(markupRange, out selectedCells, out beginCell, out endCell);

            // see if the two cells have a single containing table
            IHTMLTable table = GetSelectedTable(beginCell, endCell, markupRange) as IHTMLTable;

            // if we have a table then calculate the rest of our states
            if (table != null)
            {
                // validate the table selection
                if (ValidateTableSelection(table, markupRange, out _entireTableSelected))
                {
                    _table = table;

                    _beginCell = beginCell;
                    _endCell = endCell;

                    // filter selected cells to only include direct descendents of this table (no
                    // cells from nested tables)
                    _selectedCells = new ArrayList();
                    foreach (IHTMLElement cell in selectedCells)
                        if (HTMLElementHelper.ElementsAreEqual(TableHelper.GetContainingTableElement(cell) as IHTMLElement, _table as IHTMLElement))
                            _selectedCells.Add(cell);

                    _hasContiguousSelection = !HTMLElementHelper.ElementsAreEqual(_beginCell as IHTMLElement, _endCell as IHTMLElement);

                    _beginRow = GetContainingRowForCell(beginCell);
                    _endRow = GetContainingRowForCell(endCell);

                    _beginColumn = new HTMLTableColumn(_table, beginCell);
                    _endColumn = new HTMLTableColumn(_table, endCell);
                }
            }
        }
Exemple #3
0
        private void InitializeSizingContext(IHTMLTableCell targetCell)
        {
            IHTMLTableRow  row      = TableHelper.GetContainingRowElement(targetCell as IHTMLTableCell);
            IHTMLTableCell leftCell = row.cells.item(_pendingLeftColumnIndex, _pendingLeftColumnIndex) as IHTMLTableCell;

            _leftColumn = new HTMLTableColumn(_table, leftCell);

            if (_pendingRightColumnIndex != -1)
            {
                IHTMLTableCell rightCell = row.cells.item(_pendingRightColumnIndex, _pendingRightColumnIndex) as IHTMLTableCell;
                _rightColumn = new HTMLTableColumn(_table, rightCell);
            }
            else
            {
                _rightColumn = null;
            }

            // force a fixup of cell widths on the next call to ContinueSizing
            // (we do this during ContinueSizing so that table column borders don't
            // visible "jump" on MouseDown)

            _cellWidthsFixed = false;
        }
        private void InitializeSizingContext(IHTMLTableCell targetCell)
        {
            IHTMLTableRow row = TableHelper.GetContainingRowElement(targetCell as IHTMLTableCell);
            IHTMLTableCell leftCell = row.cells.item(_pendingLeftColumnIndex, _pendingLeftColumnIndex) as IHTMLTableCell;
            _leftColumn = new HTMLTableColumn(_table, leftCell);

            if (_pendingRightColumnIndex != -1)
            {
                IHTMLTableCell rightCell = row.cells.item(_pendingRightColumnIndex, _pendingRightColumnIndex) as IHTMLTableCell;
                _rightColumn = new HTMLTableColumn(_table, rightCell);
            }
            else
            {
                _rightColumn = null;
            }

            // force a fixup of cell widths on the next call to ContinueSizing
            // (we do this during ContinueSizing so that table column borders don't
            // visible "jump" on MouseDown)

            _cellWidthsFixed = false;
        }
        private void InsertAdjacentColumn(HTMLTableColumn column, bool after)
        {
            // set the specified alignment for each cell in the column
            foreach (IHTMLTableRow row in TableSelection.Table.rows)
            {
                if (row.cells.length > column.Index)
                {
                    // insert the cell
                    IHTMLTableCell newCell = InsertCell(row, after ? column.Index + 1 : column.Index);

                    // copy the attributes of the source cell for this column
                    HTMLElementHelper.CopyAttributes(column.BaseCell as IHTMLElement, newCell as IHTMLElement);
                }
            }
        }