示例#1
0
 private void FormatKeyword(string keyword, int wordIndex, Color wordColour)
 {
     ScriptRichTextBox.Select((wordIndex - _returnIdxFix), keyword.Length);
     ScriptRichTextBox.SelectionColor = wordColour;
     ScriptRichTextBox.Select(wordIndex + keyword.Length, 0);
     ScriptRichTextBox.SelectionColor = _DefaultColour;
 }
示例#2
0
        private void ProcessAllText()
        {
            BeginRtbUpdate();
            FormatKeywords(_LightBlueRegX, _LightBlueColour);
            FormatKeywords(_BlueRegX, _BlueColour);
            FormatKeywords(_GreenRegX, _GreenColour);

            //internal function to process words and set their colours
            void FormatKeywords(string regExPattern, Color wordColour)
            {
                var matchStrings = Regex.Matches(ScriptRichTextBox.Text, regExPattern);

                foreach (Match match in matchStrings)
                {
                    FormatKeyword(keyword: match.Value, wordIndex: match.Index, wordColour: wordColour);
                }
            }

            EndRtbUpdate();
            ScriptRichTextBox.Select(ScriptRichTextBox.Text.Length, 0);
            ScriptRichTextBox.Invalidate();
        }