public FilesWithBookmarksFilter( IServiceProvider serviceProvider, IVsHierarchyItemCollectionProvider hierarchyCollectionProvider, BookmarksManager bookmarksManager) { this.svcProvider = serviceProvider; this.hierarchyCollectionProvider = hierarchyCollectionProvider; this.bookmarksManager = bookmarksManager; }
/// <summary> /// Initializes a new instance of the <see cref="SuperBookmarksPackage"/> class. /// </summary> public SuperBookmarksPackage() { // Inside this method you can place any initialization code that does not require // any Visual Studio service because at this point the package object is created but // not sited yet inside Visual Studio environment. The place to do all the other // initialization is the Initialize method. Instance = this; BookmarksManager = new BookmarksManager(this); }
public void SaveBookmarksToDatFile() { if (!StorageOptions.SaveBookmarksToOwnFile) { return; } var info = BookmarksManager.GetSerializableInfo(); using (var stream = File.Create(DataFilePath)) info.SerializeTo(stream, prettyPrint: false); Helpers.WriteToStatusBar($"Saved {Helpers.Quantifier(info.TotalBookmarksCount, "bookmark")} from {Helpers.Quantifier(info.TotalFilesCount, "file")} to .SuperBookmarks.dat file"); }
private void _OnFrameClosed(object sender) { var frame = ((IWindowFrameEventsNotifier)sender).Frame; if (!openDocumentFrames.ContainsKey(frame)) { return; } var document = openDocumentFrames[frame]; if (document.IsTextView) { BookmarksManager.OnTextDocumentClosed(document.Path); } document.FrameEventsNotifier.FrameClosed -= OnFrameClosed; openDocumentFrames.Remove(frame); UpdateOpenDocumentsState(); Helpers.Debug($"Frame Closed: {Path.GetFileName(document.Path)}, isText: {document.IsTextView}, total open: {openDocumentFrames.Count}"); }
private int _OnBeforeDocumentWindowShow(uint docCookie, int fFirstShow, IVsWindowFrame pFrame) { if (openDocumentFrames.Count == 0) { InitializeRunningDocumentsInfo(); } var isFirstShow = fFirstShow != 0; if (isFirstShow && !openDocumentFrames.ContainsKey(pFrame)) { RegisterOpenDocument(docCookie, pFrame); } if (!openDocumentFrames.ContainsKey(pFrame)) { return(VSConstants.S_OK); } if (!isFirstShow && CurrentWindowFrame == pFrame) { return(VSConstants.S_OK); } CurrentWindowFrame = pFrame; var document = openDocumentFrames[pFrame]; BookmarksManager.OnCurrentDocumentChanged(document.Path, document.ProjectRoot); ActiveDocumentIsText = document.IsTextView; ActiveDocumentIsInProject = document.ProjectRoot != null; Helpers.Debug($"Frame Shown: {Path.GetFileName(document.Path)}, isText: {document.IsTextView}, total open: {openDocumentFrames.Count}"); return(VSConstants.S_OK); }
static FilesWithBookmarksFilteredHierarchyItemSet() { BookmarksManager = SuperBookmarksPackage.Instance.BookmarksManager; }
private void RegisterOpenDocument(uint docCookie, IVsWindowFrame frame = null) { if (frame != null && openDocumentFrames.ContainsKey(frame)) { return; } (string documentPath, string projectRoot) = GetRunningDocumentPaths(docCookie); if (documentPath == null) { return; } void RegisterOpenFrame(IVsWindowFrame currentFrame, bool isTextDocument) { var docInfo = new OpenDocumentFrameInfo(documentPath, projectRoot, currentFrame, isTextDocument); if (!openDocumentFrames.ContainsKey(currentFrame)) { openDocumentFrames.Add(currentFrame, docInfo); } docInfo.FrameEventsNotifier.FrameClosed += OnFrameClosed; if (isTextDocument) { BookmarksManager.OnTextDocumentOpen(documentPath); } Helpers.Debug($"Frame Registered: {Path.GetFileName(documentPath)}, isText: {isTextDocument}, total open: {openDocumentFrames.Count}"); } var frameForTextView = GetFrameForTextView(documentPath); var frameForDesignView = GetFrameForDesignerView(documentPath); if (frame == null) { if (frameForTextView != null) { RegisterOpenFrame(frameForTextView, true); } if (frameForDesignView != null) { RegisterOpenFrame(frameForDesignView, false); } } else { if (frameForTextView == frame) { RegisterOpenFrame(frame, true); } else if (frameForDesignView == frame) { RegisterOpenFrame(frame, false); } } UpdateOpenDocumentsState(); }