public SelectedState GetSelectedState(CellRange rng)
 {
     CellRange selection = _grid.Selection;
     if (rng.Contains(selection.Row, selection.Column))
     {
         return SelectedState.Cursor;
     }
     if (_grid.Rows.IsSelected(rng.Row) || _grid.Columns.IsSelected(rng.Column))
     {
         return SelectedState.Selected;
     }
     selection = AdjustSelection(selection, true);
     if (rng.Row < 0 && selection.ContainsColumn(rng.Column) || rng.Column < 0 && selection.ContainsRow(rng.Row))
     {
         return SelectedState.Selected;
     }
     if (_grid.SelectionMode == SelectionMode.ListBox)
     {
         return SelectedState.None;
     }
     if (!rng.Intersects(selection))
     {
         return SelectedState.None;
     }
     return SelectedState.Selected;
 }
 private CellRangeDictionary GetRangeDelta(CellRange r1, CellRange r2)
 {
     _invCells.Clear();
     _invCells[new CellRange(r1.Row, r1.Column)] = null;
     _invCells[new CellRange(r2.Row, r2.Column)] = null;
     r1 = AdjustSelection(r1, true);
     r2 = AdjustSelection(r2, true);
     foreach (CellRange cell in r1.Cells)
     {
         if (r2.Contains(cell))
         {
             continue;
         }
         _invCells[cell] = null;
     }
     foreach (CellRange cellRange in r2.Cells)
     {
         if (r1.Contains(cellRange))
         {
             continue;
         }
         _invCells[cellRange] = null;
     }
     return _invCells;
 }