コード例 #1
0
        /// <summary>
        /// Searches the text in a RichTextBox control for a string within a range of text within the control
        /// and with specific options applied to the search.
        /// </summary>
        /// <param name="search">The string to search for.</param>
        /// <param name="start">The location within the control's text at which to begin searching.</param>
        /// <param name="end">The location within the control's text at which to end searching.</param>
        /// <param name="finds">A bitwise combination of the ColorTextBoxFinds values.</param>
        /// <returns>Start position of the first occurence of the search string.</returns>
        public int Find(String search, int start, int end, ColorTextBoxFinds finds)
        {
            if (start < 0)
            {
                start = 0;
            }
            if (end < 0)
            {
                end = document.LastPos;
            }
            bool backwards = ((finds & ColorTextBoxFinds.Reverse) == ColorTextBoxFinds.Reverse);

            if (end > start)
            {
                Position <Line, Token> found = null;
                if (backwards)
                {
                    Position <Line, Token> startP = document.GetPosition(end);
                    if (startP != null)
                    {
                        found = document.Find(search, startP, finds);
                    }
                    if (found != null)
                    {
                        int retPos = document.GetCharPosition(found);
                        if (retPos >= start)
                        {
                            return(retPos);
                        }
                    }
                }
                else
                {
                    Position <Line, Token> startP = document.GetPosition(start);
                    if (startP != null)
                    {
                        found = document.Find(search, startP, finds);
                    }
                    if (found != null)
                    {
                        int retPos = document.GetCharPosition(found);
                        if (retPos <= end)
                        {
                            return(retPos);
                        }
                    }
                }
            }
            return(-1);
        }
コード例 #2
0
 /// <summary>
 /// Searches the text in a ColorTextBox control for a string at a specific location within the control
 /// and with specific options applied to the search.
 /// </summary>
 /// <param name="search">The string to search for.</param>
 /// <param name="start">The location within the control's text at which to begin searching.</param>
 /// <param name="finds"></param>
 /// <returns>Start position of the first occurence of the search string.</returns>
 public int Find(String search, int start, ColorTextBoxFinds finds)
 {
     return(Find(search, start, -1, finds));
 }
コード例 #3
0
 /// <summary>
 /// Searches the text in a ColorTextBox control for a string with specific options applied to the search.
 /// </summary>
 /// <param name="search">The string to search for</param>
 /// <param name="finds">A bitwise combination of the ColorTextBoxFinds values.</param>
 /// <returns>Start position of the first occurence of the search string.</returns>
 public int Find(String search, ColorTextBoxFinds finds)
 {
     return(Find(search, 0, finds));
 }