Exemple #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;
 }
Exemple #2
0
        public void EndRtbUpdate()
        {
            Message msg_WM_SETREDRAW = Message.Create(ScriptRichTextBox.Handle, WM_SETREDRAW, rtBox_wParam, rtBox_lParam);

            this.DefWndProc(ref msg_WM_SETREDRAW);
            //redraw the RichTextBox
            ScriptRichTextBox.Invalidate();
        }
Exemple #3
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();
        }