/// <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)); } }
object GetOwnerForSelectedSelectionContainer() { Shell.ThreadHelper.ThrowIfNotOnUIThread(); // Get the selection context object for propagator of the element // Enumerate the frames and compare their context to the propagator // to find its owner. IVsTrackSelectionEx selectionContainerCtx = null; if (IsRunningOnDev12) { var selectionMonitorPrivate = (Microsoft.Internal.VisualStudio.Shell.Interop.Dev12.IVsMonitorSelectionExPrivate)Package.GetGlobalService(typeof(SVsShellMonitorSelection)); if (selectionMonitorPrivate != null) { selectionMonitorPrivate.GetContextOfSelection(out _, out selectionContainerCtx); } } else { var selectionMonitorPrivate = (Microsoft.Internal.VisualStudio.Shell.Interop.Dev11.IVsMonitorSelectionExPrivate)Package.GetGlobalService(typeof(SVsShellMonitorSelection)); if (selectionMonitorPrivate != null) { selectionMonitorPrivate.GetContextOfSelection(out _, out selectionContainerCtx); } } if (selectionContainerCtx != null) { return(GetContextOwner(selectionContainerCtx)); } return(null); }
protected override void Initialize() { base.Initialize(); var componentModel = this.GetService <SComponentModel, IComponentModel>(); componentModel.DefaultCompositionService.SatisfyImportsOnce(this); this.trackSelection = this.GetService <SVsTrackSelectionEx, IVsTrackSelectionEx>(); Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(this.trackSelection.OnSelectChange(this.selectionContainer)); var shell = this.GetService <SVsUIShell, IVsUIShell>(); var context = new SolutionBuilderContext { PatternManager = this.PatternManager, UserMessageService = this.UserMessageService, BindingFactory = this.BindingFactory, NewProductDialogFactory = ctx => shell.CreateDialog <AddNewProductView>(ctx), NewNodeDialogFactory = ctx => shell.CreateDialog <AddNewNodeView>(ctx), ShowProperties = this.ShowProperties }; this.viewModel = new SolutionBuilderViewModel(context, this.ServiceProvider); this.Content = new SolutionBuilderView { DataContext = this.viewModel }; }
protected override void Initialize() { base.Initialize(); var componentModel = this.GetService<SComponentModel, IComponentModel>(); componentModel.DefaultCompositionService.SatisfyImportsOnce(this); this.trackSelection = this.GetService<SVsTrackSelectionEx, IVsTrackSelectionEx>(); Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(this.trackSelection.OnSelectChange(this.selectionContainer)); var shell = this.GetService<SVsUIShell, IVsUIShell>(); var context = new SolutionBuilderContext { PatternManager = this.PatternManager, UserMessageService = this.UserMessageService, BindingFactory = this.BindingFactory, NewProductDialogFactory = ctx => shell.CreateDialog<AddNewProductView>(ctx), NewNodeDialogFactory = ctx => shell.CreateDialog<AddNewNodeView>(ctx), ShowProperties = this.ShowProperties }; this.viewModel = new SolutionBuilderViewModel(context, this.ServiceProvider); this.Content = new SolutionBuilderView { DataContext = this.viewModel }; }
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)); } } } } }
void SetPropertyWindow() { IVsTrackSelectionEx track = _serviceProvider.GetService(typeof(SVsTrackSelectionEx)) as IVsTrackSelectionEx; if (track != null) { track.OnSelectChange(this); } }
bool IsEmptySelectionContext(IVsTrackSelectionEx selCtx) { ThreadHelper.ThrowIfNotOnUIThread(); Validate.IsNotNull(selCtx, "selCtx"); IVsMonitorSelection2 monitorSelection2 = Package.GetGlobalService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection2; monitorSelection2.GetEmptySelectionContext(out var emptySelCtxt); return(ComUtilities.IsSameComObject(selCtx, emptySelCtxt)); }
/// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="DocumentProperties.Close"]/*' /> public void Close() { if (this.tracker != null && this.visible) { NativeMethods.ThrowOnFailure(tracker.OnSelectChange(null)); } this.tracker = null; this.mgr = null; }
/// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="DocumentProperties.Dispose"]/*' /> protected virtual void Dispose(bool disposing) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { // Dispose managed resources. } this.tracker = null; this.mgr = null; }
/// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="DocumentProperties.DocumentProperties"]/*' /> protected DocumentProperties(CodeWindowManager mgr) { this.mgr = mgr; this.visible = true; if (mgr != null) { IOleServiceProvider sp = mgr.CodeWindow as IOleServiceProvider; if (sp != null) { ServiceProvider site = new ServiceProvider(sp); this.tracker = site.GetService(typeof(SVsTrackSelectionEx)) as IVsTrackSelectionEx; } } }
/// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="DocumentProperties.DocumentProperties"]/*' /> protected DocumentProperties(CodeWindowManager mgr) { this.mgr = mgr; this.visible = true; if (mgr != null) { IOleServiceProvider sp = mgr.CodeWindow as IOleServiceProvider; if (sp != null) { ServiceProvider site = new ServiceProvider(sp); this.tracker = site.GetService(typeof(SVsTrackSelectionEx)) as IVsTrackSelectionEx; } } }
/// <summary> /// Enumerate the window frames looking for the owner of the context /// </summary> /// <param name="selCtx"></param> /// <returns></returns> object GetContextOwner(IVsTrackSelectionEx selCtx) { ThreadHelper.ThrowIfNotOnUIThread(); if (selCtx == null) { return(null); } // No frame owns the empty selection context, just return it as its own owner. if (IsEmptySelectionContext(selCtx)) { return(selCtx); } IVsUIShell4 shell4 = Package.GetGlobalService(typeof(SVsUIShell)) as IVsUIShell4; Guid trackSelectionExServiceGuid = typeof(SVsTrackSelectionEx).GUID; Guid trackSelecitonExGuid = typeof(IVsTrackSelectionEx).GUID; shell4.GetWindowEnum((uint)__WindowFrameTypeFlags.WINDOWFRAMETYPE_All, out var frameEnum); foreach (IVsWindowFrame frame in ComUtilities.EnumerableFrom(frameEnum)) { if (ErrorHandler.Succeeded(frame.GetProperty((int)__VSFPROPID.VSFPROPID_SPFrame, out var frameServiceProvider)) && frameServiceProvider != null) { IntPtr pTrackSelection = IntPtr.Zero; try { if (ErrorHandler.Succeeded(((IOleServiceProvider)frameServiceProvider).QueryService(ref trackSelectionExServiceGuid, ref trackSelecitonExGuid, out pTrackSelection))) { IVsTrackSelectionEx frameCtx = Marshal.GetObjectForIUnknown(pTrackSelection) as IVsTrackSelectionEx; if (ComUtilities.IsSameComObject(selCtx, frameCtx)) { return(frame); } } } finally { if (pTrackSelection != IntPtr.Zero) { Marshal.Release(pTrackSelection); } } } } return(null); }
/// <include file='doc\HelpService.uex' path='docs/doc[@for="HelpService.NotifyContextChange"]/*' /> /// <devdoc> /// Called to notify the IDE that our user context has changed. /// </devdoc> private void NotifyContextChange(IVsUserContext cxt) { if (provider == null || !notifySelection) { return; } IVsTrackSelectionEx ts = (IVsTrackSelectionEx)provider.GetService(typeof(IVsTrackSelectionEx)); if (ts != null) { Object obj = cxt; ts.OnElementValueChange(5 /* SEID_UserContext */, 0, obj); } }
protected override void Initialize() { base.Initialize(); var componentModel = this.GetService<SComponentModel, IComponentModel>(); componentModel.DefaultCompositionService.SatisfyImportsOnce(this); this.trackSelection = this.GetService<SVsTrackSelectionEx, IVsTrackSelectionEx>(); Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(this.trackSelection.OnSelectChange(this.selectionContainer)); var context = new GuidanceWorkflowContext { GuidanceManager = this.GuidanceManager, Extension = this.GuidanceManager.ActiveGuidanceExtension, UserMessageService = this.UserMessageService, }; this.viewModel = new GuidanceExplorerViewModel(context, this.ServiceProvider); this.Content = new GuidanceExplorerView { DataContext = this.viewModel }; }
protected override void Initialize() { base.Initialize(); var componentModel = this.GetService <SComponentModel, IComponentModel>(); componentModel.DefaultCompositionService.SatisfyImportsOnce(this); this.trackSelection = this.GetService <SVsTrackSelectionEx, IVsTrackSelectionEx>(); Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(this.trackSelection.OnSelectChange(this.selectionContainer)); var context = new GuidanceWorkflowContext { GuidanceManager = this.GuidanceManager, Extension = this.GuidanceManager.ActiveGuidanceExtension, UserMessageService = this.UserMessageService, }; this.viewModel = new GuidanceExplorerViewModel(context, this.ServiceProvider); this.Content = new GuidanceExplorerView { DataContext = this.viewModel }; }
public int GetEmptySelectionContext(out IVsTrackSelectionEx ppEmptySelCtxt) { ppEmptySelCtxt = _emptyCtx; return(VSConstants.S_OK); }
/// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="DocumentProperties.Dispose"]/*' /> protected virtual void Dispose(bool disposing) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { // Dispose managed resources. } this.tracker = null; this.mgr = null; }
public int GetEmptySelectionContext(out IVsTrackSelectionEx ppEmptySelCtxt) { ppEmptySelCtxt = _emptyCtx; return VSConstants.S_OK; }
/// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="DocumentProperties.Close"]/*' /> public void Close() { if (this.tracker != null && this.visible) NativeMethods.ThrowOnFailure(tracker.OnSelectChange(null)); this.tracker = null; this.mgr = null; }