本文整理汇总了C#中ICSharpCode.AvalonEdit.TextEditor.ScrollToVerticalOffset方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditor.ScrollToVerticalOffset方法的具体用法?C# TextEditor.ScrollToVerticalOffset怎么用?C# TextEditor.ScrollToVerticalOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.AvalonEdit.TextEditor
的用法示例。
在下文中一共展示了TextEditor.ScrollToVerticalOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddDocument
//Add document
private TextEditor AddDocument(string hLight, string title = null, bool showInRight = false, TextEditor syncBox = null)
{
//Define objects
FoldingManager foldingManager;
LayoutDocument dc = new LayoutDocument();
Grid gd = new Grid();
TextEditor rtb = new TextEditor();
TextBox tb = new TextBox();
//Installs the folding manager
foldingManager = FoldingManager.Install(rtb.TextArea);
//Get title
if (title == null)
title = "New page";
//Check for multiple titles
int counter = 0;
foreach (LayoutDocument ld in documentPanel.Children) {
if (ld.Title.Contains(title))
counter++;
}
//Object properties
if (counter > 0)
dc.Title = title + " (" + counter + ")";
else
dc.Title = title;
tb.Margin = new Thickness(0,0,0,0);
tb.VerticalAlignment = System.Windows.VerticalAlignment.Top;
tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
tb.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
tb.BorderBrush = new SolidColorBrush(Color.FromRgb(226,226,226));
tb.Foreground = new SolidColorBrush(Color.FromRgb(91, 91, 91));
tb.SelectionBrush = new SolidColorBrush(Color.FromArgb(90, 0, 0, 0));
tb.Height = 23;
//Text editor area
rtb.AllowDrop = true;
rtb.Tag = foldingManager;
rtb.Margin = new Thickness(0, 23, 0, 0);
rtb.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
rtb.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
rtb.FontFamily = new System.Windows.Media.FontFamily("Courier New");
rtb.FontSize = Convert.ToDouble(12);
rtb.Padding = new Thickness(11);
rtb.ShowLineNumbers = true;
rtb.LineNumbersForeground = new SolidColorBrush(Color.FromRgb(140, 140, 140));
rtb.TextArea.Options.EnableEmailHyperlinks = true;
rtb.TextArea.Options.EnableHyperlinks = true;
rtb.TextArea.Options.EnableTextDragDrop = true;
rtb.TextArea.SelectionCornerRadius = 0;
rtb.TextArea.SelectionBrush = new SolidColorBrush(Color.FromArgb(190, 0, 0, 0));
rtb.TextArea.SelectionBorder = new Pen(new SolidColorBrush(Color.FromArgb(30, 0, 0, 0)), 1);
//rtb.TextArea.TextView.LineTransformers.Add(new ColorizeAvalonEdit());
rtb.Options.EnableRectangularSelection = true;
rtb.Options.AllowScrollBelowDocument = true;
//Rich text change
rtb.TextChanged += new EventHandler(
delegate(object sender, EventArgs e)
{
//Update folding layout
try
{
//Set status to not saved
if (!activeLayout().Title.EndsWith(" *"))
activeLayout().Title += " *";
//Update stats
documentStats();
foldingStrategy.UpdateFoldings((activeDocument().Tag as FoldingManager), activeDocument().Document);
}
catch { }
});
rtb.TextArea.Caret.PositionChanged += new EventHandler(
delegate(object sender, EventArgs e) {
try {
documentStats();
}
catch { }
});
if (showInRight && syncBox != null) {
//rtb.TextArea.TextView.ScrollOffsetChanged += new EventHandler(
// delegate(object sender, EventArgs e) {
// if (IsMouseOver)
// syncBox.ScrollToVerticalOffset(rtb.VerticalOffset);
//});
syncBox.TextArea.Caret.PositionChanged += new EventHandler(
delegate(object sender, EventArgs e) {
rtb.ScrollToVerticalOffset(syncBox.VerticalOffset);
});
syncBox.TextArea.TextView.ScrollOffsetChanged += new EventHandler(
delegate(object sender, EventArgs e) {
if (IsMouseOver)
rtb.ScrollToVerticalOffset(syncBox.VerticalOffset);
});
}
//.........这里部分代码省略.........