コード例 #1
0
        void DelayedInitialise()
        {
            //+ DTE EVENTS
            //DTEEvents.OnBeginShutdown += () =>
            //{
            //    HasShutdownStarted = true;

            //    if (OnBeginShutdown != null)
            //        OnBeginShutdown(this, EventArgs.Empty);
            //};

            //+ SOLUTION EVENTS
            SolutionEvents.Opened += () =>
            {
                SafeExecute(() =>
                {
                    TryRegisterBuildEventsIfNeeded();

                    if (AfterSolutionOpened != null)
                        AfterSolutionOpened(this, EventArgs.Empty);
                });
            };

            SolutionEvents.AfterClosing += () =>
            {
                SafeExecute(() =>
                {
                    if (AfterSolutionClosed != null)
                        AfterSolutionClosed(this, EventArgs.Empty);
                });
            };

            //+ DOCUMENT EVENTS
            //DocumentEvents.DocumentOpened += (document) =>
            //{
            //    SafeExecute(() =>
            //    {
            //        if (AfterDocumentOpened != null)
            //        {
            //            var documentInfo = new DocumentInfo(document.FullName, document.ProjectItem);

            //            AfterDocumentOpened(this, new EventArgs<DocumentInfo>(documentInfo));
            //        }
            //    });
            //};

            //DocumentEvents.DocumentOpening += (path, readOnly) =>
            //{
            //    SafeExecute(() =>
            //    {
            //    });
            //};

            //+ WINDOW EVENTS
            WindowEvents.WindowActivated += (gotFocus, lostFocus) =>
            {
                SafeExecute(() =>
                {
                    if (AfterActiveDocumentChanged != null)
                    {
                        if (gotFocus != null
                            && gotFocus.Document != null)
                        {
                            var document = gotFocus.Document;

                            var args = new DocumentEventArgs(document.FullName, document.ProjectItem);

                            AfterActiveDocumentChanged(this, args);
                        }
                    }
                });
            };

            //+ DEBUGGER EVENTS
            DebuggerEvents.OnEnterDesignMode += (reason) =>
            {
                SafeExecute(() =>
                {
                    if (AfterDebuggerEnterDesignMode != null)
                        AfterDebuggerEnterDesignMode(this, EventArgs.Empty);
                });
            };

            DebuggerEvents.OnEnterRunMode += (reason) =>
            {
                SafeExecute(() =>
                {
                    if (AfterDebuggerEnterRunMode != null)
                        AfterDebuggerEnterRunMode(this, EventArgs.Empty);
                });
            };

            DebuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;

            //+ COMMAND EVENTS
            //CommandEvents.BeforeExecute += CommandEvents_BeforeExecute;
        }