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


C# TextEditor.ScrollToVerticalOffset方法代码示例

本文整理汇总了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);
                });
            }
//.........这里部分代码省略.........
开发者ID:404rq,项目名称:WalrusPad,代码行数:101,代码来源:MainWindow.xaml.cs


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