Example #1
0
        private void AplicarRegras()
        {
            MatchCollection keywordMatches    = Regras.Keywords().Matches(code.Text);
            MatchCollection stringMatches     = Regras.String().Matches(code.Text);
            MatchCollection operandsMatches   = Regras.Operands().Matches(code.Text);
            MatchCollection logicMatches      = Regras.Logics().Matches(code.Text);
            MatchCollection assignmentMatches = Regras.Assigments().Matches(code.Text);
            MatchCollection commentsMatches   = Regras.Comments().Matches(code.Text);
            MatchCollection operatorsMatches  = Regras.Operators().Matches(code.Text);
            MatchCollection typeMatches       = Regras.Types().Matches(code.Text);

            int   originalIndex  = code.SelectionStart;
            int   originalLength = code.SelectionLength;
            Color originalColor  = Color.FromArgb(247, 247, 241);

            label1.Focus();

            code.SelectionStart  = 0;
            code.SelectionLength = code.Text.Length;
            code.SelectionColor  = originalColor;

            highlighting.Highlighter(keywordMatches, Color.FromArgb(237, 114, 186), code);
            highlighting.Highlighter(stringMatches, Color.FromArgb(239, 248, 139), code);
            highlighting.Highlighter(operandsMatches, Color.FromArgb(136, 228, 248), code);
            highlighting.Highlighter(logicMatches, Color.FromArgb(237, 110, 115), code);
            highlighting.Highlighter(operatorsMatches, Color.FromArgb(237, 110, 115), code);
            highlighting.Highlighter(operandsMatches, Color.FromArgb(237, 110, 115), code);
            highlighting.Highlighter(assignmentMatches, Color.FromArgb(237, 110, 115), code);
            highlighting.Highlighter(commentsMatches, Color.FromArgb(0, 203, 137), code);
            highlighting.Highlighter(logicMatches, Color.FromArgb(237, 110, 115), code);
            highlighting.Highlighter(typeMatches, Color.FromArgb(136, 228, 248), code);

            code.SelectionStart  = originalIndex;
            code.SelectionLength = originalLength;
            code.SelectionColor  = originalColor;

            code.Focus();
        }