Exemplo n.º 1
0
        private string getDocumentText(Document document)
        {
            if (document == null) return null;

            var textDocument = (TextDocument)document.Object("TextDocument");
            EditPoint editPoint = textDocument.StartPoint.CreateEditPoint();
            var content = editPoint.GetText(textDocument.EndPoint);
            return content;
        }
    private TextDocument GetTextDocument(Document doc) {
        if (doc == null || doc.ReadOnly) {
            return null;
        }

        var textDoc = doc.Object("TextDocument") as TextDocument;

        return textDoc;
    }
Exemplo n.º 3
0
 public DocumentReader(Document document)
 {
     this.document = document;
     TextDocument textDocument = (TextDocument)document.Object("TextDocument");
     EditPoint editPoint = textDocument.StartPoint.CreateEditPoint();
     editPoint.StartOfDocument();
     strDocument = editPoint.GetText(textDocument.EndPoint);
     documentIndex = -1;
     SetTabSize();
 }
Exemplo n.º 4
0
        private void InsertTemplate(Document document, string toInsert)
        {
            var textDocument = document.Object() as TextDocument;

            textDocument.StartPoint.CreateEditPoint();
            textDocument.Selection.Insert(toInsert);
        }
 //Nice clean methods avoiding slow selection-editing, from online post at:
 //  http://www.visualstudiodev.com/visual-studio-extensibility/how-can-i-edit-documents-programatically-22319.shtml
 private static string SelectAllCodeFromDocument(Document targetDoc)
 {
     string outText = "";
     TextDocument textDoc = targetDoc.Object("TextDocument") as TextDocument;
     if (textDoc != null)
         outText = textDoc.StartPoint.CreateEditPoint().GetText(textDoc.EndPoint);
     return outText;
 }
 private static void ReplaceAllCodeInDocument(Document targetDoc, string newText)
 {
     TextDocument textDoc = targetDoc.Object("TextDocument") as TextDocument;
     if (textDoc != null)
     {
         textDoc.StartPoint.CreateEditPoint().Delete(textDoc.EndPoint);
         textDoc.StartPoint.CreateEditPoint().Insert(newText);
     }
 }
 private static void ReplaceAllCodeInDocument(Document targetDoc, string newText)
 {
     TextDocument textDoc = targetDoc.Object("TextDocument") as TextDocument;
     if (textDoc != null)
     {
         textDoc.StartPoint.CreateEditPoint().ReplaceText(textDoc.EndPoint, newText, (int)vsEPReplaceTextOptions.vsEPReplaceTextKeepMarkers);
     }
 }
Exemplo n.º 8
0
 public static TextDocument GetTextDocument(Document doc)
 {
     return doc.Object("TextDocument") as TextDocument;
 }