コード例 #1
0
        // Argument must be an object to allow it to be called via DeferredRequest
        private void OnUpdateNextAndPreviousResults(object arg)
        {
            if (SearchIsActive)
            {
                Debug.Assert(_context != null, "ExplorerFrame was disposed");
                // only recalculate Next & Previous if the user selected a different tree
                // item (if they just hit Next or Previous Search Result then this will
                // be calculated automatically)
                if (!_nextOrPreviousInProgress)
                {
                    // relativeToItem is the current selection (or the root node if no selection)
                    ExplorerEFElement relativeToItem = null;
                    var selectedItem        = _selectedExplorerEFElement;
                    var relativeToSelection = (bool)arg;
                    if (relativeToSelection)
                    {
                        relativeToItem = selectedItem;
                    }
                    if (relativeToItem == null)
                    {
                        relativeToItem = ExplorerViewModelHelper.ViewModel.RootNode;
                    }

                    var explorerSearchResults = ExplorerSearchResults.GetExplorerSearchResults(_context);
                    explorerSearchResults.RecalculateNextAndPrevious(relativeToItem);
                }

                // update whether Next and Previous buttons are enabled
                OnPropertyChanged("CanGotoNextResult");
                OnPropertyChanged("CanGotoPreviousResult");
            }
        }
コード例 #2
0
        private void ResetPreviousSearchResults(bool clearTextSearch)
        {
            Debug.Assert(_context != null, "ExplorerFrame was disposed");
            if (clearTextSearch)
            {
                SearchComboBox.Text = string.Empty;
            }

            // now reset the ExplorerSearchResults which will clear all the
            // IsInSearchResults settings in the tree
            var explorerSearchResults = ExplorerSearchResults.GetExplorerSearchResults(_context);

            explorerSearchResults.Reset();
        }
コード例 #3
0
        private void ProcessTreeViewItemsInSearchResults()
        {
            Debug.Assert(_context != null, "ExplorerFrame was disposed");

            var scrollBar = GetVerticalScrollBar();

            var addAdorners           = scrollBar != null && scrollBar.IsVisible;
            var explorerSearchResults = ExplorerSearchResults.GetExplorerSearchResults(_context);

            if (addAdorners)
            {
                foreach (var explorerElement in explorerSearchResults.Results)
                {
                    SearchAdornerDecorator.AddAdorner(
                        TreeViewAdornerLayer, SearchTicksTrack, explorerElement, this);
                }
            }

            if (_searchExpansionInProgress || _modelChangesCommittingInProgress)
            {
                // update Next & Previous whether tree is being expanded because
                // search was initiated by user or because model changes are being committed
                OnUpdateNextAndPreviousResults(true);

                // only select the Next or Previous result if search was initiated by user
                if (_searchExpansionInProgress)
                {
                    if (explorerSearchResults.CanGoToNextSearchResult)
                    {
                        OnSelectNextSearchResult();
                    }
                    else if (explorerSearchResults.CanGoToPreviousSearchResult)
                    {
                        OnSelectPreviousSearchResult();
                    }
                    else
                    {
                        // this has the side-effect of calling Focus() on the selected item
                        FocusExplorerEFElement(GetSelectedExplorerEFElement(), true);
                    }
                }
            }
        }
コード例 #4
0
        private void OnSelectPreviousSearchResult()
        {
            Debug.Assert(_context != null, "ExplorerFrame was disposed");
            try
            {
                _nextOrPreviousInProgress = true;

                var explorerSearchResults    = ExplorerSearchResults.GetExplorerSearchResults(_context);
                var previousSearchResultItem = explorerSearchResults.SelectPreviousSearchResult();
                if (previousSearchResultItem != null)
                {
                    previousSearchResultItem.ExpandTreeViewToMe();
                    FocusExplorerEFElement(previousSearchResultItem, true);
                    WaitUIUpdate();
                }
            }
            finally
            {
                _nextOrPreviousInProgress = false;
            }
        }