/// <summary> /// Get a list of all files in the Running Docuement Table. /// </summary> /// <returns></returns> public List <string> GetRDTFiles() { List <string> list = new List <string>(); IEnumRunningDocuments documents; if (DocumentTable != null) { DocumentTable.GetRunningDocumentsEnum(out documents); uint[] docCookie = new uint[1]; uint fetched; while ((VSConstants.S_OK == documents.Next(1, docCookie, out fetched)) && (1 == fetched)) { uint flags; uint editLocks; uint readLocks; string moniker; IVsHierarchy docHierarchy; uint docId; IntPtr docData = IntPtr.Zero; DocumentTable.GetDocumentInfo(docCookie[0], out flags, out readLocks, out editLocks, out moniker, out docHierarchy, out docId, out docData); list.Add(moniker); } } return(list); }
public int OnBeforeSave(uint docCookie) { uint flags, readlocks, editlocks; string name; IVsHierarchy hier; uint itemid; IntPtr docData; m_RDT.GetDocumentInfo(docCookie, out flags, out readlocks, out editlocks, out name, out hier, out itemid, out docData); string projectPath = ""; try { var project = GetProject(hier); if (project != null) { // Set so rel path will be C:\path\SolutionDir\ProjectDir\project.csproj => ProjectDir\ projectPath = Path.GetDirectoryName(Path.GetDirectoryName(project.FullName)); } } catch (Exception ex) { } HandleSave(name, "pre save", projectPath); return(VSConstants.S_OK); }
public int OnBeforeSave(uint docCookie) { uint flags, readlocks, editlocks; string name; IVsHierarchy hier; uint itemid; IntPtr docData; m_RDT.GetDocumentInfo(docCookie, out flags, out readlocks, out editlocks, out name, out hier, out itemid, out docData); SessionHandler.MarkActivity(); // Should this only be done first time document is made? Or is just good practice since there can be other external changes...merging, refactoring... HandleSave(name); return(VSConstants.S_OK); }
public int OnAfterSave(uint docCookie) { uint pgrfRDTFlags, pdwReadLocks, pdwEditLocks, pitemid, e; IVsHierarchy ppHier; IntPtr ppunkDocData; string fullDocumentName; // Get document name m_IVsRunningDocumentTable.GetDocumentInfo( docCookie, out pgrfRDTFlags, out pdwReadLocks, out pdwEditLocks, out fullDocumentName, out ppHier, out pitemid, out ppunkDocData); if (fullDocumentName.EndsWith(@"vcxproj.filters")) { VCXFilterSorter.Sort(fullDocumentName); } return(VSConstants.S_OK); }
private void OnOpenDocument(uint docCookie) { if (rdt != null) { uint flags; uint readLocks; uint editLocks; string fileName; IVsHierarchy hier; uint itemId; IntPtr docData; int hr = rdt.GetDocumentInfo(docCookie, out flags, out readLocks, out editLocks , out fileName, out hier, out itemId, out docData); if (hr == 0 && !docData.Equals(IntPtr.Zero)) { IVsTextLines textLines = System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(docData) as IVsTextLines; if (textLines != null) { foreach (Task t in tasks) { t.OnOpenDocument(hier, itemId, fileName, textLines); } } } } }
public int OnAfterFirstDocumentLock(uint docCookie, uint dwRDTLockType, uint dwReadLocksRemaining, uint dwEditLocksRemaining) { // Common.Trace(string.Format("OnAfterFirstDocumentLock: {0} - {1} - {2} ", dwRDTLockType, dwReadLocksRemaining, dwEditLocksRemaining )); if (rdt != null && dwReadLocksRemaining == 1 && dwEditLocksRemaining == 1) { uint flags; uint readLocks; uint editLocks; string fileName; IVsHierarchy hier; uint itemId; IntPtr docData; int hr = rdt.GetDocumentInfo(docCookie, out flags, out readLocks, out editLocks , out fileName, out hier, out itemId, out docData); if (hr == 0 && !docData.Equals(IntPtr.Zero)) { IVsTextLines textLines = System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(docData) as IVsTextLines; if (textLines != null) { foreach (Task t in tasks) { t.OnOpenDocument(hier, itemId, fileName, textLines); } } } } return(0); }
public int OnAfterAttributeChange(uint docCookie, uint grfAttribs) { if ((grfAttribs & (uint)(__VSRDTATTRIB.RDTA_MkDocument)) == (uint)__VSRDTATTRIB.RDTA_MkDocument) { IVsRunningDocumentTable rdt = GetPackageService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; if (rdt != null) { uint flags, readLocks, editLocks, itemid; IVsHierarchy hier; IntPtr docData = IntPtr.Zero; string moniker; int hr; try { hr = rdt.GetDocumentInfo(docCookie, out flags, out readLocks, out editLocks, out moniker, out hier, out itemid, out docData); TextLineEventListener listner; if (_documents.TryGetValue(docCookie, out listner)) { listner.FileName = moniker; } } finally { if (IntPtr.Zero != docData) { Marshal.Release(docData); } } } } return(VSConstants.S_OK); }
public int OnAfterSave(uint docCookie) { uint pgrfRDTFlags, pdwReadLocks, pdwEditLocks, pitemid; IVsHierarchy ppHier; IntPtr ppunkDocData; string fullDocumentName; // Get document name m_IVsRunningDocumentTable.GetDocumentInfo( docCookie, out pgrfRDTFlags, out pdwReadLocks, out pdwEditLocks, out fullDocumentName, out ppHier, out pitemid, out ppunkDocData); //Sort only the sqlProj if (fullDocumentName.EndsWith(@"sqlproj")) { SqlProjSorter.Sort(fullDocumentName); } //Sort edmx files if (fullDocumentName.EndsWith(@"edmx")) { EdmxSorter.Sort(fullDocumentName); } return(VSConstants.S_OK); }
public int OnAfterAttributeChange(uint docCookie, uint grfAttribs) { if (rdt != null && grfAttribs != (uint)__VSRDTATTRIB.RDTA_DocDataIsNotDirty && grfAttribs != (uint)__VSRDTATTRIB.RDTA_DocDataReloaded) { return(VSConstants.S_OK); } uint docFlags; uint readLocks; uint writeLocks; string docPath; IVsHierarchy hier; uint nodeId; IntPtr docData; ErrorHandler.ThrowOnFailure(rdt.GetDocumentInfo(docCookie, out docFlags, out readLocks, out writeLocks, out docPath, out hier, out nodeId, out docData)); object projectAO; ErrorHandler.ThrowOnFailure(hier.GetProperty((uint)VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out projectAO)); OAProject project = projectAO as OAProject; if (project == null) { return(VSConstants.S_OK); } ((RustProjectNode)project.Project).OnNodeDirty(nodeId); return(VSConstants.S_OK); }
public int OnBeforeDocumentWindowShow(uint docCookie, int fFirstShow, IVsWindowFrame pFrame) { // We want to make sure that we are not 'stealing' vulcans files // so we check for a vulcan file before opening the window // when it one of our files then we register the XFile object in the XSolution, // when it is an orphaned file then it is registered in the OrphanedFiles Project if (fFirstShow != 0) { if (knownCookies.Contains(docCookie)) { return(VSConstants.S_OK); } knownCookies.Add(docCookie); if (null != rdt) { // Note that here we don't want to throw in case of error. uint flags; uint readLocks; uint writeLoks; string documentMoniker; IVsHierarchy hierarchy; uint itemId; IntPtr unkDocData; int hr = rdt.GetDocumentInfo(docCookie, out flags, out readLocks, out writeLoks, out documentMoniker, out hierarchy, out itemId, out unkDocData); // check to see if this is one our files. VsTextViewCreationListener.IsOurSourceFile(documentMoniker); } } return(VSConstants.S_OK); }
public int OnAfterSave(uint docCookie) { IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)this.GetService(typeof(SVsRunningDocumentTable)); uint pgrfRDTFlags; uint pdwReadLocks; uint pdwEditLocks; string pbstrMkDocument; IVsHierarchy ppHier; uint pitemid; IntPtr ppunkDocData; rdt.GetDocumentInfo( docCookie, out pgrfRDTFlags, out pdwReadLocks, out pdwEditLocks, out pbstrMkDocument, out ppHier, out pitemid, out ppunkDocData); EnvDTE.DTE dte = (DTE)this.GetService(typeof(DTE)); ProjectItem prjItem = dte.Solution.FindProjectItem(pbstrMkDocument); if (prjItem != null) { OnDocumentSaved(prjItem.Document); } return(VSConstants.S_OK); }
/// <summary> /// private string GetDocumentName(uint docCookie, IVsWindowFrame pFrame) { string documentName = null; IVsRunningDocumentTable runningDocTable = SdkUiUtilities.GetService <SVsRunningDocumentTable, IVsRunningDocumentTable>(ServiceProvider); if (runningDocTable != null) { uint grfRDTFlags; uint dwReadLocks; uint dwEditLocks; IVsHierarchy pHier; uint itemId; IntPtr docData = IntPtr.Zero; try { int hr = runningDocTable.GetDocumentInfo(docCookie, out grfRDTFlags, out dwReadLocks, out dwEditLocks, out documentName, out pHier, out itemId, out docData); } finally { if (docData != IntPtr.Zero) { Marshal.Release(docData); } } } return(documentName); }
private Document FindDocumentByCookie(uint docCookie) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); var documentInfo = _rdt.GetDocumentInfo(docCookie, out uint p1, out uint p2, out uint p3, out string p4, out IVsHierarchy p5, out uint p6, out IntPtr p7); return(_dte.Documents.Cast <Document>().FirstOrDefault(doc => doc.FullName == p4)); }
private string getFileNameFromCookie(uint docCookie) { IVsRunningDocumentTable rdt = provider.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; string fileName = ""; if (rdt != null) { IntPtr docData = IntPtr.Zero; try { int hr; IVsHierarchy hier; uint flags, readLocks, editLocks, itemid; hr = rdt.GetDocumentInfo(docCookie, out flags, out readLocks, out editLocks, out fileName, out hier, out itemid, out docData); if (hierarchies.ContainsKey(hier)) { } } finally { if (IntPtr.Zero != docData) { Marshal.Release(docData); } } } return(fileName); }
private string GetDocumentFilePath(uint docCookie) { var hr = _docTable.GetDocumentInfo( docCookie, out _, out _, out _, out string docFilePath, out _, out _, out IntPtr ppunkDocData ); if (ErrorHandler.Succeeded(hr)) { if (ppunkDocData != IntPtr.Zero) { Marshal.Release(ppunkDocData); } return(docFilePath); } return(null); }
/// <summary> /// Find the document and return its cookie to the lock to the document. /// </summary> /// <param name="runningDocTable">The object having a table of all running documents.</param> /// <param name="file">The file to be looked in the documents table.</param> /// <returns>The cookie to the document lock.</returns> internal static uint FindDocument(IVsRunningDocumentTable runningDocTable, string file) { ThreadHelper.ThrowIfNotOnUIThread(); // Unused variables IVsHierarchy hierarchy; uint itemId; IntPtr docData = IntPtr.Zero; uint cookieDocLock; int hr = runningDocTable.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, file, out hierarchy, out itemId, out docData, out cookieDocLock); // Although we don't use it, we still need to release the it if (docData != IntPtr.Zero) { Marshal.Release(docData); docData = IntPtr.Zero; } if (ErrorHandler.Failed(hr)) { throw Marshal.GetExceptionForHR(hr); } if (cookieDocLock > 0) { // Document is already open uint rdtFlags; // Unused variables uint readLocks; uint editLocks; string documentName; hr = runningDocTable.GetDocumentInfo(cookieDocLock, out rdtFlags, out readLocks, out editLocks, out documentName, out hierarchy, out itemId, out docData); // Although we don't use it, we still need to release the it if (docData != IntPtr.Zero) { Marshal.Release(docData); docData = IntPtr.Zero; } if (ErrorHandler.Failed(hr)) { throw Marshal.GetExceptionForHR(hr); } if ((rdtFlags & ((uint)_VSRDTFLAGS.RDT_ProjSlnDocument)) > 0) { throw Marshal.GetExceptionForHR(VSConstants.E_FAIL); } } return(cookieDocLock); }
/// <summary> /// When this event is triggered on a project item, a copy of the file is saved to the /// <see cref="documentRepository" />. /// </summary> public override int OnBeforeSave(uint docCookie) { LocalHistoryPackage.Log($"Entering {nameof(OnBeforeSave)}() on {nameof(LocalHistoryDocumentListener)}"); uint pgrfRDTFlags; uint pdwReadLocks; uint pdwEditLocks; string pbstrMkDocument; IVsHierarchy ppHier; uint pitemid; IntPtr ppunkDocData; documentTable.GetDocumentInfo( docCookie, out pgrfRDTFlags, out pdwReadLocks, out pdwEditLocks, out pbstrMkDocument, out ppHier, out pitemid, out ppunkDocData); var filePath = Utils.NormalizePath(pbstrMkDocument); if (LocalHistoryPackage.Instance.OptionsPage.CreateRevisionOnlyIfDirty) { if (!_dirtyDocCookie.Contains(docCookie)) { LocalHistoryPackage.Log($"File \"{filePath}\" is not dirty. Will not create version."); return(VSConstants.S_OK); } _dirtyDocCookie.Remove(docCookie); } LocalHistoryPackage.Log($"Creating version for file \"{filePath}\" (is dirty)."); var revNode = documentRepository.CreateRevision(filePath); var content = LocalHistoryPackage.Instance.ToolWindow?.Content as LocalHistoryControl; //only insert if this revision is different from all the others //otherwise we would be inserting duplicates in the list //remember that DocumentNode has its own GetHashCode ObservableCollection <DocumentNode> items = content?.DocumentItems; if (revNode != null && items?.Contains(revNode) == false) { LocalHistoryPackage.Log($"Adding file \"{filePath}\" to list."); items.Insert(0, revNode); LocalHistoryPackage.Instance.UpdateToolWindow("", true); return(VSConstants.S_OK); } LocalHistoryPackage.Log($"File \"{filePath}\" is already in list. Doing nothing."); return(VSConstants.S_OK); }
private (string document, IntPtr documentData) GetDocumentInfo(uint docCookie) { ThreadHelper.ThrowIfNotOnUIThread(); string pbstrMkDocument = string.Empty; _iVsRunningDocumentTable.GetDocumentInfo(docCookie, out uint pgrfRdtFlags, out uint pdwReadLocks, out uint pdwEditLocks, out pbstrMkDocument, out IVsHierarchy ppHier, out uint pitemid, out IntPtr ppunkDocData); return(document : pbstrMkDocument, documentData : ppunkDocData); }
public static IVsHierarchy GetHierarchyFromCookie(this IVsRunningDocumentTable rdt, uint docCookie) { uint flags, readlocks, editlocks; string name; IVsHierarchy hier; uint itemid; IntPtr docData; rdt.GetDocumentInfo(docCookie, out flags, out readlocks, out editlocks, out name, out hier, out itemid, out docData); return(hier); }
private IntPtr FindDocDataFromRDT() { // Get a reference to the RDT. IVsRunningDocumentTable rdt = Package.GetGlobalService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable; if (null == rdt) { return(IntPtr.Zero); } // Get the enumeration of the running documents. IEnumRunningDocuments documents; ErrorHandler.ThrowOnFailure(rdt.GetRunningDocumentsEnum(out documents)); IntPtr documentData = IntPtr.Zero; uint[] docCookie = new uint[1]; uint fetched; while ((VSConstants.S_OK == documents.Next(1, docCookie, out fetched)) && (1 == fetched)) { uint flags; uint editLocks; uint readLocks; string moniker; IVsHierarchy docHierarchy; uint docId; IntPtr docData = IntPtr.Zero; try { ErrorHandler.ThrowOnFailure( rdt.GetDocumentInfo(docCookie[0], out flags, out readLocks, out editLocks, out moniker, out docHierarchy, out docId, out docData)); // Check if this document is the one we are looking for. if ((docId == fileId) && (ownerHierarchy.Equals(docHierarchy))) { documentData = docData; docData = IntPtr.Zero; break; } } finally { if (IntPtr.Zero != docData) { Marshal.Release(docData); } } } return(documentData); }
public int OnBeforeSave(uint docCookie) { ThreadHelper.ThrowIfNotOnUIThread(); // S_OK on success, error code on error rdt.GetDocumentInfo(docCookie, out uint flags, out uint readlocks, out uint editlocks, out string name, out IVsHierarchy hier, out uint itemid, out IntPtr docData); Document document = dte.Documents.OfType <Document>().FirstOrDefault(x => x.FullName == name); FormatDocument(document, true); return(VSConstants.S_OK); }
public int OnBeforeSave(uint docCookie) { ThreadHelper.ThrowIfNotOnUIThread(); try { string documentPath = GetDocumentInfos(); string GetDocumentInfos() { runningDocumentTable.GetDocumentInfo(docCookie, out uint pgfFlags, out uint pdwReadLocks, out uint pdfEditLocks, out string pbstrMkDocument, out IVsHierarchy ppHier, out uint pitemid, out IntPtr ppunkDocData); return(pbstrMkDocument); } DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE; ProjectItem projectItem = dte.Solution.FindProjectItem(documentPath); Project project = projectItem.ContainingProject; VCProject p = project.Object as VCProject; VCConfiguration configuration = p.ActiveConfiguration; IVCRulePropertyStorage plcnextRule = configuration.Rules.Item("PLCnextCommonProperties"); string projectType = plcnextRule.GetUnevaluatedPropertyValue("ProjectType_"); if (!string.IsNullOrEmpty(projectType)) { string name = Path.GetFileName(documentPath); if (name.Equals(fileName)) { if (optionPage.AskIncludesUpdate) { UpdateIncludesViewModel viewModel = new UpdateIncludesViewModel(p.Name); UpdateIncludesDialogView view = new UpdateIncludesDialogView(viewModel); bool result = (bool)view.ShowModal(); optionPage.UpdateIncludes = result; if (viewModel.RememberDecision) { optionPage.AskIncludesUpdate = false; } } if (optionPage.UpdateIncludes) { UpdateIncludesOnBeforeSave(p, p.ProjectDirectory); } } return(VSConstants.S_OK); } } catch (NullReferenceException) { //do nothing } return(VSConstants.S_OK); }
/// <summary> /// Iterate all loaded documents of the given <typeparam name="DocumentType"/> /// </summary> public static IEnumerable <DocumentType> GetLoadedDocuments <DocumentType>(IServiceProvider serviceProvider) where DocumentType : class { // Walk all the documents and invalidate ORM diagrams if the options have changed IVsRunningDocumentTable docTable = (IVsRunningDocumentTable)serviceProvider.GetService(typeof(IVsRunningDocumentTable)); IEnumRunningDocuments docIter; ErrorHandler.ThrowOnFailure(docTable.GetRunningDocumentsEnum(out docIter)); int hrIter; uint[] currentDocs = new uint[1]; uint fetched = 0; do { ErrorHandler.ThrowOnFailure(hrIter = docIter.Next(1, currentDocs, out fetched)); if (hrIter == 0) { uint grfRDTFlags; uint dwReadLocks; uint dwEditLocks; string bstrMkDocument; IVsHierarchy pHier; uint itemId; IntPtr punkDocData = IntPtr.Zero; ErrorHandler.ThrowOnFailure(docTable.GetDocumentInfo( currentDocs[0], out grfRDTFlags, out dwReadLocks, out dwEditLocks, out bstrMkDocument, out pHier, out itemId, out punkDocData)); try { DocumentType docData = Marshal.GetObjectForIUnknown(punkDocData) as DocumentType; if (docData != null) { yield return(docData); } } finally { if (punkDocData != IntPtr.Zero) { Marshal.Release(punkDocData); } } } } while (fetched != 0); }
public static string GetMonikerForHierarchyAndItemId(this IVsRunningDocumentTable runningDocTable, IVsHierarchy hierarchy, uint itemid) { if (runningDocTable == null) { throw new ArgumentNullException("runningDocTable"); } if (hierarchy == null) { throw new ArgumentNullException("hierarchy"); } // First, get the doc cookie for this IEnumRunningDocuments runningDocsEnum; Marshal.ThrowExceptionForHR(runningDocTable.GetRunningDocumentsEnum(out runningDocsEnum)); var cookies = new uint[1]; uint cookiesFetched; while (runningDocsEnum.Next(1, cookies, out cookiesFetched) == VSConstants.S_OK && cookiesFetched == 1) { uint documentFlags; uint documentReadLocks; uint documentEditLocks; string documentId; IVsHierarchy documentHierarchy; uint documentItemID; IntPtr pDocData; Marshal.ThrowExceptionForHR(runningDocTable.GetDocumentInfo(cookies[0], out documentFlags, out documentReadLocks, out documentEditLocks, out documentId, out documentHierarchy, out documentItemID, out pDocData)); try { if (documentHierarchy == hierarchy && documentItemID == itemid) { return(documentId); } } finally { Marshal.Release(pDocData); } } // Uh, OK, that's probably not good that we're supposedly an open file but not in the RDT. We'll fall back // to the IVsHierarchy's name property for this item. object property; Marshal.ThrowExceptionForHR(hierarchy.GetProperty(itemid, (int)__VSHPROPID.VSHPROPID_Name, out property)); return((string)property); }
public int OnAfterSave(uint docCookie) { uint flags, readlocks, editlocks; string name; IVsHierarchy hier; uint itemid; IntPtr docData; runningDocumentTable.GetDocumentInfo(docCookie, out flags, out readlocks, out editlocks, out name, out hier, out itemid, out docData); TriggerFileChanged(name); return(VSConstants.S_OK); }
/// <summary> /// 关闭一个已经打开的文档 /// </summary> /// <param name="name">文档路径(包含文件后缀)</param> /// <param name="saveOption">制定如何关闭一个文档,默认为强制保存后关闭</param> public static void CloseDocument(string name, __VSSLNSAVEOPTIONS saveOption = __VSSLNSAVEOPTIONS.SLNSAVEOPT_ForceSave) { IVsRunningDocumentTable runningTabs = RunningDocumentTableObject; IVsSolution solution = VSSolution.SolutionObject; if (runningTabs != null) { IEnumRunningDocuments runningDocuments; runningTabs.GetRunningDocumentsEnum(out runningDocuments); IntPtr documentData = IntPtr.Zero; uint[] docCookie = new uint[1]; uint fetched; //遍历所有已经打开的文档 while ((VSConstants.S_OK == runningDocuments.Next(1, docCookie, out fetched)) && (fetched == 1)) { uint flags; uint editLocks; uint readLocks; string filePath; IVsHierarchy docHierarchy; uint docId; IntPtr docData = IntPtr.Zero; try { ErrorHandler.ThrowOnFailure(runningTabs.GetDocumentInfo(docCookie[0], out flags, out readLocks, out editLocks, out filePath, out docHierarchy, out docId, out docData)); if (solution != null && !filePath.EndsWith("sln") && !filePath.EndsWith("csproj")) { //string currentName = filePath.Substring(filePath.LastIndexOf("\\") + 1); if (name == filePath) { solution.CloseSolutionElement((uint)saveOption, docHierarchy, docCookie[0]); } } } finally { if (docData != IntPtr.Zero) { Marshal.Release(docData); } } } } }
public int OnAfterSave(uint docCookie) { uint flags; uint readingLocks; uint edittingLocks; string name; IVsHierarchy hierarchy; uint documentId; IntPtr documentData; _documentTable.GetDocumentInfo(docCookie, out flags, out readingLocks, out edittingLocks, out name, out hierarchy, out documentId, out documentData); OnChanged(this, new TestFileChangedEventArgs(name, TestFileChangedReason.Saved)); return(VSConstants.S_OK); }
/// <summary> /// Update the visual studio document referred to by /// <paramref name="docCookie"/></summary> /// <param name="docCookie">The identifier for the visula studio document</param> /// <returns>The <see cref="VSConstants"/> indicating whether or not the document was /// found</returns> private int UpdateVisualStudioDocument(uint docCookie) { uint flags, readingLocks, editLocks, documentId; string filePath; IVsHierarchy hierarchy; IntPtr documentData; int status = DocumentTable.GetDocumentInfo(docCookie, out flags, out readingLocks, out editLocks, out filePath, out hierarchy, out documentId, out documentData); var archive = GetArchiveForFile(filePath); if (status == VSConstants.S_OK && IsMonitoringFile(filePath) && archive.IsOutdated(filePath)) { UpdateFileAsync(filePath); } return(status); }
protected override void Load(string fileName, bool isReload) { base.Load(fileName, isReload); IVsRunningDocumentTable rdt = this.ServiceProvider.GetService(typeof(IVsRunningDocumentTable)) as IVsRunningDocumentTable; uint a, b, c, d, e, f, g, h; string x; IVsHierarchy pp; System.IntPtr docptr; rdt.GetDocumentInfo(this.Cookie, out a, out b, out c, out x, out pp, out d, out docptr); IVsWindowFrame frame = this.ServiceProvider.GetService(typeof(IVsWindowFrame)) as IVsWindowFrame; if (frame != null) { frame.SetProperty((int)__VSFPROPID.VSFPROPID_EditorCaption, "bloogle"); } }
public int OnAfterSave(uint docCookie) { string filename; uint pgrfRDTFlags, pdwReadLocks, pdwEditLocks; IVsHierarchy ppHier; uint pitemid; IntPtr ppunkDocData; documentService.GetDocumentInfo(docCookie, out pgrfRDTFlags, out pdwReadLocks, out pdwEditLocks, out filename, out ppHier, out pitemid, out ppunkDocData); OnFileSaved(filename); return(VSConstants.S_OK); }
public static IVsHierarchy GetHierarchyFromDocCookie(IVsRunningDocumentTable table, uint cookie) { uint pgrfRDTFlags; uint pdwReadLocks; uint pdwEditLocks; string pbstrMkDocument; IVsHierarchy hierarchy; uint pitemid; IntPtr ppunkDocData; table.GetDocumentInfo( cookie, out pgrfRDTFlags, out pdwReadLocks, out pdwEditLocks, out pbstrMkDocument, out hierarchy, out pitemid, out ppunkDocData ); return hierarchy; }
private static RunningDocumentInfo GetDocumentInfo(IVsRunningDocumentTable rdt, uint docCookie) { RunningDocumentInfo info = new RunningDocumentInfo(); IntPtr docData; int hr = rdt.GetDocumentInfo(docCookie, out info.Flags, out info.ReadLocks, out info.EditLocks, out info.Moniker, out info.Hierarchy, out info.ItemId, out docData); //if (hr == VSConstants.S_OK) //{ // try // { // if (docData != IntPtr.Zero) // info.DocData = Marshal.GetObjectForIUnknown(docData); // return info; // } // finally // { // Marshal.Release(docData); // } //} return info; }