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


C# TextEditor.ScrollToLine方法代码示例

本文整理汇总了C#中ICSharpCode.AvalonEdit.TextEditor.ScrollToLine方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditor.ScrollToLine方法的具体用法?C# TextEditor.ScrollToLine怎么用?C# TextEditor.ScrollToLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICSharpCode.AvalonEdit.TextEditor的用法示例。


在下文中一共展示了TextEditor.ScrollToLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindTextInTextEditor

        public void FindTextInTextEditor(TextEditor te)
        {
            if (tbFind.Text.Length == 0) return;
            //         if (cbFindUp.IsChecked == false) G.CurOffset = te.SelectionStart;
            //          else G.CurOffset = te.SelectionStart + te.SelectionLength;
            string stext = tbFind.Text;
            if (cbMatchCase.IsChecked == false) stext = stext.ToLower();
            //    if (cbMatchWholeWord.IsChecked == true) stext = ' ' + stext + ' ';
            if (cbFindUp.IsChecked == false) //Find down
            {
                while (true)
                {
                    DocumentLine dl = te.Document.GetLineByOffset(G.CurOffset);
                    string str = te.Document.GetText(G.CurOffset, dl.Length - (G.CurOffset - dl.Offset));
                    if (cbMatchCase.IsChecked == false) str = str.ToLower();
                    int pos;

                    pos = str.IndexOf(stext);
                    if (pos != -1)
                    {
                    }
                    if (cbMatchWholeWord.IsChecked == true)
                        if (!G.LineConsist(str.Split(' '), stext)) pos = -1;
                    if (pos != -1)
                    {
                        te.ScrollToLine(dl.LineNumber);
                        te.Select(dl.Offset + pos, stext.Length);
                        G.CurOffset = dl.Offset + dl.TotalLength; ;
                        break;
                    }


                    G.CurOffset = dl.Offset + dl.TotalLength;
                    if (G.CurOffset >= te.Document.TextLength) { MessageBox.Show("Reached end of document."); G.CurOffset = 0; break; }
                }//for                             
            }
            else // Find up
            {
                while (true)
                {
                    DocumentLine dl = te.Document.GetLineByOffset(G.CurOffset);
                    string str = te.Document.GetText(dl.Offset, G.CurOffset - dl.Offset);
                    if (cbMatchCase.IsChecked == false) str = str.ToLower();
                    int pos = str.IndexOf(stext);
                    if (pos != -1)
                    {
                        te.ScrollToLine(dl.LineNumber);
                        te.Select(dl.Offset + pos, stext.Length);
                        G.CurOffset = dl.Offset + pos;
                        break;
                    }//if 
                    if (dl.PreviousLine != null)
                        G.CurOffset = dl.PreviousLine.Offset + dl.PreviousLine.Length;
                    else G.CurOffset = 0;
                    if (G.CurOffset <= 0) { MessageBox.Show("Reached begin of document."); G.CurOffset = 0; break; }
                }//for                             

            }
        }//func
开发者ID:NightmareX1337,项目名称:lfs,代码行数:59,代码来源:wReplace.xaml.cs

示例2: HighlightText

 public static void HighlightText(TextEditor te, int nl)
 {
     DocumentLine dl = te.Document.GetLineByNumber(nl);
     te.UpdateLayout();
     te.Select(dl.Offset, dl.Length);
     te.ScrollToLine(nl);
 }
开发者ID:NightmareX1337,项目名称:lfs,代码行数:7,代码来源:AvalonEdit.cs

示例3: ReplaceAll

        private void ReplaceAll(TextEditor editor)
        {
            if (this.cboReplace.Text == null)
            {
                MessageBox.Show("No Replace Text specified");
            }

            int origPos = editor.CaretOffset;

            if (!this.cboLookIn.SelectedValue.ToString().Equals("Selection"))
            {
                //Check whether the relevant Text is already selected
                if (this.cboFind.Text != null && !this.cboFind.Text.Equals(String.Empty))
                {
                    if (this.cboFind.Text.Equals(editor.SelectedText))
                    {
                        //If it is remove the selection so the FindNext() call will simply find the currently highlighted text
                        editor.SelectionStart = 0;
                        editor.SelectionLength = 0;
                    }
                }
            }

            //Replace All works over the entire document unless there was already a selection present
            int minPos, maxPos;
            bool restoreSelection = false;
            if (editor.SelectionLength > 0 && this.IsScopeSelection)
            {
                restoreSelection = true;
                minPos = editor.SelectionStart - 1;
                maxPos = editor.SelectionStart + editor.SelectionLength;
                editor.CaretOffset = Math.Max(minPos, 0);
            }
            else
            {
                minPos = -1;
                maxPos = editor.Text.Length;
                editor.CaretOffset = 0;
            }
            editor.SelectionStart = 0;
            editor.SelectionLength = 0;

            editor.Document.BeginUpdate();
            String replace = this.cboReplace.Text;
            while (this.FindNext(editor, minPos, maxPos))
            {
                int diff = replace.Length - editor.SelectionLength;

                editor.Document.Replace(editor.SelectionStart, editor.SelectionLength, replace);
                editor.SelectionLength = replace.Length;
                editor.CaretOffset = editor.SelectionStart;

                maxPos += diff;
            }
            editor.Document.EndUpdate();

            editor.CaretOffset = origPos;
            editor.ScrollToLine(editor.Document.GetLineByOffset(origPos).LineNumber);

            if (restoreSelection)
            {
                editor.Select(minPos + 1, maxPos - minPos - 1);
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:64,代码来源:FindReplace.xaml.cs

示例4: ScrollToLine

 public static void ScrollToLine(TextEditor editor, int line)
 {
     var max = Math.Max(1, editor.Document.LineCount);
     line = Math.Min(max, Math.Max(line, 1));
     editor.ScrollToLine(line);
     var offset = editor.Document.GetOffset(line, 0);
     editor.CaretOffset = offset;
 }
开发者ID:nikolalukovic,项目名称:Markdown-Edit,代码行数:8,代码来源:EditorUtilities.cs

示例5: SelectSymbol

        /// <summary>
        /// Selects a Symbol around the current selection (if any) or caret position
        /// </summary>
        /// <param name="editor">Text Editor</param>
        public void SelectSymbol(TextEditor editor)
        {
            int selStart, selLength;

            if (editor.SelectionStart >= 0 && editor.SelectionLength > 0)
            {
                selStart = editor.SelectionStart;
                selLength = editor.SelectionLength;
            }
            else
            {
                selStart = editor.CaretOffset;
                selLength = 0;
            }

            //If there is an existing Selection and deliminators are not included
            //check whether the preceding and following characters are deiliminators and if so
            //alter the selection start and length appropriately to include these otherwise our
            //select won't select the surrounding symbol properly
            if (selStart > 0 && selLength > 0 && !this._includeDelim)
            {
                if (this.IsStartingDeliminator(editor.Document.GetCharAt(selStart-1)))
                {
                    selStart--;
                    selLength++;
                }
                if (selStart + selLength < editor.Document.TextLength - 1)
                {
                    if (this.IsEndingDeliminator(editor.Document.GetCharAt(selStart + selLength))) selLength++;
                }
            }

            char? endDelim = null;

            //Extend the selection backwards
            while (selStart >= 0)
            {
                selStart--;
                selLength++;

                //Start of Document is always a Boundary
                if (selStart == 0) break;

                //Otherwise check if character at start of selection is a boundary
                char current = editor.Document.GetCharAt(selStart);
                if (this.IsStartingDeliminator(current))
                {
                    endDelim = this.RequireMatchingDeliminator(current);
                    break;
                }
            }
            if (!this._includeDelim)
            {
                if (selStart > 0 || this.IsStartingDeliminator(editor.Document.GetCharAt(selStart)))
                {
                    selStart++;
                    selLength--;
                }
            }

            //Extend the selection forwards
            while (selStart + selLength < editor.Document.TextLength)
            {
                selLength++;

                //End of Document is always a Boundary
                if (selStart + selLength == editor.Document.TextLength) break;

                //Otherwise check if character after end of selection is a boundary
                char current = editor.Document.GetCharAt(selStart + selLength);
                if (endDelim != null )
                {
                    //If a matching End Deliminator is required then stop when that is reached
                    if (endDelim == current) break;
                }
                else if (this.IsEndingDeliminator(current))
                {
                    //Otherwise stop when any End Deliminator is found
                    break;
                }
            }
            if (this._includeDelim)
            {
                selLength++;
            }

            //Select the Symbol Text
            editor.Select(selStart, selLength);
            editor.ScrollToLine(editor.Document.GetLineByOffset(selStart).LineNumber);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:94,代码来源:BaseSelector.cs

示例6: ScrollToOffset

 public static void ScrollToOffset(TextEditor editor, int offset)
 {
     var line = editor.Document.GetLineByOffset(offset);
     if (line == null) return;
     editor.ScrollToLine(line.LineNumber);
     editor.CaretOffset = offset;
 }
开发者ID:jhorv,项目名称:Markdown-Edit,代码行数:7,代码来源:EditorUtilities.cs


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