src/Misc/EFTools/XmlCore/UI/ViewModels/Explorer/ExplorerSearchResults.cs
/// <summary>
///     Recalculate the Next and Previous items based on the passed in current selection
///     which may or may not be in the Search Results.
///     Note: if currentlySelectedItem _is_ in Search Results then Previous and Next items
///     will bracket it (i.e. neither Next nor Previous will be the currently selected item).
/// </summary>
Recalculate the Next and Previous items based on the passed in current selection
which may or may not be in the Search Results.
Note: if currentlySelectedItem _is_ in Search Results then Previous and Next items
will bracket it .
Recalculate the Next and Previous items based on the passed in current selection which may or may not be in the Search Results . Note : if currentlySelectedItem _is_ in Search Results then Previous and Next items will bracket it .
internal void RecalculateNextAndPrevious(ExplorerEFElement currentlySelectedItem)
        {
            if (null == _results)
            {
                Debug.Assert(false, "RecalculateNextAndPrevious called when _results is null");
                return;
            }
            var indexOfCurrentSelectionInResults = _results.BinarySearch(currentlySelectedItem, ExplorerHierarchyComparer.Instance);
            if (indexOfCurrentSelectionInResults >= 0)
            {
                _currentSelectionIsInResults = true;
                if (indexOfCurrentSelectionInResults > 0)
                {
                    _previousSearchResultItemIndex = indexOfCurrentSelectionInResults - 1;
                    _previousSearchResultItem = _results[_previousSearchResultItemIndex];
                }
                else
                {
                    _previousSearchResultItemIndex = -1;
                    _previousSearchResultItem = null;
                }
                if ((indexOfCurrentSelectionInResults + 1) < _results.Count)
                {
                    _nextSearchResultItemIndex = indexOfCurrentSelectionInResults + 1;
                    _nextSearchResultItem = _results[_nextSearchResultItemIndex];
                }
                else
                {
                    _nextSearchResultItemIndex = -1;
                    _nextSearchResultItem = null;
                }
            }
            else
            {
                _currentSelectionIsInResults = false;
                var indexOfNextGreatestItem = ~indexOfCurrentSelectionInResults;
                if (indexOfNextGreatestItem == _results.Count)
                {
                    _nextSearchResultItemIndex = -1;
                    _nextSearchResultItem = null;
                }
                else
                {
                    _nextSearchResultItemIndex = indexOfNextGreatestItem;
                    _nextSearchResultItem = _results[_nextSearchResultItemIndex];
                }
                if (_nextSearchResultItemIndex > 0)
                {
                    _previousSearchResultItemIndex = _nextSearchResultItemIndex - 1;
                    _previousSearchResultItem = _results[_previousSearchResultItemIndex];
                }
                else if (_nextSearchResultItemIndex == 0)
                {
                    _previousSearchResultItemIndex = -1;
                    _previousSearchResultItem = null;
                }
                else if (_results.Count > 0)
                {
                    _previousSearchResultItemIndex = _results.Count - 1;
                    _previousSearchResultItem = _results[_previousSearchResultItemIndex];
                }
                else
                {
                    _previousSearchResultItemIndex = -1;
                    _previousSearchResultItem = null;
                }
            }
        }
internal void RecalculateNextAndPrevious ( ExplorerEFElement currentlySelectedItem ) { if ( null == _results ) { Debug . Assert ( false , " " ) ; return ; } var indexOfCurrentSelectionInResults = _results . BinarySearch ( currentlySelectedItem , ExplorerHierarchyComparer . Instance ) ; if ( indexOfCurrentSelectionInResults >= 0 ) { _currentSelectionIsInResults = true ; if ( indexOfCurrentSelectionInResults > 0 ) { _previousSearchResultItemIndex = indexOfCurrentSelectionInResults - 1 ; _previousSearchResultItem = _results [ _previousSearchResultItemIndex ] ; } else { _previousSearchResultItemIndex = - 1 ; _previousSearchResultItem = null ; } if ( ( indexOfCurrentSelectionInResults + 1 ) < _results . Count ) { _nextSearchResultItemIndex = indexOfCurrentSelectionInResults + 1 ; _nextSearchResultItem = _results [ _nextSearchResultItemIndex ] ; } else { _nextSearchResultItemIndex = - 1 ; _nextSearchResultItem = null ; } } else { _currentSelectionIsInResults = false ; var indexOfNextGreatestItem = ~ indexOfCurrentSelectionInResults ; if ( indexOfNextGreatestItem == _results . Count ) { _nextSearchResultItemIndex = - 1 ; _nextSearchResultItem = null ; } else { _nextSearchResultItemIndex = indexOfNextGreatestItem ; _nextSearchResultItem = _results [ _nextSearchResultItemIndex ] ; } if ( _nextSearchResultItemIndex > 0 ) { _previousSearchResultItemIndex = _nextSearchResultItemIndex - 1 ; _previousSearchResultItem = _results [ _previousSearchResultItemIndex ] ; } else if ( _nextSearchResultItemIndex == 0 ) { _previousSearchResultItemIndex = - 1 ; _previousSearchResultItem = null ; } else if ( _results . Count > 0 ) { _previousSearchResultItemIndex = _results . Count - 1 ; _previousSearchResultItem = _results [ _previousSearchResultItemIndex ] ; } else { _previousSearchResultItemIndex = - 1 ; _previousSearchResultItem = null ; } } }
Recalculate the Next and Previous items based on the passed in current selection
which may or may not be in the Search Results.
Recalculate the Next and Previous items based on the passed in current selection which may or may not be in the Search Results .
// recalculate, note that _results is in increasing order so can perform // binary search to find the item equal to or just above this element // currentlySelectedItem is in _results list // currentlySelectedItem is _not_ in _results list // there is no item "greater" than selected item in list // current selection is not in list and _nextSearchResultItemIndex > 0 // so _previousSearchResultItemIndex must be the next item down the list // _nextSearchResultItemIndex == 0, so _previousSearchResultItem does not exist // there is no _nextSearchResultItem, so current selection is "greater" than // all items in the list, so _previousSearchResultItem is the last item in the list // the list is empty so both _nextSearchResultItem and  // _previousSearchResultItem do not exist
currentlySelectedItem
ExplorerEFElement