本文整理汇总了C#中ICSharpCode.AvalonEdit.TextEditor.ScrollToHome方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditor.ScrollToHome方法的具体用法?C# TextEditor.ScrollToHome怎么用?C# TextEditor.ScrollToHome使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.AvalonEdit.TextEditor
的用法示例。
在下文中一共展示了TextEditor.ScrollToHome方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Set
public void Set(TextEditor textEditor, IEnumerable<MulticastMessageViewModel> collection)
{
_ranges.Clear();
var document = new StringBuilder();
var settings = new List<CustomElementSetting>();
foreach (var target in collection)
{
int startOffset = document.Length;
{
string item1;
if (target.Option.State.HasFlag(MulticastMessageState.IsLocked)) item1 = "#";
else if (target.Option.State.HasFlag(MulticastMessageState.IsUnread)) item1 = "!";
else item1 = "@";
var item2 = target.Item.CreationTime.ToLocalTime().ToString(LanguagesManager.Instance.DateTime_StringFormat, System.Globalization.DateTimeFormatInfo.InvariantInfo);
var item3 = target.Item.Signature;
{
settings.Add(new CustomElementSetting("State", document.Length, item1.Length));
document.Append(item1);
document.Append(" ");
settings.Add(new CustomElementSetting("CreationTime", document.Length, item2.Length));
document.Append(item2);
document.Append(" - ");
settings.Add(new CustomElementSetting("Signature", document.Length, item3.Length));
document.Append(item3);
if (!Inspect.ContainTrustSignature(target.Item.Signature))
{
document.Append(" +");
document.Append(target.Option.Cost);
}
}
document.AppendLine();
}
{
document.AppendLine();
}
{
foreach (var line in target.Item.Comment
.Trim('\r', '\n')
.Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.None)
.Take(128))
{
foreach (var match in _uriRegexes.Select(n => n.Matches(line)).SelectMany(n => n.OfType<Match>()))
{
settings.Add(new CustomElementSetting("Uri", document.Length + match.Index, match.Length));
}
document.AppendLine(line);
}
}
{
document.AppendLine();
}
_ranges.Add(new CustomElementRange(startOffset, document.Length));
}
if (document.Length >= 2) document.Remove(document.Length - 2, 2);
textEditor.Document.BeginUpdate();
textEditor.Document.Text = "";
textEditor.CaretOffset = 0;
textEditor.SelectionLength = 0;
textEditor.TextArea.TextView.ElementGenerators.Clear();
textEditor.ScrollToHome();
textEditor.Document.Text = document.ToString();
var elementGenerator = new CustomElementGenerator(settings);
elementGenerator.ClickEvent += (string text) => this.OnClickEvent(text);
elementGenerator.SelectEvent += (CustomElementRange range) => textEditor.Select(range.Start, range.End - range.Start);
textEditor.TextArea.TextView.ElementGenerators.Add(elementGenerator);
textEditor.Document.EndUpdate();
textEditor.CaretOffset = textEditor.Document.Text.Length;
textEditor.TextArea.Caret.BringCaretToView();
textEditor.ScrollToEnd();
}
示例2: Clear
public void Clear(TextEditor textEditor)
{
_ranges.Clear();
textEditor.Document.BeginUpdate();
textEditor.Document.Text = "";
textEditor.CaretOffset = 0;
textEditor.SelectionLength = 0;
textEditor.TextArea.TextView.ElementGenerators.Clear();
textEditor.ScrollToHome();
textEditor.Document.EndUpdate();
}