static TextLocation FindMethodStart(ICSharpCode.TextEditor.Document.IDocument document, DomRegion bodyRegion)
        {
            if (bodyRegion.IsEmpty)
            {
                return(TextLocation.Empty);
            }
            int offset = document.PositionToOffset(new TextLocation(bodyRegion.BeginColumn - 1, bodyRegion.BeginLine - 1));

            while (offset < document.TextLength)
            {
                if (document.GetCharAt(offset) == '{')
                {
                    return(document.OffsetToPosition(offset + 1));
                }
                offset++;
            }
            return(TextLocation.Empty);
        }
Ejemplo n.º 2
0
        internal static void SelectText(ICSharpCode.TextEditor.TextEditorControl Editor, string Text)
        {
            int offset    = Editor.Text.IndexOf(Text);
            int endOffset = offset + Text.Length;

            Editor.ActiveTextAreaControl.TextArea.Caret.Position = Editor.ActiveTextAreaControl.TextArea.Document.OffsetToPosition(endOffset);
            Editor.ActiveTextAreaControl.TextArea.SelectionManager.ClearSelection();
            ICSharpCode.TextEditor.Document.IDocument        document  = Editor.ActiveTextAreaControl.TextArea.Document;
            ICSharpCode.TextEditor.Document.DefaultSelection selection = new ICSharpCode.TextEditor.Document.DefaultSelection(document, document.OffsetToPosition(offset), document.OffsetToPosition(endOffset));
            Editor.ActiveTextAreaControl.TextArea.SelectionManager.SetSelection(selection);
        }