/// <summary> /// This is called by the Find dialog to locate the next name /// </summary> /// <param name="finder"></param> private void OnFindNext(FindSearchViewModel finder) { Debug.Assert(finder == _finder); IEnumerable <int> searchRange; if (finder.SearchBackward) { int spos = (FocusedRow != null) ? FocusedRow.Position : TotalRows; searchRange = Enumerable.Range(0, spos).Reverse(); } else { int spos = (FocusedRow != null) ? FocusedRow.Position : -1; searchRange = Enumerable.Range(spos + 1, TotalRows - (spos + 1)); } int foundAt = searchRange.Where(i => VisibleData[i].IsSequence).FirstOrDefault( i => finder.Match(VisibleData[i].Header)); if (foundAt == 0 && !finder.Match(VisibleData[0].Header)) { IErrorVisualizer errorVisualizer = Resolve <IErrorVisualizer>(); if (errorVisualizer != null) { errorVisualizer.Show("No Match", "No matches were found."); } } else { FocusedRow = VisibleData[foundAt]; TopRow = foundAt; } }
/// <summary> /// Locate a specific sequence by name (or partial name) /// </summary> private void OnFindByName() { if (_finder != null) { _finder.RaiseActivateRequest(); return; } IUIVisualizer uiVisualizer = Resolve <IUIVisualizer>(); if (uiVisualizer != null) { _finder = new FindSearchViewModel(new DelegatingCommand <FindSearchViewModel>(OnFindNext, fsvm => fsvm != null && !string.IsNullOrEmpty(fsvm.SearchString))); uiVisualizer.Show(typeof(FindSearchView).ToString(), _finder, true, (s, e) => { _finder = null; RaiseActivateRequest(); }); } }