本文整理汇总了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;
}
}