private async Task <IVsWindowFrame> FindExistingSolutionWindowFrameAsync() { ThreadHelper.ThrowIfNotOnUIThread(); var uiShell = await GetServiceAsync(typeof(SVsUIShell)) as IVsUIShell; foreach (var windowFrame in VsUtility.GetDocumentWindows(uiShell)) { object property; var hr = windowFrame.GetProperty( (int)__VSFPROPID.VSFPROPID_DocData, out property); var packageManagerControl = VsUtility.GetPackageManagerControl(windowFrame); if (hr == VSConstants.S_OK && property is IVsSolution && packageManagerControl != null) { return(windowFrame); } } return(null); }
public void ApplyShowPreviewSetting(bool show) { ThreadHelper.ThrowIfNotOnUIThread(); var uiShell = _serviceProvider.GetService <SVsUIShell, IVsUIShell>(); foreach (var windowFrame in VsUtility.GetDocumentWindows(uiShell)) { var packageManagerControl = VsUtility.GetPackageManagerControl(windowFrame); packageManagerControl?.ApplyShowPreviewSetting(show); } }
/// <summary> /// Search for packages using the searchText. /// </summary> /// <param name="windowFrame">A window frame that hosts the PackageManagerControl.</param> /// <param name="searchText">Search text.</param> private void Search(IVsWindowFrame windowFrame, string searchText) { if (string.IsNullOrWhiteSpace(searchText)) { return; } var packageManagerControl = VsUtility.GetPackageManagerControl(windowFrame); if (packageManagerControl != null) { packageManagerControl.Search(searchText); } }
public override void ApplyShowDeprecatedFrameworkSetting(bool show) { var serviceProvider = ServiceLocator.GetInstance <IServiceProvider>(); IVsUIShell uiShell = (IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell)); foreach (var windowFrame in VsUtility.GetDocumentWindows(uiShell)) { var packageManagerControl = VsUtility.GetPackageManagerControl(windowFrame); if (packageManagerControl != null) { packageManagerControl.ApplyShowDeprecatedFrameworkSetting(show); } } }
private async Task <IVsWindowFrame> FindExistingWindowFrameAsync(Project project) { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); foreach (var windowFrame in VsUtility.GetDocumentWindows(uiShell)) { object docView; var hr = windowFrame.GetProperty( (int)__VSFPROPID.VSFPROPID_DocView, out docView); if (hr == VSConstants.S_OK && docView is PackageManagerWindowPane) { var packageManagerWindowPane = (PackageManagerWindowPane)docView; if (packageManagerWindowPane.Model.IsSolution) { // the window is the solution package manager continue; } var projects = packageManagerWindowPane.Model.Context.Projects; if (projects.Count() != 1) { continue; } IProjectContextInfo existingProject = projects.First(); IServiceBroker serviceBroker = await ServiceBrokerProvider.Value.GetAsync(); IProjectMetadataContextInfo projectMetadata = await existingProject.GetMetadataAsync( serviceBroker, CancellationToken.None); if (string.Equals(projectMetadata.Name, project.Name, StringComparison.OrdinalIgnoreCase)) { return(windowFrame); } } } return(null); }
private IVsWindowFrame FindExistingWindowFrame( Project project) { ThreadHelper.ThrowIfNotOnUIThread(); var uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); foreach (var windowFrame in VsUtility.GetDocumentWindows(uiShell)) { object docView; var hr = windowFrame.GetProperty( (int)__VSFPROPID.VSFPROPID_DocView, out docView); if (hr == VSConstants.S_OK && docView is PackageManagerWindowPane) { var packageManagerWindowPane = (PackageManagerWindowPane)docView; if (packageManagerWindowPane.Model.IsSolution) { // the window is the solution package manager continue; } var projects = packageManagerWindowPane.Model.Context.Projects; if (projects.Count() != 1) { continue; } var existingProject = projects.First(); var projectName = existingProject.GetMetadata <string>(NuGetProjectMetadataKeys.Name); if (string.Equals(projectName, project.Name, StringComparison.OrdinalIgnoreCase)) { return(windowFrame); } } } return(null); }
private IVsWindowFrame FindExistingSolutionWindowFrame() { IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); foreach (var windowFrame in VsUtility.GetDocumentWindows(uiShell)) { object property; int hr = windowFrame.GetProperty( (int)__VSFPROPID.VSFPROPID_DocData, out property); var packageManagerControl = VsUtility.GetPackageManagerControl(windowFrame); if (hr == VSConstants.S_OK && property is IVsSolution && packageManagerControl != null) { return windowFrame; } } return null; }