Example #1
0
        void IFormStateAware <FinderFormState> .GetState(FinderFormState formState)
        {
            formState.DataGridViewSortState = new DataGridViewSortState(_dataGridView);

            formState.FilterRows = _dataGridViewFindToolStrip.FilterRows;

            if (KeepFindTextBetweenCalls && _contextSettingsPersister == null)
            {
                // persist the find text, to the "global" (per type) form state
                formState.FindText = _dataGridViewFindToolStrip.FindText;
            }
            else if (_restoredState != null)
            {
                // write the original restored value
                formState.FindText = _restoredState.FindText;
            }

            formState.MatchCase = _dataGridViewFindToolStrip.MatchCase;

            // save the scroll position
            formState.FirstDisplayedScrollingRowIndex =
                _dataGridView.FirstDisplayedScrollingRowIndex;
            formState.FirstDisplayedScrollingColumnIndex =
                _dataGridView.FirstDisplayedScrollingColumnIndex;
        }
Example #2
0
        private static string GetRestoredFindText(
            [NotNull] FinderFormState formState,
            [CanBeNull] ContextSpecificSettings contextSpecificSettings)
        {
            if (contextSpecificSettings == null)
            {
                return(StringUtils.IsNotEmpty(formState.FindText)
                                               ? formState.FindText
                                               : null);
            }

            return(StringUtils.IsNotEmpty(contextSpecificSettings.FindText)
                                       ? contextSpecificSettings.FindText
                                       : null);
        }
Example #3
0
        private void ApplyState([CanBeNull] FinderFormState state,
                                [CanBeNull] ContextSpecificSettings contextSpecificSettings,
                                bool skipSorting = false)
        {
            if (state == null)
            {
                _dataGridViewFindToolStrip.FilterRows = true;

                if (!skipSorting)
                {
                    ApplyDefaultSortOrder();
                }

                return;
            }

            _dataGridViewFindToolStrip.FilterRows = state.FilterRows;
            _dataGridViewFindToolStrip.MatchCase  = state.MatchCase;

            if (!skipSorting)
            {
                // try to restore the saved grid sort state
                DataGridViewSortState sortState = state.DataGridViewSortState;

                if (sortState == null || !sortState.TryApplyState(_dataGridView))
                {
                    ApplyDefaultSortOrder();
                }
            }

            if (state.FirstDisplayedScrollingRowIndex > 0)
            {
                DataGridViewUtils.TrySetFirstDisplayedScrollingRow(
                    _dataGridView, state.FirstDisplayedScrollingRowIndex);
            }

            if (state.FirstDisplayedScrollingColumnIndex > 0)
            {
                DataGridViewUtils.TrySetFirstDisplayedScrollinColumn(
                    _dataGridView, state.FirstDisplayedScrollingColumnIndex);
            }

            if (KeepFindTextBetweenCalls)
            {
                _dataGridViewFindToolStrip.FindText = GetRestoredFindText(state,
                                                                          contextSpecificSettings);
            }
        }
Example #4
0
 void IFormStateAware <FinderFormState> .RestoreState(FinderFormState formState)
 {
     _restoredState = formState;
 }