Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
        private void HandleMouseMove(TableColumnMouseEventArgs ea)
        {
            // cell element we are over
            IHTMLElement targetCell = GetTargetCell(ea.ClientPoint);

            // if there is no element then we are done
            if (targetCell == null)
            {
                // reset state
                _sizingOperation.EndSizing();
                return;
            }

            // get the cell and row
            IHTMLTableCell cell = targetCell as IHTMLTableCell;
            IHTMLTableRow  row  = TableHelper.GetContainingRowElement(cell);

            // convert the client point to cell-local coordinates & calcualte our comparison x values
            TableCellEditingElementBehavior cellBehavior = _tableEditingContext.GetCellBehavior(targetCell);

            if (cellBehavior == null)
            {
                _sizingOperation.ClearPending();
                return;
            }

            Point cellLocalMousePt  = cellBehavior.TransformGlobalToLocal(ea.ClientPoint);
            int   cellSpacing       = TableHelper.GetAttributeAsInteger(_table.cellSpacing);
            int   cellSpacingOffset = cellSpacing / 2;
            int   compareX          = cellLocalMousePt.X;
            int   cellStartX        = 0 - cellSpacingOffset;
            int   cellEndX          = targetCell.offsetWidth + cellSpacingOffset;

            // if the mouse is near the edge of the cell then update the pending sizing action
            // (unless the mouse is near the edge of the first cell where no sizing is supported)
            if (MouseNearCellEdge(compareX, cellStartX, cellSpacing) || MouseNearCellEdge(compareX, cellEndX, cellSpacing))
            {
                if (MouseNearCellEdge(compareX, cellStartX, cellSpacing))
                {
                    if (cell.cellIndex > 0)
                    {
                        int leftIndex  = cell.cellIndex - 1;
                        int rightIndex = cell.cellIndex;
                        _sizingOperation.TrackPending(ea.ClientPoint.X, leftIndex, rightIndex);
                        ea.Handled = true;
                    }
                    else
                    {
                        _sizingOperation.ClearPending();
                    }
                }
                else if (MouseNearCellEdge(compareX, cellEndX, cellSpacing))
                {
                    int leftIndex  = cell.cellIndex;
                    int rightIndex = cell.cellIndex < (row.cells.length - 1) ? cell.cellIndex + 1 : -1;

                    _sizingOperation.TrackPending(ea.ClientPoint.X, leftIndex, rightIndex);
                    ea.Handled = true;
                }
            }
            else // mouse is not near the edge of the cell, reset pending action
            {
                _sizingOperation.ClearPending();
            }
        }