예제 #1
0
 private HelpService(HelpService parentService, IVsUserContext subContext, int cookie, IServiceProvider provider, HelpContextType priority)
 {
     this.context       = subContext;
     this.provider      = provider;
     this.cookie        = cookie;
     this.parentService = parentService;
     this.priority      = priority;
 }
예제 #2
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);
        }
예제 #3
0
        /// <include file='doc\HelpService.uex' path='docs/doc[@for="HelpService.Dispose"]/*' />
        /// <devdoc>
        ///     Disposes this object.
        /// </devdoc>
        public virtual void Dispose()
        {
            if (subContextList != null && subContextList.Count > 0)
            {
                foreach (HelpService hs in subContextList)
                {
                    hs.parentService = null;
                    if (context != null)
                    {
                        context.RemoveSubcontext(hs.cookie);
                    }
                    hs.Dispose();
                }
                subContextList = null;
            }

            if (parentService != null)
            {
                IHelpService parent = parentService;
                parentService = null;
                parent.RemoveLocalContext(this);
            }

            if (provider != null)
            {
                IDesignerHost host = (IDesignerHost)provider.GetService(typeof(IDesignerHost));
                if (host != null)
                {
                    host.Activated -= new EventHandler(this.OnDesignerActivate);
                }
                provider = null;
            }
            if (context != null)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(context);
                context = null;
            }
            this.cookie = 0;
        }