public StartupProjectSelector() { _bIsSolutionOpened = UnrealVSPackage.Instance.DTE.Solution.IsOpen; // Create the handlers for our commands { // StartupProjectCombo var StartupProjectComboCommandId = new CommandID( GuidList.UnrealVSCmdSet, StartupProjectComboId ); var StartupProjectComboCommand = new OleMenuCommand(StartupProjectComboHandler, StartupProjectComboCommandId); StartupProjectComboCommand.BeforeQueryStatus += (sender, args) => StartupProjectComboCommand.Enabled = _bIsSolutionOpened; UnrealVSPackage.Instance.MenuCommandService.AddCommand( StartupProjectComboCommand ); // StartupProjectComboList var StartupProjectComboListCommandId = new CommandID( GuidList.UnrealVSCmdSet, StartupProjectComboListId ); var StartupProjectComboListCommand = new OleMenuCommand(StartupProjectComboListHandler, StartupProjectComboListCommandId); StartupProjectComboListCommand.BeforeQueryStatus += (sender, args) => StartupProjectComboListCommand.Enabled = _bIsSolutionOpened; UnrealVSPackage.Instance.MenuCommandService.AddCommand( StartupProjectComboListCommand ); StartupProjectComboCommands = new[] { StartupProjectComboCommand, StartupProjectComboListCommand }; } // Register for events that we care about UnrealVSPackage.Instance.OnStartupProjectChanged += OnStartupProjectChanged; UnrealVSPackage.Instance.OnSolutionOpened += delegate { Logging.WriteLine("Opened solution " + UnrealVSPackage.Instance.DTE.Solution.FullName); _bIsSolutionOpened = true; UpdateStartupProjectCombo(); UpdateStartupProjectList(Utils.GetAllProjectsFromDTE()); }; UnrealVSPackage.Instance.OnSolutionClosing += delegate { Logging.WriteLine("Closing solution"); _bIsSolutionOpened = false; UpdateStartupProjectCombo(); _CachedStartupProjects.Clear(); }; UnrealVSPackage.Instance.OnProjectOpened += delegate(Project OpenedProject) { if (_bIsSolutionOpened) { Logging.WriteLine("Opened project node " + OpenedProject.Name); UpdateStartupProjectList(OpenedProject); } else { Logging.WriteLine("Opened project node " + OpenedProject.Name + " with the solution CLOSED"); } }; UnrealVSPackage.Instance.OnProjectClosed += delegate(Project ClosedProject) { Logging.WriteLine("Closed project node " + ClosedProject.Name); RemoveFromStartupProjectList(ClosedProject); }; UnrealVSPackage.Instance.OptionsPage.OnOptionsChanged += OnOptionsChanged; UpdateStartupProjectList(Utils.GetAllProjectsFromDTE()); UpdateStartupProjectCombo(); }
private void OnOptionsChanged(object Sender, EventArgs E) { UpdateCachedOptions(); UpdateStartupProjectList(Utils.GetAllProjectsFromDTE()); }