Ejemplo n.º 1
0
        private IHelpService CreateLocalContext(HelpContextType contextType, bool recreate, out IVsUserContext localContext, out int cookie)
        {
            cookie       = 0;
            localContext = null;
            if (provider == null)
            {
                return(null);
            }

            localContext = null;
            IVsMonitorUserContext muc = (IVsMonitorUserContext)provider.GetService(typeof(IVsMonitorUserContext));

            if (muc != null)
            {
                localContext = muc.CreateEmptyContext();
            }

            if (localContext != null)
            {
                int priority = 0;
                switch (contextType)
                {
                case HelpContextType.ToolWindowSelection:
                    priority = tagVsUserContextPriority.VSUC_Priority_ToolWndSel;
                    break;

                case HelpContextType.Selection:
                    priority = tagVsUserContextPriority.VSUC_Priority_Selection;
                    break;

                case HelpContextType.Window:
                    priority = tagVsUserContextPriority.VSUC_Priority_Window;
                    break;

                case HelpContextType.Ambient:
                    priority = tagVsUserContextPriority.VSUC_Priority_Ambient;
                    break;
                }

                cookie = GetUserContext().AddSubcontext(localContext, priority);

                if (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);
        }
Ejemplo n.º 2
0
        /// <devdoc>
        ///     Retrieves a user context for us to add and remove attributes.  This
        ///     will demand create the context if it doesn't exist.
        /// </devdoc>
        private IVsUserContext GetUserContext()
        {
            // try to rebuild from a parent if possible.
            RecreateContext();

            // Create a new context if we don't have one.
            //
            if (context == null)
            {
                if (provider == null)
                {
                    return(null);
                }


                IVsWindowFrame windowFrame = (IVsWindowFrame)provider.GetService(typeof(IVsWindowFrame));

                if (windowFrame != null)
                {
                    object prop;
                    NativeMethods.ThrowOnFailure(windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_UserContext, out prop));
                    context = (IVsUserContext)prop;
                }

                if (context == null)
                {
                    IVsMonitorUserContext muc = (IVsMonitorUserContext)provider.GetService(typeof(IVsMonitorUserContext));
                    if (muc != null)
                    {
                        NativeMethods.ThrowOnFailure(muc.CreateEmptyContext(out context));
                        Debug.Assert(context != null, "muc didn't create context");
                    }
                }

                if (subContextList != null && context != null)
                {
                    foreach (object helpObj in subContextList)
                    {
                        if (helpObj is HelpService)
                        {
                            ((HelpService)helpObj).RecreateContext();
                        }
                    }
                }
            }

            return(context);
        }
Ejemplo n.º 3
0
        /// <include file='doc\HelpService.uex' path='docs/doc[@for="HelpService.GetUserContext"]/*' />
        /// <devdoc>
        ///     Retrieves a user context for us to add and remove attributes.  This
        ///     will demand create the context if it doesn't exist.
        /// </devdoc>
        private IVsUserContext GetUserContext()
        {
            // try to rebuild from a parent if possible.
            RecreateContext();

            // Create a new context if we don't have one.
            //
            if (context == null)
            {
                if (provider == null)
                {
                    return(null);
                }


                IVsWindowFrame windowFrame = (IVsWindowFrame)provider.GetService(typeof(IVsWindowFrame));

                if (windowFrame != null)
                {
                    context = (IVsUserContext)windowFrame.GetProperty(__VSFPROPID.VSFPROPID_UserContext);
                }

                if (context == null)
                {
                    IVsMonitorUserContext muc = (IVsMonitorUserContext)provider.GetService(typeof(IVsMonitorUserContext));
                    if (muc != null)
                    {
                        context         = muc.CreateEmptyContext();
                        notifySelection = true;
                        Debug.Assert(context != null, "muc didn't create context");
                    }
                }

                if (subContextList != null && context != null)
                {
                    foreach (object helpObj in subContextList)
                    {
                        if (helpObj is HelpService)
                        {
                            ((HelpService)helpObj).RecreateContext();
                        }
                    }
                }
            }

            return(context);
        }
Ejemplo n.º 4
0
        /// <include file='doc\Task.uex' path='docs/doc[@for="Task.GetUserContext"]/*' />
        public int GetUserContext(out IVsUserContext ppctx)
        {
            int hr = NativeMethods.S_OK;

            if (context == null)
            {
                // Create an empty context
                IVsMonitorUserContext monitorContext = owner.GetService(typeof(SVsMonitorUserContext)) as IVsMonitorUserContext;
                NativeMethods.ThrowOnFailure(monitorContext.CreateEmptyContext(out context));

                // Add the required information to the context
                hr = context.AddAttribute(VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_LookupF1, contextNameKeyword, this.HelpKeyword);
            }
            ppctx = context;

            return(hr);
        }
Ejemplo n.º 5
0
 private IVsUserContext GetUserContext()
 {
     RecreateContext();
     if (_Context == null)
     {
         if (_ServiceProvider == null)
         {
             return(null);
         }
         IVsWindowFrame frame = (IVsWindowFrame)_ServiceProvider.GetService(typeof(IVsWindowFrame));
         if (frame != null)
         {
             object obj2;
             NativeMethods.ThrowOnFailure(frame.GetProperty(-3010, out obj2));
             _Context = (IVsUserContext)obj2;
         }
         if (_Context == null)
         {
             IVsMonitorUserContext context =
                 (IVsMonitorUserContext)_ServiceProvider.GetService(typeof(IVsMonitorUserContext));
             if (context != null)
             {
                 NativeMethods.ThrowOnFailure(context.CreateEmptyContext(out _Context));
                 if (((_Context != null) && (frame != null)) && IsToolWindow(frame))
                 {
                     NativeMethods.ThrowOnFailure(frame.SetProperty(-3010, _Context));
                 }
             }
         }
         if ((_SubContextList != null) && (_Context != null))
         {
             foreach (object obj3 in _SubContextList)
             {
                 HelpService service = obj3 as HelpService;
                 if (service != null)
                 {
                     service.RecreateContext();
                 }
             }
         }
     }
     return(_Context);
 }
Ejemplo n.º 6
0
 public int GetUserContext(out IVsUserContext ppctx)
 {
     // Common.Trace("Task.GetUserContext");
     // set the user context
     if (userContext == null && helpKeyword != null && helpKeyword.Length > 0)
     {
         IVsMonitorUserContext monitor = Common.GetService(typeof(SVsMonitorUserContext)) as IVsMonitorUserContext;
         if (monitor != null)
         {
             int hr = monitor.CreateEmptyContext(out userContext);
             if (hr == 0 && userContext != null)
             {
                 hr = userContext.AddAttribute(VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_LookupF1, "keyword", helpKeyword);
             }
             if (hr != 0)
             {
                 userContext = null;
             }
         }
     }
     ppctx = userContext;
     return(0);
 }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        /// <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);
        }