/// <devdoc> /// Recretes the context /// </devdoc> private void RecreateContext() { if (parentService != null && needsRecreate) { needsRecreate = false; if (this.context == null) { parentService.CreateLocalContext(this.priority, true, out this.context, out this.cookie); } else { VSUSERCONTEXTPRIORITY vsPriority = 0; switch (priority) { case HelpContextType.ToolWindowSelection: vsPriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_ToolWndSel; break; case HelpContextType.Selection: vsPriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Selection; break; case HelpContextType.Window: vsPriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Window; break; case HelpContextType.Ambient: vsPriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Ambient; break; } IVsUserContext cxtParent = parentService.GetUserContext(); IVsUserContext cxt = GetUserContext(); if (cxt != null && cxtParent != null) { NativeMethods.ThrowOnFailure(cxtParent.AddSubcontext(cxt, (int)vsPriority, out this.cookie)); } } } }
private void RecreateContext() { if ((_ParentService != null) && _NeedsRecreate) { _NeedsRecreate = false; if (_Context == null) { _ParentService.CreateLocalContext(_Priority, true, out _Context, out _Cookie); } else { VSUSERCONTEXTPRIORITY vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_None; switch (_Priority) { case HelpContextType.Ambient: vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Ambient; break; case HelpContextType.Window: vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Window; break; case HelpContextType.Selection: vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Selection; break; case HelpContextType.ToolWindowSelection: vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_ToolWndSel; break; } IVsUserContext userContext = _ParentService.GetUserContext(); IVsUserContext pSubCtx = GetUserContext(); if ((pSubCtx != null) && (userContext != null)) { NativeMethods.ThrowOnFailure(userContext.AddSubcontext(pSubCtx, (int)vsusercontextpriority, out _Cookie)); } } } }
private IHelpService CreateLocalContext(HelpContextType contextType, bool recreate, out IVsUserContext localContext, out uint cookie) { cookie = 0; localContext = null; if (_ServiceProvider != null) { localContext = null; int hr = 0; IVsMonitorUserContext context = (IVsMonitorUserContext)_ServiceProvider.GetService(typeof(IVsMonitorUserContext)); if (context != null) { try { hr = context.CreateEmptyContext(out localContext); } catch (COMException exception) { hr = exception.ErrorCode; } } if (NativeMethods.Succeeded(hr) && (localContext != null)) { VSUSERCONTEXTPRIORITY vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_None; switch (contextType) { case HelpContextType.Ambient: vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Ambient; break; case HelpContextType.Window: vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Window; break; case HelpContextType.Selection: vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Selection; break; case HelpContextType.ToolWindowSelection: vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_ToolWndSel; break; } IVsUserContext userContext = GetUserContext(); if (userContext != null) { try { hr = userContext.AddSubcontext(localContext, (int)vsusercontextpriority, out cookie); } catch (COMException exception2) { hr = exception2.ErrorCode; } } if ((NativeMethods.Succeeded(hr) && (cookie != 0)) && !recreate) { HelpService service = new HelpService(this, localContext, cookie, _ServiceProvider, contextType); if (_SubContextList == null) { _SubContextList = new ArrayList(); } _SubContextList.Add(service); return(service); } } } return(null); }
/// <devdoc> /// </devdoc> private IHelpService CreateLocalContext(HelpContextType contextType, bool recreate, out IVsUserContext localContext, out uint cookie) { cookie = 0; localContext = null; if (provider == null) { return(null); } localContext = null; int hr = NativeMethods.S_OK; IVsMonitorUserContext muc = (IVsMonitorUserContext)provider.GetService(typeof(IVsMonitorUserContext)); if (muc != null) { try { hr = muc.CreateEmptyContext(out localContext); } catch (COMException e) { hr = e.ErrorCode; } } if (NativeMethods.Succeeded(hr) && (localContext != null)) { VSUSERCONTEXTPRIORITY priority = 0; switch (contextType) { case HelpContextType.ToolWindowSelection: priority = VSUSERCONTEXTPRIORITY.VSUC_Priority_ToolWndSel; break; case HelpContextType.Selection: priority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Selection; break; case HelpContextType.Window: priority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Window; break; case HelpContextType.Ambient: priority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Ambient; break; } IVsUserContext cxt = GetUserContext(); if (cxt != null) { try { hr = cxt.AddSubcontext(localContext, (int)priority, out cookie); } catch (COMException e) { hr = e.ErrorCode; } } if (NativeMethods.Succeeded(hr) && (cookie != 0)) { if (!recreate) { HelpService newHs = new HelpService(this, localContext, cookie, provider, contextType); if (subContextList == null) { subContextList = new ArrayList(); } subContextList.Add(newHs); return(newHs); } } } return(null); }