@@ -1019,39 +1019,55 @@ private async Task<IVsWindowFrame> CreateDocWindowForSolutionAsync()
10191019
10201020 private void ShowManageLibraryPackageForSolutionDialog ( object sender , EventArgs e )
10211021 {
1022- NuGetUIThreadHelper . JoinableTaskFactory . RunAsync ( async delegate
1022+ PackageManagerShowOptions options = null ;
1023+ if ( e is OleMenuCmdEventArgs eventArgs )
10231024 {
1024- await NuGetUIThreadHelper . JoinableTaskFactory . SwitchToMainThreadAsync ( ) ;
1025-
1026- if ( ShouldInitializeSolutionExperiences ( ) )
1025+ if ( eventArgs ? . InValue is string parameterString )
10271026 {
1028- await InitializeSolutionExperiencesAsync ( ) ;
1027+ options = new PackageManagerShowOptions ( ) { SearchText = parameterString } ;
10291028 }
1030-
1031- var windowFrame = await FindExistingSolutionWindowFrameAsync ( ) ;
1032- if ( windowFrame == null )
1029+ else if ( eventArgs ? . InValue is PackageManagerShowOptions parameterOptions )
10331030 {
1034- // Create the window frame
1035- windowFrame = await CreateDocWindowForSolutionAsync ( ) ;
1031+ options = parameterOptions ;
10361032 }
1037-
1038- if ( windowFrame != null )
1033+ else
10391034 {
1040- // process search string
1041- string parameterString = null ;
1042- var args = e as OleMenuCmdEventArgs ;
1043- if ( args != null )
1044- {
1045- parameterString = args . InValue as string ;
1046- }
1047- var searchText = GetSearchText ( parameterString ) ;
1048- Search ( windowFrame , searchText ) ;
1049-
1050- windowFrame . Show ( ) ;
1035+ options = new PackageManagerShowOptions ( ) ;
10511036 }
1037+ }
1038+
1039+ NuGetUIThreadHelper . JoinableTaskFactory . RunAsync ( async delegate
1040+ {
1041+ await ShowManageLibraryPackageForSolutionDialogAsync ( options ) ;
10521042 } ) . PostOnFailure ( nameof ( NuGetPackage ) , nameof ( ShowManageLibraryPackageForSolutionDialog ) ) ;
10531043 }
10541044
1045+ private async Task < IVsWindowFrame > ShowManageLibraryPackageForSolutionDialogAsync ( PackageManagerShowOptions options )
1046+ {
1047+ string searchText = GetSearchText ( options . SearchText ) ;
1048+
1049+ await NuGetUIThreadHelper . JoinableTaskFactory . SwitchToMainThreadAsync ( ) ;
1050+
1051+ if ( ShouldInitializeSolutionExperiences ( ) )
1052+ {
1053+ await InitializeSolutionExperiencesAsync ( ) ;
1054+ }
1055+
1056+ var windowFrame = await FindExistingSolutionWindowFrameAsync ( ) ;
1057+ // Create the window frame
1058+ windowFrame ??= await CreateDocWindowForSolutionAsync ( ) ;
1059+
1060+ if ( windowFrame != null )
1061+ {
1062+ SelectActiveItemFilter ( windowFrame , options . ItemFilter ) ;
1063+ SelectFilterOptions ( windowFrame , options . PackageFilterOptions ) ;
1064+ Search ( windowFrame , searchText ) ;
1065+ windowFrame . Show ( ) ;
1066+ }
1067+
1068+ return windowFrame ;
1069+ }
1070+
10551071 /// <summary>
10561072 /// Search for packages using the searchText.
10571073 /// </summary>
@@ -1090,6 +1106,31 @@ private void ShowUpdatePackages(IVsWindowFrame windowFrame, ShowUpdatePackageOpt
10901106 packageManagerControl ? . ShowUpdatePackages ( updatePackageOptions ) ;
10911107 }
10921108
1109+ private static void SelectActiveItemFilter ( IVsWindowFrame windowFrame , UI . ItemFilter ? itemFilter )
1110+ {
1111+ ThreadHelper . ThrowIfNotOnUIThread ( ) ;
1112+
1113+ if ( itemFilter . HasValue )
1114+ {
1115+ var packageManagerControl = VsUtility . GetPackageManagerControl ( windowFrame ) ;
1116+ if ( packageManagerControl != null )
1117+ {
1118+ packageManagerControl . ActiveFilter = itemFilter . Value ;
1119+ }
1120+ }
1121+ }
1122+
1123+ private static void SelectFilterOptions ( IVsWindowFrame windowFrame , PackageFilterOptions packageFilterOptions )
1124+ {
1125+ ThreadHelper . ThrowIfNotOnUIThread ( ) ;
1126+
1127+ if ( packageFilterOptions != null )
1128+ {
1129+ var packageManagerControl = VsUtility . GetPackageManagerControl ( windowFrame ) ;
1130+ packageManagerControl ? . SelectPackageFilterOptions ( packageFilterOptions ) ;
1131+ }
1132+ }
1133+
10931134 // For PowerShell, it's okay to query from the worker thread.
10941135 private void BeforeQueryStatusForPowerConsole ( object sender , EventArgs args )
10951136 {
0 commit comments