Exemple #1
0
        /// <summary>
        /// Searches for all occurrences of a text in the preview pane.
        /// Highlights the first occurrence and ensures that it is shown in the preview.
        /// </summary>
        /// <param name="text">The search text.</param>
        /// <param name="matchCase">Indicates whether to perform a case-sensitive search.</param>
        /// <returns>True if at least one occurrence was found, false otherwise.</returns>
        public bool Find(string text, bool matchCase)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(false);
            }

            _findArgs            = new C1TextSearchArgs();
            _findArgs.Text       = text;
            _findArgs.IgnoreCase = !matchCase;
            _finds       = PreviewPane.TextSearchAll(_findArgs);
            _findCurrent = _finds != null && _finds.Length > 0 ? 0 : -1;
            if (_findCurrent != -1)
            {
                PreviewPane.SelectTextFragment(_finds[_findCurrent]);
                PreviewPane.GoToSelection();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
 /// <summary>
 /// Searches for the next occurrence of a text in the preview pane.
 /// Highlights the found occurrence and ensures that it is shown in the preview.
 /// If there are no more occurrences of the search text in the specified direction,
 /// wraps to the beginning or end of the document.
 /// </summary>
 /// <param name="text">The search text.</param>
 /// <param name="matchCase">Indicates whether to perform a case-sensitive search.</param>
 /// <param name="up">Indicates whether to search up or down in the document.</param>
 /// <returns>True if the next occurrence was found, false otherwise.</returns>
 public bool FindNext(string text, bool matchCase, bool up)
 {
     if (_finds == null || _finds.Length == 0)
     {
         return(Find(text, matchCase));
     }
     else
     {
         if (!up)
         {
             ++_findCurrent;
             if (_findCurrent >= _finds.Length)
             {
                 _findCurrent = 0;
             }
         }
         else
         {
             --_findCurrent;
             if (_findCurrent < 0)
             {
                 _findCurrent = _finds.Length - 1;
             }
         }
         if (_findCurrent >= 0 && _findCurrent < _finds.Length)
         {
             PreviewPane.SelectTextFragment(_finds[_findCurrent]);
             PreviewPane.GoToSelection();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }