当前位置: 首页>>代码示例>>C#>>正文


C# Range.GetRanges方法代码示例

本文整理汇总了C#中Range.GetRanges方法的典型用法代码示例。如果您正苦于以下问题:C# Range.GetRanges方法的具体用法?C# Range.GetRanges怎么用?C# Range.GetRanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Range的用法示例。


在下文中一共展示了Range.GetRanges方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetRanges

 /// <summary>
 /// Finds ranges for given regex pattern
 /// </summary>
 /// <param name="textbox"></param>
 /// <param name="regexPattern">Regex pattern</param>
 /// <param name="options"></param>
 /// <returns>Enumeration of ranges</returns>
 public static IEnumerable<Range> GetRanges(FastColoredTextBox textbox, string regexPattern, RegexOptions options)
 {
     var range = new Range(textbox);
     range.SelectAll();
     //
     foreach (Range r in range.GetRanges(regexPattern, options))
         yield return r;
 }
开发者ID:rickaas,项目名称:FastColoredTextBox,代码行数:15,代码来源:RangeUtil.cs

示例2: CSharpSyntaxHighlight

        /// <summary>
        /// Highlights C# code
        /// </summary>
        /// <param name="range"></param>
        public virtual void CSharpSyntaxHighlight(Range range)
        {
            range.tb.CommentPrefix = "//";
            range.tb.LeftBracket = '(';
            range.tb.RightBracket = ')';
            range.tb.LeftBracket2 = '\x0';
            range.tb.RightBracket2 = '\x0';
            //clear style of changed range
            range.ClearStyle(StringStyle, CommentStyle, NumberStyle, AttributeStyle, ClassNameStyle, KeywordStyle);
            //
            if (CSharpStringRegex == null)
                InitCShaprRegex();
            //string highlighting
            range.SetStyle(StringStyle, CSharpStringRegex);
            //comment highlighting
            range.SetStyle(CommentStyle, CSharpCommentRegex1);
            range.SetStyle(CommentStyle, CSharpCommentRegex2);
            range.SetStyle(CommentStyle, CSharpCommentRegex3);
            //number highlighting
            range.SetStyle(NumberStyle, CSharpNumberRegex);
            //attribute highlighting
            range.SetStyle(AttributeStyle, CSharpAttributeRegex);
            //class name highlighting
            range.SetStyle(ClassNameStyle, CSharpClassNameRegex);
            //keyword highlighting
            range.SetStyle(KeywordStyle, CSharpKeywordRegex);

            //find document comments
            foreach (var r in range.GetRanges(@"^\s*///.*$", RegexOptions.Multiline))
            {
                //remove C# highlighting from this fragment
                r.ClearStyle(StyleIndex.All);
                //do XML highlighting
                if (HTMLTagRegex == null)
                    InitHTMLRegex();
                //
                r.SetStyle(CommentStyle);
                //tags
                foreach (var rr in r.GetRanges(HTMLTagContentRegex))
                {
                    rr.ClearStyle(StyleIndex.All);
                    rr.SetStyle(CommentTagStyle);
                }
                //prefix '///'
                foreach (var rr in r.GetRanges( @"^\s*///", RegexOptions.Multiline))
                {
                    rr.ClearStyle(StyleIndex.All);
                    rr.SetStyle(CommentTagStyle);
                }
            }

            //clear folding markers
            range.ClearFoldingMarkers();
            //set folding markers
            range.SetFoldingMarkers("{", "}");//allow to collapse brackets block
            range.SetFoldingMarkers(@"#region\b", @"#endregion\b");//allow to collapse #region blocks
            range.SetFoldingMarkers(@"/\*", @"\*/");//allow to collapse comment block
        }
开发者ID:remco138,项目名称:FastColoredTextBox,代码行数:62,代码来源:SyntaxHighlighter.cs

示例3: XmlFolding

 private void XmlFolding(Range range)
 {
     var stack = new Stack<XmlFoldingTag>();
     var id = 0;
     var fctb = range.tb;
     //extract opening and closing tags (exclude open-close tags: <TAG/>)
     foreach (var r in range.GetRanges(XMLFoldingRegex))
     {
         var tagName = r.Text;
         var iLine = r.Start.iLine;
         //if it is opening tag...
         if (tagName[0] != '/')
         {
             // ...push into stack
             var tag = new XmlFoldingTag { Name = tagName, id = id++, startLine = r.Start.iLine };
             stack.Push(tag);
             // if this line has no markers - set marker
             if (string.IsNullOrEmpty(fctb[iLine].FoldingStartMarker))
                 fctb[iLine].FoldingStartMarker = tag.Marker;
         }
         else
         {
             //if it is closing tag - pop from stack
             if (stack.Count > 0)
             {
                 var tag = stack.Pop();
                 //compare line number
                 if (iLine == tag.startLine)
                 {
                     //remove marker, because same line can not be folding
                     if (fctb[iLine].FoldingStartMarker == tag.Marker) //was it our marker?
                         fctb[iLine].FoldingStartMarker = null;
                 }
                 else
                 {
                     //set end folding marker
                     if (string.IsNullOrEmpty(fctb[iLine].FoldingEndMarker))
                         fctb[iLine].FoldingEndMarker = tag.Marker;
                 }
             }
         }
     }
 }
开发者ID:tsovince,项目名称:V_Library,代码行数:43,代码来源:SyntaxHighlighter.cs

示例4: CSyntaxHighLight

        public virtual void CSyntaxHighLight(Range range)
        {
            range.tb.CommentPrefix = "//";
            range.tb.LeftBracket = '(';
            range.tb.RightBracket = ')';
            range.tb.LeftBracket2 = '{';
            range.tb.RightBracket2 = '}';
            range.tb.BracketsHighlightStrategy = BracketsHighlightStrategy.Strategy2;

            range.tb.AutoIndentCharsPatterns
                = @"
            ^\s*[\w\.]+(\s\w+)?\s*(?<range>=)\s*(?<range>[^;]+);
            ^\s*(case|default)\s*[^:]*(?<range>:)\s*(?<range>[^;]+);
            ";
            //clear style of changed range
            range.ClearStyle(StringStyle, CommentStyle, NumberStyle, AttributeStyle, ClassNameStyle, KeywordStyle);
            //
            if (CStringRegex == null)
                InitCRegex();
            //string highlighting
            range.SetStyle(StringStyle, CStringRegex);
            //comment highlighting
            range.SetStyle(CommentStyle, CCommentRegex1);
            range.SetStyle(CommentStyle, CCommentRegex2);
            range.SetStyle(CommentStyle, CCommentRegex3);
            //number highlighting
            range.SetStyle(NumberStyle, CNumberRegex);
            //directive highlighting
            range.SetStyle(StringStyle, CDirectiveRegex);
            //class name highlighting
            range.SetStyle(ClassNameStyle, CStructRegex);
            //keyword highlighting
            range.SetStyle(KeywordStyle, CKeywordRegex);

            //find document comments
            foreach (Range r in range.GetRanges(@"^\s*///.*$", RegexOptions.Multiline))
            {
                //remove C# highlighting from this fragment
                r.ClearStyle(StyleIndex.All);
                r.SetStyle(CommentStyle);
                //tags
                //prefix '///'
                foreach (Range rr in r.GetRanges(@"^\s*///", RegexOptions.Multiline))
                {
                    rr.ClearStyle(StyleIndex.All);
                    rr.SetStyle(CommentTagStyle);
                }
            }

            //clear folding markers
            range.ClearFoldingMarkers();
            //set folding markers
            range.SetFoldingMarkers("{", "}"); //allow to collapse brackets block
            range.SetFoldingMarkers(@"#region\b", @"#endregion\b"); //allow to collapse #region blocks
            range.SetFoldingMarkers(@"/\*", @"\*/"); //allow to collapse comment block
        }
开发者ID:BSUIR350531,项目名称:kiselev,代码行数:56,代码来源:SyntaxHighlighter.cs

示例5: CSharpSyntaxHighlight

        /// <summary>
        /// Highlights C# code
        /// </summary>
        /// <param name="range"></param>
        public void CSharpSyntaxHighlight(Range range)
        {
            range.tb.CommentPrefix = "//";
            range.tb.LeftBracket = '(';
            range.tb.RightBracket = ')';
            range.tb.LeftBracket2 = '{';
            range.tb.RightBracket2 = '}';
            range.tb.BracketsHighlightStrategy = BracketsHighlightStrategy.Strategy2;

            range.tb.AutoIndentCharsPatterns = @"^\s*[\w\.]+(\s\w+)?\s*(?<range>=)\s*(?<range>[^;]+);^\s*(case|default)\s*[^:]*(?<range>:)\s*(?<range>[^;]+);";
            range.ClearStyle(StringStyle, CommentStyle, NumberStyle, AttributeStyle, ClassNameStyle, KeywordStyle);
            if (CSharpStringRegex == null) InitCSharpRegex();
            range.SetStyle(NumberStyle, CSharpNumberRegex);
            range.SetStyle(AttributeStyle, CSharpAttributeRegex);
            range.SetStyle(ClassNameStyle, CSharpClassNameRegex);
            range.SetStyle(KeywordStyle, CSharpKeywordRegex);
            range.SetStylesStringsAndComments(CSharpStringAndCommentsRegex, StringStyle, CommentStyle); // By WendyH

            //find document comments
            foreach (Range r in range.GetRanges(@"^\s*///.*$", RegexOptions.Multiline)) {
                //remove C# highlighting from this fragment
                r.ClearStyle(StyleIndex.All);
                //do XML highlighting
                if (HTMLTagRegex == null)
                    InitHTMLRegex();
                //
                r.SetStyle(CommentStyle);
                //tags
                foreach (Range rr in r.GetRanges(HTMLTagContentRegex)) {
                    rr.ClearStyle(StyleIndex.All);
                    rr.SetStyle(CommentTagStyle);
                }
                //prefix '///'
                foreach (Range rr in r.GetRanges(@"^\s*///", RegexOptions.Multiline)) {
                    rr.ClearStyle(StyleIndex.All);
                    rr.SetStyle(CommentTagStyle);
                }
            }

            //clear folding markers
            range.ClearFoldingMarkers();
            //set folding markers
            range.SetFoldingMarkers("{", "}"); //allow to collapse brackets block
            range.SetFoldingMarkers(@"#region\b", @"#endregion\b"); //allow to collapse #region blocks
            range.SetFoldingMarkers(@"/\*", @"\*/"); //allow to collapse comment block
        }
开发者ID:WendyH,项目名称:HMSEditor,代码行数:50,代码来源:SyntaxHighlighter.cs

示例6: CSharpSyntaxHighlight

        public virtual void CSharpSyntaxHighlight(Range range)
        {
            range.tb.CommentPrefix = "//";
            range.tb.LeftBracket = '(';
            range.tb.RightBracket = ')';
            range.tb.LeftBracket2 = '{';
            range.tb.RightBracket2 = '}';
            range.tb.BracketsHighlightStrategy = BracketsHighlightStrategy.Strategy2;
            range.tb.AutoIndentCharsPatterns =
                "\r\n^\\s*[\\w\\.]+(\\s\\w+)?\\s*(?<range>=)\\s*(?<range>[^;]+);\r\n^\\s*(case|default)\\s*[^:]*(?<range>:)\\s*(?<range>[^;]+);\r\n";
            range.ClearStyle(StringStyle, CommentStyle, NumberStyle, AttributeStyle, ClassNameStyle, KeywordStyle, OmitableNameStyle);
            var flag = CSharpStringRegex == null;
            if (flag)
            {
                InitCShaprRegex();
            }
            range.SetStyle(StringStyle, CSharpStringRegex);
            range.SetStyle(CommentStyle, CSharpCommentRegex1);
            range.SetStyle(CommentStyle, CSharpCommentRegex2);
            range.SetStyle(CommentStyle, CSharpCommentRegex3);
            range.SetStyle(NumberStyle, CSharpNumberRegex);
            range.SetStyle(AttributeStyle, CSharpAttributeRegex);
            range.SetStyle(ClassNameStyle, CSharpClassNameRegex);
            range.SetStyle(OmitableNameStyle, CSharpOmitableNameRegex);
            range.SetStyle(PreCompileSpaceNameStyle, CSharpPreCompileSpaceNameRegex);
            range.SetStyle(KeywordStyle, CSharpKeywordRegex);
            foreach (var current in range.GetRanges("^\\s*///.*$", RegexOptions.Multiline))
            {
                current.ClearStyle(StyleIndex.All);
                
                current.SetStyle(CommentStyle);
                foreach (var current3 in current.GetRanges("^\\s*///", RegexOptions.Multiline))
                {
                    current3.ClearStyle(StyleIndex.All);
                    current3.SetStyle(CommentTagStyle);
                }
            }
            range.ClearFoldingMarkers();

            //set folding markers
            range.SetFoldingMarkers("<head", "</head>", RegexOptions.IgnoreCase);
            range.SetFoldingMarkers("<body", "</body>", RegexOptions.IgnoreCase);
            range.SetFoldingMarkers("<table", "</table>", RegexOptions.IgnoreCase);
            range.SetFoldingMarkers("<form", "</form>", RegexOptions.IgnoreCase);
            range.SetFoldingMarkers("<div", "</div>", RegexOptions.IgnoreCase);
            range.SetFoldingMarkers("<script", "</script>", RegexOptions.IgnoreCase);
            range.SetFoldingMarkers("<tr", "</tr>", RegexOptions.IgnoreCase);
        }
开发者ID:McSwaggens,项目名称:FastColoredTextBox,代码行数:48,代码来源:SyntaxHighlighter.cs

示例7: XMLSyntaxHighlight

        /// <summary>
        /// Highlights XML code
        /// </summary>
        /// <param name="range"></param>
        public virtual void XMLSyntaxHighlight(Range range)
        {
            range.tb.CommentPrefix = null;
            range.tb.LeftBracket = '<';
            range.tb.RightBracket = '>';
            range.tb.LeftBracket2 = '(';
            range.tb.RightBracket2 = ')';
            range.tb.AutoIndentCharsPatterns = @"";
            //clear style of changed range
            range.ClearStyle(CommentStyle, XmlTagBracketStyle, XmlTagNameStyle, XmlAttributeStyle, XmlAttributeValueStyle,
                             XmlEntityStyle, XmlCDataStyle);

            //
            if (XMLTagRegex == null)
            {
                InitXMLRegex();
            }

            //xml CData
            range.SetStyle(XmlCDataStyle, XMLCDataRegex);

            //comment highlighting
            range.SetStyle(CommentStyle, XMLCommentRegex1);
            range.SetStyle(CommentStyle, XMLCommentRegex2);

            //tag brackets highlighting
            range.SetStyle(XmlTagBracketStyle, XMLTagRegex);

            //tag name
            range.SetStyle(XmlTagNameStyle, XMLTagNameRegex);

            //end of tag
            range.SetStyle(XmlTagNameStyle, XMLEndTagRegex);

            //attributes
            range.SetStyle(XmlAttributeStyle, XMLAttrRegex);

            //attribute values
            range.SetStyle(XmlAttributeValueStyle, XMLAttrValRegex);

            //xml entity
            range.SetStyle(XmlEntityStyle, XMLEntityRegex);

            //clear folding markers
            range.ClearFoldingMarkers();

            //set folding markers
            //
            var stack = new Stack<XmlFoldingTag>();
            var id = 0;
            var fctb = range.tb;
            //extract opening and closing tags (exclude open-close tags: <TAG/>)
            foreach (var r in range.GetRanges(XMLFoldingRegex))
            {
                var tagName = r.Text;
                var iLine = r.Start.iLine;
                //if it is opening tag...
                if (tagName[0] != '/')
                {
                    // ...push into stack
                    var tag = new XmlFoldingTag { Name = tagName, id = id++, startLine = r.Start.iLine };
                    stack.Push(tag);
                    // if this line has no markers - set marker
                    if (string.IsNullOrEmpty(fctb[iLine].FoldingStartMarker))
                        fctb[iLine].FoldingStartMarker = tag.Marker;
                }
                else
                {
                    //if it is closing tag - pop from stack
                    if (stack.Count > 0)
                    {
                        var tag = stack.Pop();
                        //compare line number
                        if (iLine == tag.startLine)
                        {
                            //remove marker, because same line can not be folding
                            if (fctb[iLine].FoldingStartMarker == tag.Marker)//was it our marker?
                                fctb[iLine].FoldingStartMarker = null;
                        }
                        else
                        {
                            //set end folding marker
                            if (string.IsNullOrEmpty(fctb[iLine].FoldingEndMarker))
                                fctb[iLine].FoldingEndMarker = tag.Marker;
                        }
                    }
                }
            }
        }
开发者ID:rbrzezinski,项目名称:Trax,代码行数:93,代码来源:SyntaxHighlighter.cs


注:本文中的Range.GetRanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。