private void _dteEvents_OnStartupComplete() { _welcomePage?.Show(); if (_error != null) { var boxresult = MessageBox.Show($"Configuration unsuccessful. Do you want to open an issue on GitHub?", "LINQBridgeVs: Error during the configuration", MessageBoxButton.YesNo); if (boxresult == MessageBoxResult.Yes) { System.Diagnostics.Process.Start($"https://github.com/codingadventures/LINQBridgeVs/issues/new?title={_error.Title}&body={_error.Body}"); } _error = null; } if (_installationResult == null) { return; } var messageResult = MessageBox.Show("Do you want to send anonymous error reports to LINQBridgeVs?", "LINQBridgeVs: Error Tracking", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); _packageSettings.ErrorTrackingEnabled = messageResult == MessageBoxResult.Yes; _packageSettings.SaveSettingsToStorage(); MessageBox.Show(_installationResult.Value ? "LINQBridgeVs has been successfully configured." : "LINQBridgeVs wasn't successfully configured."); }
/// <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> /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> /// <param name="progress">A provider for progress updates.</param> /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); // Query service asynchronously from the UI thread var dte = await GetServiceAsync(typeof(DTE)) as DTE; Assumes.Present(dte); BridgeVsExtension bridge = new BridgeVsExtension(dte); // Add our command handlers for menu(commands must exist in the.vsct file) OleMenuCommandService mcs = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; Assumes.Present(mcs); // Create the command for the menu item. CommandID enableCommand = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdEnableBridge); OleMenuCommand menuItemEnable = new OleMenuCommand((s, e) => bridge.Execute(CommandAction.Enable), enableCommand); menuItemEnable.BeforeQueryStatus += (s, e) => bridge.UpdateCommand(menuItemEnable, CommandAction.Enable); CommandID disableCommand = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdDisableBridge); OleMenuCommand menuItemDisable = new OleMenuCommand((s, e) => bridge.Execute(CommandAction.Disable), disableCommand); menuItemDisable.BeforeQueryStatus += (s, e) => bridge.UpdateCommand(menuItemDisable, CommandAction.Disable); CommandID gettingStarted = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdGettingStarted); OleMenuCommand menuItemGettingStarted = new OleMenuCommand((s, e) => System.Diagnostics.Process.Start("https://github.com/codingadventures/LINQBridgeVs#getting-started"), gettingStarted); CommandID sendFeedback = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdFeedback); OleMenuCommand menuItemSendFeedback = new OleMenuCommand((s, e) => System.Diagnostics.Process.Start("https://marketplace.visualstudio.com/items?itemName=codingadventures.linqbridgevs#review-details"), sendFeedback); mcs.AddCommand(menuItemEnable); mcs.AddCommand(menuItemDisable); mcs.AddCommand(menuItemGettingStarted); mcs.AddCommand(menuItemSendFeedback); bool isLinqBridgeVsConfigured = PackageConfigurator.IsBridgeVsConfigured(dte.Version); //if first time user if (isLinqBridgeVsConfigured) { return; } //Initialize Object Exporter settings PackageSettings packageSettings = null; Package: try { packageSettings = (PackageSettings)GetDialogPage(typeof(PackageSettings)); } catch { goto Package; } DialogResult messageResult = MessageBox.Show("Do you want to send anonymous error reports to LINQBridgeVs?", "LINQBridgeVs: Error Tracking", MessageBoxButtons.YesNo, MessageBoxIcon.Question); packageSettings.ErrorTrackingEnabled = messageResult == DialogResult.Yes; packageSettings.SaveSettingsToStorage(); PackageConfigurator.Install(dte.Version, dte.Edition); }