Beispiel #1
0
 private void NotifyContextChange(IVsUserContext cxt)
 {
     if ((_ServiceProvider != null) && (_ParentService == null))
     {
         IVsUserContext        ppContext = null;
         IVsMonitorUserContext service   =
             (IVsMonitorUserContext)_ServiceProvider.GetService(typeof(IVsMonitorUserContext));
         if (service != null)
         {
             NativeMethods.ThrowOnFailure(service.get_ApplicationContext(out ppContext));
         }
         if (ppContext != cxt)
         {
             IVsWindowFrame frame = (IVsWindowFrame)_ServiceProvider.GetService(typeof(IVsWindowFrame));
             if ((frame != null) && !IsToolWindow(frame))
             {
                 IVsTrackSelectionEx ex = (IVsTrackSelectionEx)_ServiceProvider.GetService(typeof(IVsTrackSelectionEx));
                 if (ex != null)
                 {
                     object varValue = cxt;
                     NativeMethods.ThrowOnFailure(ex.OnElementValueChange(5, 0, varValue));
                 }
             }
         }
     }
 }
Beispiel #2
0
        /// <devdoc>
        ///     Called to notify the IDE that our user context has changed.
        /// </devdoc>
        private void NotifyContextChange(IVsUserContext cxt)
        {
            if (provider == null)
            {
                return;
            }

            IVsUserContext        currentContext = null;
            IVsMonitorUserContext muc            = (IVsMonitorUserContext)provider.GetService(typeof(IVsMonitorUserContext));

            if (muc != null)
            {
                NativeMethods.ThrowOnFailure(muc.get_ApplicationContext(out currentContext));
            }

            if (currentContext == cxt)
            {
                return;
            }


            IVsTrackSelectionEx ts = (IVsTrackSelectionEx)provider.GetService(typeof(IVsTrackSelectionEx));

            if (ts != null)
            {
                Object obj = cxt;

                NativeMethods.ThrowOnFailure(ts.OnElementValueChange(5 /* SEID_UserContext */, 0, obj));
            }
        }
Beispiel #3
0
    public static HelpContext2 GetHelpContext(DTE2 dte)
    {
        // Get a reference to the current active window (presumably a code editor).
        Window activeWindow = dte.ActiveWindow;

        // make a few gnarly COM-interop calls in order to get Help Context
        Microsoft.VisualStudio.OLE.Interop.IServiceProvider sp = (Microsoft.VisualStudio.OLE.Interop.IServiceProvider)activeWindow.DTE;
        Microsoft.VisualStudio.Shell.ServiceProvider        serviceProvider = new Microsoft.VisualStudio.Shell.ServiceProvider(sp);
        IVsMonitorUserContext contextMonitor = (IVsMonitorUserContext)serviceProvider.GetService(typeof(IVsMonitorUserContext));
        IVsUserContext        userContext;
        int          hresult = contextMonitor.get_ApplicationContext(out userContext);
        HelpContext2 attrs   = new HelpContext2(userContext);

        return(attrs);
    }