コード例 #1
0
        /// <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 cleanupActiveCodeCommand = new CleanupActiveCodeCommand(this);

            RunningDocumentTableEventListener             = new RunningDocumentTableEventListener(this);
            RunningDocumentTableEventListener.BeforeSave += cleanupActiveCodeCommand.OnBeforeDocumentSave;
        }
コード例 #2
0
        /// <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)
            {
                RunningDocumentTableEventListener             = new RunningDocumentTableEventListener(this);
                RunningDocumentTableEventListener.BeforeSave += OnBeforeDocumentSave;
            }
        }
コード例 #3
0
ファイル: CodeMaidPackage.cs プロジェクト: zer09/codemaid
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing">
        /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release
        /// only unmanaged resources.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            // Dispose of any event listeners.
            BuildProgressEventListener?.Dispose();
            DocumentEventListener?.Dispose();
            RunningDocumentTableEventListener?.Dispose();
            ShellEventListener?.Dispose();
            SolutionEventListener?.Dispose();
            TextEditorEventListener?.Dispose();
            WindowEventListener?.Dispose();
        }
コード例 #4
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing">
        /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release
        /// only unmanaged resources.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (RunningDocumentTableEventListener != null)
            {
                RunningDocumentTableEventListener.Dispose();
            }

            if (ShellEventListener != null)
            {
                ShellEventListener.Dispose();
            }
        }
コード例 #5
0
ファイル: CodeMaidPackage.cs プロジェクト: zhyifei/codemaid
        /// <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;
            }
        }
コード例 #6
0
ファイル: CodeMaidPackage.cs プロジェクト: zhyifei/codemaid
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing">
        /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release
        /// only unmanaged resources.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            // Dispose of any event listeners.
            if (BuildProgressEventListener != null)
            {
                BuildProgressEventListener.Dispose();
            }

            if (DocumentEventListener != null)
            {
                DocumentEventListener.Dispose();
            }

            if (RunningDocumentTableEventListener != null)
            {
                RunningDocumentTableEventListener.Dispose();
            }

            if (ShellEventListener != null)
            {
                ShellEventListener.Dispose();
            }

            if (SolutionEventListener != null)
            {
                SolutionEventListener.Dispose();
            }

            if (TextEditorEventListener != null)
            {
                TextEditorEventListener.Dispose();
            }

            if (WindowEventListener != null)
            {
                WindowEventListener.Dispose();
            }
        }
        /// <summary>
        /// Register the package event listeners.
        /// </summary>
        /// <remarks>
        /// Every event listener registers VS events by itself.
        /// </remarks>
        private async Task RegisterEventListenersAsync()
        {
            var codeModelManager      = CodeModelManager.GetInstance(this);
            var settingsContextHelper = SettingsContextHelper.GetInstance(this);

            VSColorTheme.ThemeChanged += _ => ThemeManager.ApplyTheme();

            await BuildProgressEventListener.InitializeAsync(this);

            BuildProgressEventListener.Instance.BuildBegin           += BuildProgressToolWindowCommand.Instance.OnBuildBegin;
            BuildProgressEventListener.Instance.BuildProjConfigBegin += BuildProgressToolWindowCommand.Instance.OnBuildProjConfigBegin;
            BuildProgressEventListener.Instance.BuildProjConfigDone  += BuildProgressToolWindowCommand.Instance.OnBuildProjConfigDone;
            BuildProgressEventListener.Instance.BuildDone            += BuildProgressToolWindowCommand.Instance.OnBuildDone;

            await DocumentEventListener.InitializeAsync(this);

            DocumentEventListener.Instance.OnDocumentClosing += codeModelManager.OnDocumentClosing;

            await RunningDocumentTableEventListener.InitializeAsync(this);

            await SettingsMonitor.WatchAsync(s => s.Feature_SettingCleanupOnSave, on =>
            {
                if (on)
                {
                    RunningDocumentTableEventListener.Instance.BeforeSave += CleanupActiveCodeCommand.Instance.OnBeforeDocumentSave;
                }
                else
                {
                    RunningDocumentTableEventListener.Instance.BeforeSave -= CleanupActiveCodeCommand.Instance.OnBeforeDocumentSave;
                }

                return(Task.CompletedTask);
            });

            await SettingsMonitor.WatchAsync(s => s.Feature_SpadeToolWindow, on =>
            {
                if (on)
                {
                    RunningDocumentTableEventListener.Instance.AfterSave += SpadeToolWindowCommand.Instance.OnAfterDocumentSave;
                }
                else
                {
                    RunningDocumentTableEventListener.Instance.AfterSave -= SpadeToolWindowCommand.Instance.OnAfterDocumentSave;
                }

                return(Task.CompletedTask);
            });

            await SolutionEventListener.InitializeAsync(this);

            await SettingsMonitor.WatchAsync(s => s.Feature_CollapseAllSolutionExplorer, on =>
            {
                if (on)
                {
                    SolutionEventListener.Instance.OnSolutionOpened += CollapseAllSolutionExplorerCommand.Instance.OnSolutionOpened;
                }
                else
                {
                    SolutionEventListener.Instance.OnSolutionOpened -= CollapseAllSolutionExplorerCommand.Instance.OnSolutionOpened;
                }

                return(Task.CompletedTask);
            });

            SolutionEventListener.Instance.OnSolutionOpened += settingsContextHelper.OnSolutionOpened;
            SolutionEventListener.Instance.OnSolutionClosed += settingsContextHelper.OnSolutionClosed;
            SolutionEventListener.Instance.OnSolutionClosed += OnSolutionClosedShowStartPage;

            await TextEditorEventListener.InitializeAsync(this);

            TextEditorEventListener.Instance.OnLineChanged += codeModelManager.OnDocumentChanged;

            await WindowEventListener.InitializeAsync(this);

            WindowEventListener.Instance.OnWindowChange += SpadeToolWindowCommand.Instance.OnWindowChange;

            // Check if a solution has already been opened before CodeMaid was initialized.
            if (IDE.Solution?.IsOpen == true)
            {
                SolutionEventListener.Instance.FireSolutionOpenedEvent();
            }
        }
コード例 #8
0
        /// <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 cleanupActiveCodeCommand = new CleanupActiveCodeCommand(this);

            RunningDocumentTableEventListener = new RunningDocumentTableEventListener(this);
            RunningDocumentTableEventListener.BeforeSave += cleanupActiveCodeCommand.OnBeforeDocumentSave;
        }