Exemplo n.º 1
0
        private void ContinueFind(bool next = true, bool replace = false)
        {
            if (!replace && string.IsNullOrEmpty(_textToFind))
            {
                Find();
                return;
            }
            else if (replace && (string.IsNullOrEmpty(_textToFind) ||
                                 (winDialog == null && string.IsNullOrEmpty(_textToReplace))))
            {
                Replace();
                return;
            }

            bool found;
            bool gaveFullTurn;

            if (next)
            {
                if (!replace)
                {
                    found = _textView.FindNextText(_textToFind, out gaveFullTurn, _matchCase, _matchWholeWord);
                }
                else
                {
                    found = _textView.FindNextText(_textToFind, out gaveFullTurn, _matchCase, _matchWholeWord,
                                                   _textToReplace, true);
                }
            }
            else
            {
                if (!replace)
                {
                    found = _textView.FindPreviousText(_textToFind, out gaveFullTurn, _matchCase, _matchWholeWord);
                }
                else
                {
                    found = _textView.FindPreviousText(_textToFind, out gaveFullTurn, _matchCase, _matchWholeWord,
                                                       _textToReplace, true);
                }
            }
            if (!found)
            {
                MessageBox.Query("Find", $"The following specified text was not found: '{_textToFind}'", "Ok");
            }
            else if (gaveFullTurn)
            {
                MessageBox.Query("Find", $"No more occurrences were found for the following specified text: '{_textToFind}'", "Ok");
            }
        }