protected void HandleParentCursorChanged(object sender, EventArgs e)
        {
            TreePath       path;
            TreeIter       row;
            TreeViewColumn col;

            GetCursor(out path, out col);
            if (Model.GetIter(out row, path) && col != null && CurrentButton != Mouse.RIGHT_MOUSE_BUTTON)
            {
                bool shiftDown = (CurrentKeyboardModifier & ModifierType.ShiftMask) != ModifierType.None;
                bool ctrlDown  = (CurrentKeyboardModifier & ModifierType.ControlMask) != ModifierType.None;

                mSelectionHook = (shiftDown) ? mSelectionHook : new CellLocation(row, col);
                List <CellLocation> selectedcells = new List <CellLocation>(SheetSelection.SelectedCells);
                int col1 = (selectedcells.Count > 0) ? Array.IndexOf(Columns, mSelectionHook.Col) : -1;
                if (col1 >= 0 && shiftDown)
                {
                    SheetSelection.SelectRange(mSelectionHook.Row, col1, row, Array.IndexOf(Columns, col));
                }
                else
                {
                    if (SheetSelection.IsSelected(row, col) && (ctrlDown || selectedcells.Count == 1))
                    {
                        SheetSelection.Unselect(row, col);
                    }
                    else
                    {
                        SheetSelection.Select(row, col, ctrlDown);
                    }
                }
                QueueDraw();
            }
        }
 public void Unselect(CellLocation cell, bool notify = true)
 {
     if (SelectedCells.Remove(cell) && notify)
     {
         Notify();
     }
 }
예제 #3
0
 public void Select(CellLocation cell, bool addToCurrentCellSelection, bool notify = true)
 {
     ClearSelectedRows(false);
     ClearSelectedColumns(false);
     if (!addToCurrentCellSelection)
     {
         ClearSelectedCells(false);
     }
     SelectedCells.Add(cell);
     if (notify)
     {
         Notify();
     }
 }
예제 #4
0
 public bool IsSelected(CellLocation cell)
 {
     return(SelectedCells.Contains(cell) ||
            SelectedColumns.Contains(cell.Col) ||
            SelectedRows.Contains(cell.Row));
 }