本文整理汇总了C#中ICSharpCode.AvalonEdit.TextEditor.ScrollToEnd方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditor.ScrollToEnd方法的具体用法?C# TextEditor.ScrollToEnd怎么用?C# TextEditor.ScrollToEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.AvalonEdit.TextEditor
的用法示例。
在下文中一共展示了TextEditor.ScrollToEnd方法的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: OpenScript
/// <summary>
///
/// </summary>
/// <param name="path"></param>
/// <returns>true when a new tab is created</returns>
public bool OpenScript(string path)
{
int srcFileOpen = FileIsOpen(path);
if (srcFileOpen == -1) // not found
{
FoldingManager foldingManager;
AbstractFoldingStrategy foldingStrategy;
foldingStrategy = new BraceFoldingStrategy();
TextEditor textEditor = new TextEditor();
textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(textEditor.Options);
textEditor.Foreground = FindResource("ForegroundGray") as Brush;
textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#");
textEditor.ScrollToEnd();
textEditor.FontFamily = new FontFamily("Consolas");
textEditor.FontSize = 11;
textEditor.ShowLineNumbers = true;
textEditor.Text = File.ReadAllText(path, Encoding.UTF8);
textEditor.Tag = path; // stores the file path in memory
textEditor.TextChanged += textEditor_TextChanged;
textEditor.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
textEditor.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
foldingManager = FoldingManager.Install(textEditor.TextArea);
foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document);
TabItem tabItem = new TabItem();
tabItem.Style = FindResource("TabItemStyle") as Style;
tabItem.Foreground = FindResource("ForegroundGray") as Brush;
tabItem.Header = System.IO.Path.GetFileNameWithoutExtension(path);
tabItem.Content = textEditor;
tabItem.Tag = path; // stores the file path in memory
tabItem.Loaded += tabItem_Loaded;
tabControl.Items.Add(tabItem);
tabControl.SelectedIndex = tabControl.Items.Count - 1;
return true;
}
else
{
tabControl.SelectedIndex = srcFileOpen;
this.Activate();
FLASHWINFO pf = new FLASHWINFO();
pf.cbSize = Convert.ToUInt32(Marshal.SizeOf(pf));
pf.hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;
pf.dwFlags = FLASHW_TIMER | FLASHW_TRAY; // (or FLASHW_ALL to flash and if it is not minimized)
pf.uCount = 8;
pf.dwTimeout = 75;
FlashWindowEx(ref pf);
return false;
}
}