Esempio n. 1
0
            public void ToggleMode(GridCell gridCell)
            {
                VerifyGridCell(gridCell, nameof(gridCell));

                bool isKeyboardFocusWithin = gridCell.IsKeyboardFocusWithin;
                var  mode = Mode;

                Mode = mode == GridCellMode.Edit ? GridCellMode.Select : GridCellMode.Edit;
                gridCell.Refresh();
                if (isKeyboardFocusWithin && !gridCell.ContainsKeyboardFocus())
                {
                    gridCell.Focus();
                }
            }
Esempio n. 2
0
            public void Select(GridCell gridCell, bool isExtended)
            {
                if (Mode != GridCellMode.Select)
                {
                    throw new InvalidOperationException(DiagnosticMessages.GridCell_Presenter_SelectionNotAllowedInEditMode);
                }

                var bindingIndex = VerifyGridCell(gridCell, nameof(gridCell));

                SuspendInvalidateView();

                DeselectAllRows();

                if (CurrentBindingIndex == -1)
                {
                    CurrentBindingIndex = bindingIndex;
                }

                if (isExtended)
                {
                    _extendedBindingSelection += CurrentBindingIndex - bindingIndex;
                    _extendedRowSelection     += CurrentRow.Index - gridCell.GetRowPresenter().Index;
                }
                else
                {
                    ClearExtendedSelection();
                }

                if (!gridCell.IsKeyboardFocusWithin)
                {
                    _isExtendedSelectionLocked = true;
                    try
                    {
                        gridCell.Focus();
                    }
                    finally
                    {
                        _isExtendedSelectionLocked = false;
                    }
                }

                Debug.Assert(CurrentBindingIndex == bindingIndex);
                InvalidateView();
                ResumeInvalidateView();
            }