public void FindMatch(SearchParameters options) { int activeEditorIndex = mWordEditorList.ActiveEditorIndex; IWordEditor activeEditor = activeEditorIndex >= 0 ? mWordEditorList[activeEditorIndex] : null; if (activeEditor != null) { options.SearchFromWordIndex = ((IMemoryFullWord)activeEditor.WordValue).Index; options.SearchFromField = activeEditor.FocusedField ?? FieldTypes.None; options.SearchFromFieldIndex = options.SearchFromField != FieldTypes.None ? activeEditor.CaretIndex ?? 0 : 0; } else { if (mWordEditorList.FirstVisibleIndex > options.SearchFromWordIndex || mWordEditorList.FirstVisibleIndex + mWordEditorList.VisibleEditorCount <= options.SearchFromWordIndex) { options.SearchFromWordIndex = mWordEditorList.FirstVisibleIndex; } options.SearchFromField = FieldTypes.None; options.SearchFromFieldIndex = 0; } var result = mMemory.FindMatch(options); if (result != null) { MakeAddressVisible(result.WordIndex); activeEditor = mWordEditorList[result.WordIndex - mWordEditorList.FirstVisibleIndex]; activeEditor.Focus(result.Field, result.FieldIndex); activeEditor.Select(result.FieldIndex, options.SearchText.Length); } else { MessageBox.Show(this, string.Format("Search text \"{0}\" could not be found.", options.SearchText), "Text not found", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public SearchResult FindMatch(SearchParameters options) { if (options.SearchFromWordIndex < mMinIndex || options.SearchFromWordIndex > mMaxIndex) { return(null); } var filteredOptions = new SearchParameters { SearchText = options.SearchText, SearchFields = options.SearchFields, MatchWholeWord = options.MatchWholeWord, WrapSearch = options.WrapSearch, IncludeOriginalSource = options.IncludeOriginalSource, SearchFromWordIndex = options.SearchFromWordIndex + mIndexOffset, SearchFromField = options.SearchFromField, SearchFromFieldIndex = options.SearchFromFieldIndex }; var result = SourceMemory.FindMatch(filteredOptions); if (result == null) { return(null); } result.WordIndex -= mIndexOffset; if (result.WordIndex >= mMinIndex && result.WordIndex <= mMaxIndex) { return(result); } if (!options.WrapSearch || options.SearchFromWordIndex == mMinIndex) { return(null); } filteredOptions.SearchFromWordIndex = mMinIndex + mIndexOffset; filteredOptions.WrapSearch = false; result = SourceMemory.FindMatch(filteredOptions); return(result != null && (result.WordIndex -= mIndexOffset) < options.SearchFromWordIndex ? result : null); }