Inheritance: IVsUpdateSolutionEvents2, IVsSelectionEvents
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Commands.Initialize(this);
            base.Initialize();

            vsHelper = new VisualStudioHelper(this);
            vsHelper.SolutionAfterOpen     += VsHelper_SolutionOpend;
            vsHelper.SolutionBeforeClose   += VsHelper_SolutionWillClose;
            vsHelper.SolutionAfterClose    += VsHelper_SolutionClosed;
            vsHelper.StartupProjectChanged += VsHelper_StartupProjectChanged;
            vsHelper.StartupProjectConfigurationChanged += VsHelper_StartupProjectConfigurationChanged;
            vsHelper.ProjectBeforeRun += VsHelper_ProjectWillRun;

            vsHelper.ProjectAfterOpen   += VsHelper_ProjectAdded;
            vsHelper.ProjectBeforeClose += VsHelper_ProjectRemoved;
            vsHelper.ProjectAfterRename += VsHelper_ProjectRenamed;

            vsHelper.Initialize();

            GetDialogPage <CmdArgsOptionPage>().VcsSupportChanged       += OptionPage_VcsSupportChanged;
            GetDialogPage <CmdArgsOptionPage>().UseMonospaceFontChanged += OptionPage_UseMonospaceFontChanged;

            // Extension window was opend while a solution is already open
            if (vsHelper.IsSolutionOpen)
            {
                Logger.Info("Package.Initialize called while solution was already open.");

                InitializeForSolution();
            }

            ToolWindowViewModel.TreeViewModel.ItemSelectionChanged += OnItemSelectionChanged;

            ToolWindowViewModel.UseMonospaceFont = IsUseMonospaceFontEnabled;
        }
Esempio n. 2
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Commands.Initialize(this);
            base.Initialize();

            vsHelper = new VisualStudioHelper(this);
            vsHelper.SolutionOpend         += VsHelper_SolutionOpend;
            vsHelper.SolutionWillClose     += VsHelper_SolutionWillClose;
            vsHelper.SolutionClosed        += VsHelper_SolutionClosed;
            vsHelper.StartupProjectChanged += VsHelper_StartupProjectChanged;
            vsHelper.StartupProjectConfigurationChanged += VsHelper_StartupProjectConfigurationChanged;

            vsHelper.ProjectAdded   += VsHelper_ProjectAdded;
            vsHelper.ProjectRemoved += VsHelper_ProjectRemoved;
            vsHelper.ProjectRenamed += VsHelper_ProjectRenamed;

            vsHelper.Initialize();

            GetDialogPage <CmdArgsOptionPage>().MacroEvaluationChanged += OptionPage_MacroEvaluationChanged;

            // Extension window was opend while a solution is already open
            if (vsHelper.IsSolutionOpen)
            {
                Logger.Info("Package.Initialize called while solution was already open.");

                UpdateCommandsForAllProjects();
                AttachFsWatcherToAllProjects();
                UpdateCurrentStartupProject();
            }

            ToolWindowViewModel.CommandLineChanged   += OnCommandLineChanged;
            ToolWindowViewModel.SelectedItemsChanged += OnSelectedItemsChanged;
        }
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await Commands.InitializeAsync(this);

            vsHelper = new VisualStudioHelper(this);
            vsHelper.SolutionAfterOpen     += VsHelper_SolutionOpend;
            vsHelper.SolutionBeforeClose   += VsHelper_SolutionWillClose;
            vsHelper.SolutionAfterClose    += VsHelper_SolutionClosed;
            vsHelper.StartupProjectChanged += VsHelper_StartupProjectChanged;
            vsHelper.StartupProjectConfigurationChanged += VsHelper_StartupProjectConfigurationChanged;
            vsHelper.ProjectBeforeRun += VsHelper_ProjectWillRun;

            vsHelper.ProjectAfterOpen   += VsHelper_ProjectAdded;
            vsHelper.ProjectBeforeClose += VsHelper_ProjectRemoved;
            vsHelper.ProjectAfterRename += VsHelper_ProjectRenamed;
            vsHelper.ProjectAfterLoad   += VsHelper_ProjectAfterLoad;

            fileStorage = new FileStorage(this, vsHelper);
            fileStorage.FileStorageChanged += FileStorage_FileStorageChanged;

            await vsHelper.InitializeAsync();

            // Switch to main thread
            await JoinableTaskFactory.SwitchToMainThreadAsync();

            ToolWindowViewModel.SettingsViewModel.VcsSupportEnabledChanged += OptionPage_VcsSupportChanged;
            ToolWindowViewModel.SettingsViewModel.UseSolutionDirChanged    += CmdArgsPackage_UseSolutionDirChanged;
            GetDialogPage <CmdArgsOptionPage>().UseMonospaceFontChanged    += OptionPage_UseMonospaceFontChanged;

            // Extension window was opend while a solution is already open
            if (vsHelper.IsSolutionOpen)
            {
                Logger.Info("Package.Initialize called while solution was already open.");

                InitializeForSolution();
            }

            ToolWindowViewModel.TreeViewModel.ItemSelectionChanged += OnItemSelectionChanged;
            ToolWindowViewModel.TreeViewModel.TreeContentChanged   += OnTreeContentChanged;

            ToolWindowViewModel.UseMonospaceFont = IsUseMonospaceFontEnabled;

            await base.InitializeAsync(cancellationToken, progress);
        }