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


C# TextEditor.ScrollTo方法代码示例

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


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

示例1: FindNext


//.........这里部分代码省略.........
            int pos;
            int length = find.Length;
            StringComparison compareMode = (this.chkMatchCase.IsChecked == true) ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
            RegexOptions regexOps = (this.chkMatchCase.IsChecked == true) ? RegexOptions.None : RegexOptions.IgnoreCase;

            if (this.chkSearchUp.IsChecked == true)
            {
                //Search portion of Document prior to current position
                if (this.chkRegex.IsChecked == true)
                {
                    MatchCollection ms = Regex.Matches(editor.Text.Substring(0, start), find, regexOps);
                    if (ms.Count == 0)
                    {
                        pos = -1;
                    }
                    else
                    {
                        pos = ms[ms.Count - 1].Index;
                        length = ms[ms.Count - 1].Length;
                    }
                }
                else
                {
                    pos = editor.Text.Substring(0, start).LastIndexOf(find, compareMode);
                }
            }
            else
            {
                //Search position of Document subsequent to current position (incl. any selected text)
                start += editor.SelectionLength;
                if (this.chkRegex.IsChecked == true)
                {
                    Match m = Regex.Match(editor.Text.Substring(start), find, regexOps);
                    if (!m.Success)
                    {
                        pos = -1;
                    }
                    else
                    {
                        pos = start + m.Index;
                        length = m.Length;
                    }
                }
                else
                {
                    pos = editor.Text.IndexOf(find, start, compareMode);
                }
            }

            //If we've found the position of the next highlight it and return true otherwise return false
            if (pos > -1)
            {
                //Check we meet any document range restrictions
                if (pos < minPos || pos > maxPos)
                {
                    editor.CaretOffset = pos;
                    editor.SelectionStart = pos;
                    editor.SelectionLength = length;
                    return this.FindNext(editor, minPos, maxPos);
                }

                //If Matching on whole word ensure that their are boundaries before and after the match
                if (this.chkMatchWholeWord.IsChecked == true)
                {
                    //Check boundary before
                    if (pos > 0)
                    {
                        char c = editor.Text[pos - 1];
                        if (Char.IsLetterOrDigit(c))
                        {
                            //Not a boundary so adjust start position and recurse
                            editor.CaretOffset = pos + length;
                            if (this.chkSearchUp.IsChecked == false) editor.CaretOffset -= editor.SelectionLength;
                            return this.FindNext(editor);
                        }
                    }
                    //Check boundary after
                    if (pos + length < editor.Text.Length - 1)
                    {
                        char c = editor.Text[pos + length];
                        if (Char.IsLetterOrDigit(c))
                        {
                            //Not a boundary so adjust start position and recurse
                            editor.CaretOffset = pos + length - 1;
                            if (this.chkSearchUp.IsChecked == false) editor.CaretOffset -= editor.SelectionLength;
                            return this.FindNext(editor);
                        }
                    }
                }

                editor.Select(pos, length);
                editor.CaretOffset = pos;
                editor.ScrollTo(editor.Document.GetLineByOffset(pos).LineNumber, 0);
                return true;
            }
            else
            {
                return false;
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:101,代码来源:FindReplace.xaml.cs


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