/// <summary> /// Initializes a singleton instance of this event listener. /// </summary> /// <param name="package">The hosting package.</param> /// <returns>A task.</returns> public static async Task InitializeAsync(CodeMaidPackage package) { Instance = new BuildProgressEventListener(package); await package.SettingsMonitor.WatchAsync(s => s.Feature_BuildProgressToolWindow, Instance.SwitchAsync); }
/// <summary> /// Register the package event listeners. /// </summary> /// <remarks> /// This must occur after the DTE service is available since many of the events are based /// off of the DTE object. /// </remarks> private void RegisterNonShellEventListeners() { // Create event listeners and register for events. var menuCommandService = MenuCommandService; if (menuCommandService != null) { var buildProgressToolWindowCommand = _commands.OfType<BuildProgressToolWindowCommand>().First(); var cleanupActiveCodeCommand = _commands.OfType<CleanupActiveCodeCommand>().First(); var collapseAllSolutionExplorerCommand = _commands.OfType<CollapseAllSolutionExplorerCommand>().First(); var spadeToolWindowCommand = _commands.OfType<SpadeToolWindowCommand>().First(); var codeModelManager = CodeModelManager.GetInstance(this); var settingsContextHelper = SettingsContextHelper.GetInstance(this); BuildProgressEventListener = new BuildProgressEventListener(this); BuildProgressEventListener.BuildBegin += buildProgressToolWindowCommand.OnBuildBegin; BuildProgressEventListener.BuildProjConfigBegin += buildProgressToolWindowCommand.OnBuildProjConfigBegin; BuildProgressEventListener.BuildProjConfigDone += buildProgressToolWindowCommand.OnBuildProjConfigDone; BuildProgressEventListener.BuildDone += buildProgressToolWindowCommand.OnBuildDone; DocumentEventListener = new DocumentEventListener(this); DocumentEventListener.OnDocumentClosing += codeModelManager.OnDocumentClosing; RunningDocumentTableEventListener = new RunningDocumentTableEventListener(this); RunningDocumentTableEventListener.BeforeSave += cleanupActiveCodeCommand.OnBeforeDocumentSave; RunningDocumentTableEventListener.AfterSave += spadeToolWindowCommand.OnAfterDocumentSave; SolutionEventListener = new SolutionEventListener(this); SolutionEventListener.OnSolutionOpened += collapseAllSolutionExplorerCommand.OnSolutionOpened; SolutionEventListener.OnSolutionOpened += settingsContextHelper.OnSolutionOpened; SolutionEventListener.OnSolutionClosed += settingsContextHelper.OnSolutionClosed; SolutionEventListener.OnSolutionClosed += OnSolutionClosedShowStartPage; // Check if a solution has already been opened before CodeMaid was initialized. if (IDE.Solution != null && IDE.Solution.IsOpen) { collapseAllSolutionExplorerCommand.OnSolutionOpened(); } TextEditorEventListener = new TextEditorEventListener(this); TextEditorEventListener.OnLineChanged += codeModelManager.OnDocumentChanged; WindowEventListener = new WindowEventListener(this); WindowEventListener.OnWindowChange += spadeToolWindowCommand.OnWindowChange; } }
public static void Intialize(CodeMaidPackage package) => Instance = new BuildProgressEventListener(package);