///////////////////////////////////////////////////////////////////////////// // Overridden Package Implementation /// <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 async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); AppInfo.appObject = (EnvDTE80.DTE2)ServiceProvider.GlobalProvider.GetService(typeof(DTE)); ExternalSettingsTracker.Start(); OleMenuCommandService mcs = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; CommandID menuCommandID = new CommandID(GuidList.guidAlwaysAlignedCmdSet, (int)PkgCmdIDList.AlwaysAlignedMenu); OleMenuCommand menuItem = new OleMenuCommand(MenuItemCallback, menuCommandID); menuItem.BeforeQueryStatus += new EventHandler(OnBeforeQueryStatusSetMenuText); mcs.AddCommand(menuItem); }
///////////////////////////////////////////////////////////////////////////// // Overriden Package Implementation /// <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 initilaization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); base.Initialize(); AppInfo.appObject = (EnvDTE80.DTE2)ServiceProvider.GlobalProvider.GetService(typeof(DTE)); ExternalSettingsTracker.Start(); OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (mcs != null) { // Create the command for the menu item. CommandID menuCommandID = new CommandID(GuidList.guidAlwaysAlignedCmdSet, (int)PkgCmdIDList.AlwaysAlignedMenu); OleMenuCommand menuItem = new OleMenuCommand(MenuItemCallback, menuCommandID); menuItem.BeforeQueryStatus += new EventHandler(OnBeforeQueryStatusSetMenuText); mcs.AddCommand(menuItem); } }