protected void ShowWaitCursor() { VsShell.IVsUIShell uiShell = this.ServiceProvider.GetService <VsShell.IVsUIShell>(); Debug.Assert(uiShell != null); if (uiShell != null) { ErrorHandler.ThrowOnFailure(uiShell.SetWaitCursor()); } }
/// <summary> /// Called on a feature object right after it has been created from the /// meta-feature information. /// </summary> /// <param name="metaFeature">Corresponding MetaFeature which created the feature.</param> /// <param name="serviceProvider">Feature context (service provider).</param> public void Associate(MetaFeature metaFeature, ITypedServiceProvider serviceProvider) { Debug.Assert(!m_disposed); if (metaFeature == null) { throw new ArgumentNullException("metaFeature"); } if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } m_metaFeature = metaFeature; m_serviceProvider = serviceProvider; VsShell.IVsUIShell vsUIShell = m_serviceProvider.GetService <VsShell.IVsUIShell>(); Debug.Assert(vsUIShell != null); if (vsUIShell != null) { Guid toolWindowID = this.GetType().GUID; int[] position = new int[1]; VsShell.IVsWindowFrame frame; Guid emptyGuid = Guid.Empty; int hr = vsUIShell.CreateToolWindow( (int)VsShell.__VSCREATETOOLWIN.CTW_fInitNew, 0, this, ref emptyGuid, ref toolWindowID, ref emptyGuid, null, m_metaFeature.Name, position, out frame); // If the add-in is reloaded, the CreateToolWindow method may fail because // previous tool window may not be destroyed correctly. We try to create // tool window again. if (ErrorHandler.Failed(hr)) { ErrorHandler.ThrowOnFailure(vsUIShell.CreateToolWindow( (int)VsShell.__VSCREATETOOLWIN.CTW_fInitNew, 0, this, ref emptyGuid, ref toolWindowID, ref emptyGuid, null, m_metaFeature.Name, position, out frame)); } } }
private RdtManager() { // assert if we're not on the UI thread. GetService calls must be made on the UI thread, so caching // these services lets this class be used on multiple threads. if (Application.MessageLoop == false) { Debug.Fail("Must create RdtManager on the UI Thread"); throw new InvalidOperationException("Must create RdtManager on the UI Thread"); } _invisibleEditorManager = Package.GetGlobalService(typeof(VsShell.SVsInvisibleEditorManager)) as VsShell.IVsInvisibleEditorManager; _runningDocumentTable = Package.GetGlobalService(typeof(VsShell.IVsRunningDocumentTable)) as VsShell.IVsRunningDocumentTable; _dte = Package.GetGlobalService(typeof(_DTE)) as _DTE; _uiShell = Package.GetGlobalService(typeof(VsShell.SVsUIShell)) as VsShell.IVsUIShell; if (_uiShell == null) { throw new InvalidOperationException("Could not get _uiShell!"); } }
private RdtManager() { // assert if we're not on the UI thread. GetService calls must be made on the UI thread, so caching // these services lets this class be used on multiple threads. if (Application.MessageLoop == false) { Debug.Fail("Must create RdtManager on the UI Thread"); throw new InvalidOperationException("Must create RdtManager on the UI Thread"); } _invisibleEditorManager = Package.GetGlobalService(typeof(VsShell.SVsInvisibleEditorManager)) as VsShell.IVsInvisibleEditorManager; _runningDocumentTable = Package.GetGlobalService(typeof(VsShell.IVsRunningDocumentTable)) as VsShell.IVsRunningDocumentTable; _dte = Package.GetGlobalService(typeof(_DTE)) as _DTE; _uiShell = Package.GetGlobalService(typeof(VsShell.SVsUIShell)) as VsShell.IVsUIShell; if (_uiShell == null) { throw new InvalidOperationException("Could not get _uiShell!"); } }