国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

設置代碼Code高亮顯示成藍色

2019-11-17 02:36:27
字體:
來源:轉載
供稿:網友

設置代碼Code高亮顯示成藍色

  下面方法是讓設置的關鍵字高亮顯示,考慮到了注釋與字符串的影響,所以備用,以便將來能夠用到.

        PRivate static void ColorizeCode(RichTextBox rtb)        {            string[] keyWords = {"as", "do", "if", "in", "is", "for", "int", "new", "out", "ref", "try", "base",                                "bool", "byte", "case", "char", "else", "enum", "goto", "lock", "long", "null",                                "this", "true", "uint", "void", "break", "catch", "class", "const", "event", "false",                                "fixed", "float", "sbyte", "short", "throw", "ulong", "using", "where", "while",                                "yield", "double", "extern", "object", "params", "public", "return", "sealed",                                "sizeof", "static", "string", "struct", "switch", "typeof", "unsafe", "ushort",                                "checked", "decimal", "default", "finally", "foreach", "partial", "private",                                "virtual", "abstract", "continue", "delegate", "explicit", "implicit", "internal",                                "Operator", "override", "readonly", "volatile",                                "interface", "namespace", "protected", "unchecked",                                "stackalloc",                                "from", "in", "where", "select", "join", "equals", "let", "on", "group", "by",                                "into", "orderby", "ascending", "descending", "var"};            string text = rtb.Text;            rtb.SelectAll();            rtb.SelectionColor = rtb.ForeColor;            foreach (String keyword in keywords)            {                int keywordPos = rtb.Find(keyword, RichTextBoxFinds.MatchCase | RichTextBoxFinds.WholeWord);                while (keywordPos != -1)                {                    int commentPos = text.LastIndexOf("http://", keywordPos, StringComparison.OrdinalIgnoreCase);                    int newLinePos = text.LastIndexOf("/n", keywordPos, StringComparison.OrdinalIgnoreCase);                    int quoteCount = 0;                    int quotePos = text.IndexOf("/"", newLinePos + 1, keywordPos - newLinePos, StringComparison.OrdinalIgnoreCase);                    while (quotePos != -1)                    {                        quoteCount++;                        quotePos = text.IndexOf("/"", quotePos + 1, keywordPos - (quotePos + 1), StringComparison.OrdinalIgnoreCase);                    }                    if (newLinePos >= commentPos && quoteCount % 2 == 0)                        rtb.SelectionColor = Color.Blue;                    keywordPos = rtb.Find(keyword, keywordPos + rtb.SelectionLength, RichTextBoxFinds.MatchCase | RichTextBoxFinds.WholeWord);                }            }            rtb.Select(0, 0);        }


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 会东县| 沈丘县| 克东县| 榆林市| 宣汉县| 永宁县| 习水县| 舟曲县| 大同县| 万年县| 锡林浩特市| 禹州市| 西城区| 云南省| 左权县| 廉江市| 鱼台县| 莱西市| 泰和县| 忻州市| 潮安县| 扎赉特旗| 图片| 墨脱县| 庄浪县| 会同县| 资源县| 镇雄县| 庐江县| 长乐市| 定结县| 弋阳县| 镇雄县| 鄂州市| 莲花县| 新兴县| 梁平县| 廉江市| 黄大仙区| 封开县| 色达县|