public void pintar(SyntaxRichTextBox syntaxRichTextBox1)
        {
            string[] pala = new string[]
            {
                "char", "float", "double", "short", "int", "long", "and", "as", "assert", "break",
                "class", "continue", "def", "del", "elif", "else", "except", "exec", "finally", "for",
                "from", "global", "if", "import", "in", "is", "lambda", "not", "or", "pass", "try", "while",
                "with", "yield", "print", "include", "std", "cout", "endl", "main", "void", "input",
            };
            foreach (var item in pala)
            {
                syntaxRichTextBox1.Settings.Keywords.Add(item);
            }


            syntaxRichTextBox1.Settings.Comment = "//";


            syntaxRichTextBox1.Settings.KeywordColor = Color.Blue;
            syntaxRichTextBox1.Settings.CommentColor = Color.Green;
            syntaxRichTextBox1.Settings.StringColor  = Color.Orange;
            syntaxRichTextBox1.Settings.IntegerColor = Color.Red;

            syntaxRichTextBox1.Settings.EnableIntegers = false;
            syntaxRichTextBox1.Settings.EnableStrings  = true;
            syntaxRichTextBox1.CompileKeywords();
            syntaxRichTextBox1.ProcessAllLines();
        }
예제 #2
0
        public PatternEditor()
        {
            InitializeComponent();
            AddHandler(Keyboard.KeyDownEvent, (System.Windows.Input.KeyEventHandler)HandleKeyDownEvent);
            // Add the keywords to the list.
            m_syntaxRichTextBox.Settings.Keywords.Add("function");
            m_syntaxRichTextBox.Settings.Keywords.Add("if");
            m_syntaxRichTextBox.Settings.Keywords.Add("then");
            m_syntaxRichTextBox.Settings.Keywords.Add("else");
            m_syntaxRichTextBox.Settings.Keywords.Add("elseif");
            m_syntaxRichTextBox.Settings.Keywords.Add("end");

            // Set the comment identifier.
            // For Lua this is two minus-signs after each other (--).
            // For C++ code we would set this property to "//".
            m_syntaxRichTextBox.Settings.Comment = "--";
            // Set the colors that will be used.
            m_syntaxRichTextBox.Settings.KeywordColor = System.Drawing.Color.Blue;
            m_syntaxRichTextBox.Settings.CommentColor = System.Drawing.Color.Green;
            m_syntaxRichTextBox.Settings.StringColor  = System.Drawing.Color.Gray;
            m_syntaxRichTextBox.Settings.IntegerColor = System.Drawing.Color.Red;
            // Let's not process strings and integers.
            m_syntaxRichTextBox.Settings.EnableStrings  = true;
            m_syntaxRichTextBox.Settings.EnableIntegers = true;

            // Let's make the settings we just set valid by compiling
            // the keywords to a regular expression.
            m_syntaxRichTextBox.CompileKeywords();
            m_syntaxRichTextBox.Font            = new System.Drawing.Font("Courier New", 10);
            m_syntaxRichTextBox.Text            = PSMC.Properties.Settings.Default.CustomModelPattern;
            m_syntaxRichTextBox.Invalidated    += m_syntaxRichTextBox_TextChanged;
            m_syntaxRichTextBox.PreviewKeyDown += m_syntaxRichTextBox_TextChanged;
            this.wfh.Child = m_syntaxRichTextBox;
            m_syntaxRichTextBox.ProcessAllLines();
        }