private void OnPlotHistoryHistoryChanged(object sender, EventArgs e) { ((IVsWindowFrame)Frame).ShowNoActivate(); IVsUIShell shell = VsAppShell.Current.GetGlobalService <IVsUIShell>(typeof(SVsUIShell)); shell.UpdateCommandUI(0); }
public void OnExecute(CommandEventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); if (_control == null) { return; // Can never happen as update already checked this } if (e.Command == AnkhCommand.SvnInfoAlphabetical) { _control.Grid.PropertySort = PropertySort.Alphabetical; } else { _control.Grid.PropertySort = PropertySort.CategorizedAlphabetical; } // And tell VS that the state of other commands changed to // avoid an ugly delay in updating the other toolbar button IVsUIShell shell = e.GetService <IVsUIShell>(); if (shell != null) { shell.UpdateCommandUI(1); // Force an immediate update } }
/// <include file='doc\OleMenuCommandService.uex' path='docs/doc[@for="OleMenuCommandService.OnCommandChanged"]/*' /> /// <devdoc> /// This is called by a menu command when it's status has changed. /// </devdoc> protected override void OnCommandsChanged(MenuCommandsChangedEventArgs e) { base.OnCommandsChanged(e); if (0 == _queryStatusCount) { // UpdateCommandUI(0) can not be called inside QueryStatus because this will cause an infinite // sequence of calls to QueryStatus during idle time. IVsUIShell uiShellSvc = null; try { uiShellSvc = GetService(typeof(SVsUIShell)) as IVsUIShell; } catch (Exception) { // The command change notifications may come at shutdown time after COM has been terminated if a package or addin // chooses to remove menu commands from an object finalizer (the finalizer thread runs after COM shutdown, too). // Any access to shell services at that point will cause System.InvalidComObjectException, System.AccessViolationException // or System.Runtime.InteropServices.COMException(RPC_E_DISCONNECTED) because the RCW for the service provider // has been disconnected from the underlying COM object. // Instead of crashing, catch exceptions around getting the shell service, and skip updating the UI. // Continue to throw if there were problems obtaining the shell service when running on the UI thead (as the function should normally be invoked). if (IsCurrentThreadMainUIThread()) { throw; } } if (uiShellSvc != null) { NativeMethods.ThrowOnFailure(uiShellSvc.UpdateCommandUI(0)); } } }
/// <summary> /// Updates the command UI. /// </summary> /// <param name="performImmediately">if set to <c>true</c> [perform immediately].</param> public void UpdateCommandUI(bool performImmediately) { IVsUIShell shell = UIShell; if (shell != null) { shell.UpdateCommandUI(performImmediately ? 1 : 0); } }
/// <include file='doc\DesignerPackage.uex' path='docs/doc[@for="DesignerPackage.SetUIDirty"]/*' /> /// <devdoc> /// Marks the UI dirty. The UI becomes dirty whenever a toolbar or menu item's /// status changes. Most development environments cache the status of these /// elements for speed, and need to know when they need to be updated. /// /// This method would be called, for example, after a set of objects have /// been selected within the designer to enable the cut and copy menu items, /// for example. /// </devdoc> public void SetUIDirty() { IVsUIShell uishell = (IVsUIShell)GetService(typeof(IVsUIShell)); if (uishell != null) { uishell.UpdateCommandUI(0); } }
private void UpdateQueryStatus() { // Force the shell to refresh the QueryStatus for all the command since default behavior is it only does query // when focus on error list has changed, not individual items. if (_shellService != null) { _shellService.UpdateCommandUI(0); } }
/// <summary> /// Update commands when the zoom level changes /// </summary> private void DesignerZoomChanged(object sender, DiagramEventArgs e) { IVsUIShell shell = (IVsUIShell)GetService(typeof(SVsUIShell)); if (shell != null) { ErrorHandler.ThrowOnFailure(shell.UpdateCommandUI(0)); } }
void UpdateUI(IServiceProvider sp) { IVsUIShell vsShell = (IVsUIShell)sp.GetService(typeof(IVsUIShell)); if (vsShell != null) { int hr = vsShell.UpdateCommandUI(0);//建议传入0 Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(hr); } }
/// <summary> /// Updates the command UI. /// </summary> /// <param name="performImmediately">if set to <c>true</c> [perform immediately].</param> public void UpdateCommandUI(bool performImmediately) { ThreadHelper.ThrowIfNotOnUIThread(); IVsUIShell shell = UIShell; if (shell != null) { shell.UpdateCommandUI(performImmediately ? 1 : 0); } }
void UpdateUI(bool synchronous) { Dispatcher.CurrentDispatcher.VerifyAccess(); IVsUIShell vsShell = (IVsUIShell)m_serviceProvider.GetService(typeof(IVsUIShell)); if (vsShell != null) { Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(vsShell.UpdateCommandUI(synchronous ? 1 : 0)); } }
/// <summary> /// Refresh the command state when a different page is selected /// </summary> void UpdateCommands() { ThreadHelper.ThrowIfNotOnUIThread(); addToFavoritesButton.IsEnabled = (SelectionToolTabs.SelectedItem != tabFavorites); removeFromFavoritesButton.IsEnabled = (SelectionToolTabs.SelectedItem == tabFavorites); toggleStatusButton.IsEnabled = (SelectionToolTabs.SelectedItem == tabFavorites); clearLogButton.IsEnabled = (SelectionToolTabs.SelectedItem == tabUIContextLog || SelectionToolTabs.SelectedItem == tabSelectionLog); IVsUIShell uiShell = Package.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell; uiShell.UpdateCommandUI(1); }
private void OnNavigated(object sender, WebBrowserNavigatedEventArgs e) { SetThemeColors(); _host.Child = Browser; Browser.Document.Window.Unload += OnWindowUnload; // Upon vavigation we need to ask VS to update UI so // Back /Forward buttons become properly enabled or disabled. IVsUIShell shell = VsAppShell.Current.GetGlobalService <IVsUIShell>(typeof(SVsUIShell)); shell.UpdateCommandUI(0); }
private void OnNavigated(object sender, WebBrowserNavigatedEventArgs e) { // Page may be loaded, but body may still be null of scripts // are running. For example, in 3.2.2 code colorization script // tends to damage body content so browser may have to to re-create it. SetThemeColorsWhenReady(); // Upon navigation we need to ask VS to update UI so // Back/Forward buttons become properly enabled or disabled. IVsUIShell shell = _services.GetService <IVsUIShell>(typeof(SVsUIShell)); shell.UpdateCommandUI(0); }
private void UpdateInteractiveWindowIfRequired(IInteractiveWindowVisualComponent newInteractiveWindow) { var oldInteractiveWindow = Interlocked.Exchange(ref _lastActiveWindow, newInteractiveWindow); if (oldInteractiveWindow == newInteractiveWindow) { return; } IVsUIShell shell = VsAppShell.Current.GetGlobalService <IVsUIShell>(typeof(SVsUIShell)); shell.UpdateCommandUI(1); }
private async Task OnDispatcherStartCompletedAsync() { WpfConsole.Dispatcher.StartWaitingKey -= OnDispatcherStartWaitingKey; ConsoleParentPane.NotifyInitializationCompleted(); await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); // force the UI to update the toolbar IVsUIShell vsUIShell = await AsyncServiceProvider.GlobalProvider.GetServiceAsync <IVsUIShell, IVsUIShell>(throwOnFailure : false); vsUIShell.UpdateCommandUI(0 /* false = update UI asynchronously */); }
public void RefreshToolbars() { if (_serviceProvider == null) { return; } IVsUIShell shell = _serviceProvider.GetService(typeof(IVsUIShell)) as IVsUIShell; if (shell != null) { shell.UpdateCommandUI(1); } }
private async Task OnDispatcherStartCompletedAsync() { WpfConsole.Dispatcher.StartWaitingKey -= OnDispatcherStartWaitingKey; ConsoleParentPane.NotifyInitializationCompleted(); await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); // force the UI to update the toolbar IVsUIShell vsUIShell = await AsyncServiceProvider.GlobalProvider.GetServiceAsync <IVsUIShell>(); vsUIShell.UpdateCommandUI(0 /* false = update UI asynchronously */); NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageManagerConsoleLoaded); }
/// <include file='doc\OleMenuCommandService.uex' path='docs/doc[@for="OleMenuCommandService.OnCommandChanged"]/*' /> /// <devdoc> /// This is called by a menu command when it's status has changed. /// </devdoc> protected override void OnCommandsChanged(MenuCommandsChangedEventArgs e) { base.OnCommandsChanged(e); if (0 == _queryStatusCount) { // UpdateCommandUI(0) can not be called inside QueryStatus because this will cause an infinite // sequence of calls to QueryStatus during idle time. IVsUIShell uiShellSvc = GetService(typeof(SVsUIShell)) as IVsUIShell; if (uiShellSvc != null) { NativeMethods.ThrowOnFailure(uiShellSvc.UpdateCommandUI(0)); } } }
private void OnViewPresetChanged( object sender, ValueChangedEventArgs <AsyncDataViewModelPreset> args) { string name = args.NewValue?.Name; if (!string.IsNullOrEmpty(name)) { ambientStore.SetValue(SettingsKeys.ActiveViewPreset, args.NewValue?.Name); } else { ambientStore.ClearValue(SettingsKeys.ActiveViewPreset); } uiShell?.UpdateCommandUI(0); }
protected override void OnItemChecked(ItemCheckedEventArgs e) { base.OnItemChecked(e); if (_shell == null) { IAnkhServiceProvider sps = SelectionPublishServiceProvider; if (sps != null) { _shell = sps.GetService <IVsUIShell>(typeof(SVsUIShell)); } } if (_shell != null) { _shell.UpdateCommandUI(0); // Make sure the toolbar is updated on check actions } }
private void RichTextSelectionChanged(object sender, EventArgs e) { ReadingRichTextBox richText = (ReadingRichTextBox)sender; bool newHasSelection = richText.SelectionLength != 0; bool newIsProtected = richText.SelectionPartiallyProtected; if (newHasSelection ^ myRichTextSelected || newIsProtected ^ myRichTextProtected) { myRichTextSelected = newHasSelection; myRichTextProtected = newIsProtected; IVsUIShell service = myCtorServiceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; if (service != null) { service.UpdateCommandUI(1); } } }
private void ChangeOrientation() { if (_vertical) { pendingChangesTabs.Dock = DockStyle.Bottom; } else { pendingChangesTabs.Dock = DockStyle.Left; } if (Context != null) { IVsUIShell ui = Context.GetService <IVsUIShell>(typeof(SVsUIShell)); if (ui != null) { ui.UpdateCommandUI(0); } } }
/// <summary> /// Catch selection change notifications to force UI update /// </summary> protected override void OnNotifyMessage(Message m) { if (m.Msg == 0x282 && m.WParam == (IntPtr)0xB) // WM_IME_NOTIFY = 0x282, IMN_SETCOMPOSITIONWINDOW = 0xB { bool hasCurrentSelection = SelectionLength != 0; bool hasText = hasCurrentSelection || TextLength != 0; if ((hasCurrentSelection ^ myHasSelection) || (hasText ^ myHasText)) { myHasSelection = hasCurrentSelection; myHasText = hasText; if (this.Focused) { IVsUIShell service = myServiceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; if (service != null) { service.UpdateCommandUI(1); } } } } }
public void SpotClient_OnTrackChange(object sender, SpotifyAPI.Local.TrackChangeEventArgs e) { if (!UserPreferences.Default.showTrackArtistOnChange) { Console.WriteLine("ShowTrackArtist is disabled in user preferences."); return; } if (e.NewTrack == null || e.NewTrack.TrackResource == null || e.NewTrack.TrackResource.Name == null || e.NewTrack.AlbumResource.Name == null) { return; } string trackName = e.NewTrack.TrackResource.Name; string artistName = e.NewTrack.ArtistResource.Name; Console.WriteLine("Show New track name: " + trackName); myOleCommand.Text = String.Format("{0} - {1}", trackName, artistName); Microsoft.VisualStudio.Shell.ServiceProvider serviceProvider = new Microsoft.VisualStudio.Shell.ServiceProvider(((EnvDTE.DTE)Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE))) as Microsoft.VisualStudio.OLE.Interop.IServiceProvider); IVsUIShell uiShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; uiShell.UpdateCommandUI(0); if (timer != null) { timer.Stop(); timer.Start(); } else { timer = new System.Timers.Timer() { Interval = kSHOW_TRACK_INTERVAL }; //timer.AutoReset = false; timer.Elapsed += TrackChangeTimerTick; timer.Start(); } }
private static void ActuallyUpdateUI(IVsDataHostService hostService) { IVsUIShell uiShell = hostService.GetService <IVsUIShell>(); uiShell.UpdateCommandUI(0); // fImmediateUpdate == false }
public void UpdateCommandStatus(bool immediate) => _coreShell.MainThread().Post(() => { _uiShell.UpdateCommandUI(immediate ? 1 : 0); });
private void UpdateCommandUI() { _uiShell.UpdateCommandUI(0); }
/// <summary> /// Initializes a new instance of the <see cref="Command4"/> class. /// Adds our command handlers for menu (commands must exist in the command table file) /// </summary> /// <param name="package">Owner package, not null.</param> private Command4(Package package) { if (package == null) { throw new ArgumentNullException("package"); } this.package = package; OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (commandService != null) { var menuCommandID = new CommandID(CommandSet, CommandId); // var menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID); myOleCommand = new OleMenuCommand(this.MenuItemCallback, menuCommandID); //if (null != myOleCommand) //{ // myOleCommand.Text = "New Text"; // //} if (IsSpotifyProcessRunning()) { if (Command1Package.SpotifyCommandShouldShowText()) { myOleCommand.Text = kSpotifyOpenString; } else { myOleCommand.Text = " "; } } else { if (UserPreferences.Default.HideButtonTextOnInactive) { myOleCommand.Text = " "; } else { myOleCommand.Text = kSpotifyStartString; } } Microsoft.VisualStudio.Shell.ServiceProvider serviceProvider = new Microsoft.VisualStudio.Shell.ServiceProvider(((EnvDTE.DTE)Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE))) as Microsoft.VisualStudio.OLE.Interop.IServiceProvider); IVsUIShell uiShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; uiShell.UpdateCommandUI(0); if (IsSpotifyProcessRunning()) { SpotClientRegisterTrackChange(); } commandService.AddCommand(myOleCommand); gCommand4Instance = this; } }