Ejemplo n.º 1
0
        public void EditorSelectionChanged(TableSelection tableSelection)
        {
            // list of currently selected cells (default to none)
            ArrayList selectedCells = new ArrayList();

            if (tableSelection != null && tableSelection.HasContiguousSelection)
            {
                selectedCells = tableSelection.SelectedCells;
            }

            // build hashtables of element behaviors for our selected and unselected cells
            Hashtable selectedCellBehaviors = new Hashtable();

            foreach (IHTMLElement cellElement in selectedCells)
            {
                TableCellEditingElementBehavior cellBehavior = _tableEditingContext.GetCellBehavior(cellElement);
                if (cellBehavior != null)
                {
                    selectedCellBehaviors[cellElement.sourceIndex] = cellBehavior;
                }
            }
            Hashtable lastSelectedCellBehaviors = new Hashtable();

            foreach (IHTMLElement cellElement in _lastSelectedCells)
            {
                TableCellEditingElementBehavior cellBehavior = _tableEditingContext.GetCellBehavior(cellElement);
                if (cellBehavior != null)
                {
                    lastSelectedCellBehaviors[cellElement.sourceIndex] = cellBehavior;
                }
            }

            // unselect cells that should no longer be selected
            foreach (DictionaryEntry entry in lastSelectedCellBehaviors)
            {
                if (!selectedCellBehaviors.ContainsKey(entry.Key))
                {
                    (entry.Value as TableCellEditingElementBehavior).DrawSelectionBorder = false;
                }
            }

            // select cells that are joining the selection
            foreach (DictionaryEntry entry in selectedCellBehaviors)
            {
                if (!lastSelectedCellBehaviors.ContainsKey(entry.Key))
                {
                    (entry.Value as TableCellEditingElementBehavior).DrawSelectionBorder = true;
                }
            }

            // update the last selected cells
            _lastSelectedCells = selectedCells;
        }
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();
            }
        }
 public void RemoveCellBehavior(TableCellEditingElementBehavior cellBehavior)
 {
     _cellElementBehaviors.Remove(cellBehavior);
 }
 public void AddCellBehavior(TableCellEditingElementBehavior cellBehavior)
 {
     _cellElementBehaviors.Add(cellBehavior);
 }
Ejemplo n.º 5
0
 public void RemoveCellBehavior(TableCellEditingElementBehavior cellBehavior)
 {
     _cellElementBehaviors.Remove(cellBehavior);
 }
Ejemplo n.º 6
0
 public void AddCellBehavior(TableCellEditingElementBehavior cellBehavior)
 {
     _cellElementBehaviors.Add(cellBehavior);
 }