Ejemplo n.º 1
0
        public int OnAfterOpenSolution(object aPUnkReserved, int aFNewSolution)
        {
            try
            {
                var dte = GetService(typeof(DTE)) as DTE2;
                mCommandsController = new CommandsController(this, dte);


                if (null == mCompileCmd)
                {
                    mCompileCmd = new CompileCommand(this, CommandSet, CommandIds.kCompileId, mCommandsController);
                }

                if (null == mTidyCmd)
                {
                    mTidyCmd = new TidyCommand(this, CommandSet, CommandIds.kTidyId, mCommandsController);
                }

                if (null == mClangFormatCmd)
                {
                    mClangFormatCmd = new ClangFormatCommand(this, CommandSet, CommandIds.kClangFormat, mCommandsController);
                }

                if (null == mStopClangCmd)
                {
                    mStopClangCmd = new StopClang(this, CommandSet, CommandIds.kStopClang, mCommandsController);
                }

                DispatcherHandler.Initialize(dte);
                StatusBarHandler.Initialize(this);
                ErrorManager.Initialize(this);

                var generalOptions = (ClangGeneralOptionsView)this.GetDialogPage(typeof(ClangGeneralOptionsView));
                var currentVersion = GetPackageVersion();

                if (0 != string.Compare(generalOptions.Version, currentVersion))
                {
                    OutputManager outputManager = new OutputManager(dte);
                    outputManager.Show();
                    outputManager.AddMessage($"🎉\tClang Power Tools was upgraded to v{currentVersion}\n" +
                                             $"\tCheck out what's new at http://www.clangpowertools.com/CHANGELOG");

                    generalOptions.Version = currentVersion;
                    generalOptions.SaveSettingsToStorage();
                }

                mBuildEvents.OnBuildBegin += ErrorManager.Instance.OnBuildBegin;

                mBuildEvents.OnBuildBegin += mCommandsController.OnBuildBegin;
                mBuildEvents.OnBuildDone  += mCommandsController.OnBuildDone;

                mBuildEvents.OnBuildDone += mCompileCmd.OnBuildDone;

                mCommandEvents.BeforeExecute += mCompileCmd.CommandEventsBeforeExecute;
                mCommandEvents.BeforeExecute += mTidyCmd.CommandEventsBeforeExecute;

                mRunningDocTableEvents.BeforeSave += mTidyCmd.OnBeforeSave;
                mRunningDocTableEvents.BeforeSave += mClangFormatCmd.OnBeforeSave;
            }
            catch (Exception)
            {
            }

            return(VSConstants.S_OK);
        }