Example #1
0
        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);
            }
        }