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); }
//NOTE: these two methods need to be moved to the ascx_SourceCodeEditor control public void showInSourceCode(Object sender, TreeViewEventArgs e) { var treeNoteTag = e.Node.Tag; // temp Hack to handle the fact that AstValue<obTject> is current using AstValue<object> var endLocation = (ICSharpCode.NRefactory.Location)O2.Kernel.PublicDI.reflection.getProperty("EndLocation", treeNoteTag); var startLocation = (ICSharpCode.NRefactory.Location)O2.Kernel.PublicDI.reflection.getProperty("StartLocation", treeNoteTag); var originalObject = O2.Kernel.PublicDI.reflection.getProperty("OriginalObject", treeNoteTag); var text = (string)O2.Kernel.PublicDI.reflection.getProperty("Text", treeNoteTag); var astValue = new AstValue <object>(text, originalObject, startLocation, endLocation); //if (treeNoteTag is AstValue<object>) //{ //var astValue = (AstValue<object>)treeNoteTag; var textEditorControl = sourceCodeEditor.getObject_TextEditorControl(); var start = new ICSharpCode.TextEditor.TextLocation(astValue.StartLocation.X - 1, astValue.StartLocation.Y - 1); var end = new ICSharpCode.TextEditor.TextLocation(astValue.EndLocation.X - 1, astValue.EndLocation.Y - 1); var selection = new ICSharpCode.TextEditor.Document.DefaultSelection(textEditorControl.Document, start, end); textEditorControl.ActiveTextAreaControl.SelectionManager.SetSelection(selection); setCaretToCurrentSelection(textEditorControl); //} }
//NOTE: these two methods need to be moved to the ascx_SourceCodeEditor control public void showInSourceCode(Object sender, TreeViewEventArgs e) { var treeNoteTag = e.Node.Tag; // temp Hack to handle the fact that AstValue<obTject> is current using AstValue<object> var endLocation = (ICSharpCode.NRefactory.Location)O2.Kernel.PublicDI.reflection.getProperty("EndLocation",treeNoteTag); var startLocation = (ICSharpCode.NRefactory.Location)O2.Kernel.PublicDI.reflection.getProperty("StartLocation", treeNoteTag); var originalObject = O2.Kernel.PublicDI.reflection.getProperty("OriginalObject", treeNoteTag); var text = (string)O2.Kernel.PublicDI.reflection.getProperty("Text", treeNoteTag); var astValue = new AstValue<object>(text,originalObject,startLocation,endLocation); //if (treeNoteTag is AstValue<object>) //{ //var astValue = (AstValue<object>)treeNoteTag; var textEditorControl = sourceCodeEditor.getObject_TextEditorControl(); var start = new ICSharpCode.TextEditor.TextLocation(astValue.StartLocation.X - 1, astValue.StartLocation.Y - 1); var end = new ICSharpCode.TextEditor.TextLocation(astValue.EndLocation.X - 1, astValue.EndLocation.Y - 1); var selection = new ICSharpCode.TextEditor.Document.DefaultSelection(textEditorControl.Document, start, end); textEditorControl.ActiveTextAreaControl.SelectionManager.SetSelection(selection); setCaretToCurrentSelection(textEditorControl); //} }