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


C# Range.GetFragment方法代码示例

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


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

示例1: OnToolTip

        //函数悬停提示
        protected override void OnToolTip()
        {
            if (ToolTip == null)
                return;
            if (ToolTipNeeded == null)
                return;

            //get place under mouse
            Place place = PointToPlace(lastMouseCoord);

            //check distance
            Point p = PlaceToPoint(place);
            if (Math.Abs(p.X - lastMouseCoord.X) > CharWidth*2 ||
                Math.Abs(p.Y - lastMouseCoord.Y) > CharHeight*2)
                return;
            //get word under mouse
            var r = new Range(this, place, place);
            string hoveredWord = r.GetFragment("[a-zA-Z0-9_]").Text;
            //event handler
            var ea = new ToolTipNeededEventArgs(place, hoveredWord);
            ToolTipNeeded(this, ea);

            if (ea.ToolTipText != null)
            {
                //show tooltip
                ToolTip.ToolTipTitle = ea.ToolTipTitle;
                ToolTip.ToolTipIcon = ea.ToolTipIcon;
                //ToolTip.SetToolTip(this, ea.ToolTipText);
                ToolTip.Show(ea.ToolTipText, this, new Point(lastMouseCoord.X, lastMouseCoord.Y + CharHeight));
            }
        }
开发者ID:jiaoy06,项目名称:DataEditorX,代码行数:32,代码来源:FastColoredTextBoxEx.cs

示例2: fastColoredTextBox_Code_ToolTipNeeded

 private void fastColoredTextBox_Code_ToolTipNeeded(object aSender, ToolTipNeededEventArgs aEventArgs)
 {
     var lRange  = new Range(aSender as FastColoredTextBox, aEventArgs.Place, aEventArgs.Place);
         try
         {
             int lHandle = mBrowser.getItemHandleByName(lRange.GetFragment("[^\n ']").Text);
             if (lHandle != -1)
             {
                 aEventArgs.ToolTipText = mBrowser.getItemToolTipByHandle(lHandle);
             }
         }
         catch { }
 }
开发者ID:yuriik83,项目名称:Process-Simulator-2-OpenSource,代码行数:13,代码来源:SetupForm.cs

示例3: DoHighlighting

        protected virtual void DoHighlighting()
        {
            if (parser == null)
                return;

            //parse text
            ParseTree tree;

            try
            {
                tree = parser.Parse(Text);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message); //oops...
                return;
            }

            //highlight errors
            if (tree.Status == ParseTreeStatus.Error)
            {
                ClearStyle(GetStyleIndexMask(new[] {WavyStyle}));
                foreach (var msg in tree.ParserMessages)
                {
                    var loc = msg.Location;
                    var place = new Place(loc.Column, loc.Line);
                    var r = new Range(this, place, place);
                    var f = r.GetFragment(@"[\S]");
                    f.SetStyle(WavyStyle);
                }
                return;
            }

            //highlight syntax
            ClearStyle(StyleIndex.All);
            foreach (var t in tree.Tokens)
            {
                var arg = new StyleNeededEventArgs(t);
                OnStyleNeeded(arg);

                if (arg.Cancel)
                    continue;

                if (arg.Style != null)
                {
                    GetTokenRange(t).SetStyle(arg.Style);
                    continue;
                }

                switch (t.Terminal.GetType().Name)
                {
                    case "KeyTerm":
                        if ((t.Terminal.Flags & TermFlags.IsKeyword) != 0) //keywords are highlighted only
                            GetTokenRange(t).SetStyle(SyntaxHighlighter.KeywordStyle);
                        break;
                    case "NumberLiteral":
                        GetTokenRange(t).SetStyle(SyntaxHighlighter.NumberStyle);
                        break;
                    case "StringLiteral":
                        GetTokenRange(t).SetStyle(SyntaxHighlighter.StringStyle);
                        break;
                    case "CommentTerminal":
                        GetTokenRange(t).SetStyle(SyntaxHighlighter.CommentStyle);
                        break;
                }
            }
        }
开发者ID:workwhileweb,项目名称:FastColoredTextBox,代码行数:67,代码来源:IronyFCTB.cs

示例4: tb_MouseMove

        private void tb_MouseMove(object sender, MouseEventArgs e)
        {
            var tb = sender as FastColoredTextBox;
            var place = tb.PointToPlace(e.Location);
            var r = new Range(tb, place, place);

            string text = r.GetFragment("[\\(\\)a-zA-Z_0-9]").Text;
            int result = 0;
            if (text.Length > 0 && !int.TryParse(text, out result) && !(text[0] == '(') && !(text[text.Length - 1] == ')'))
            {
                List<Style> stls = tb.GetStylesOfChar(place);
                int x = stls.FindIndex(p => p == tb.SyntaxHighlighter.styScpComments);
                if (x > 0)
                    return;
                toolStripStatusLabel1.Text = text;
            }
            else
            {
                toolStripStatusLabel1.Text = "";
            }
        }
开发者ID:msx752,项目名称:ScriptCommunityPack-Editor,代码行数:21,代码来源:REditor.cs

示例5: CurrentWord

 private string CurrentWord()
 {
     Range r = new Range(Editor, Editor.Selection.Start, Editor.Selection.Start);
     r = r.GetFragment(@"[\w]");
     if (Editor.SyntaxHighlighter.IsCommentOrString(r)) return "";
     return r.Text;
 }
开发者ID:WendyH,项目名称:HMSEditor,代码行数:7,代码来源:HMSEditor.cs


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