1212using Microsoft . UI . Xaml . Input ;
1313using Microsoft . UI . Xaml . Media . Imaging ;
1414using System . IO ;
15+ using System . Threading . Tasks ;
1516using System . Windows . Input ;
1617using Windows . AI . Actions ;
1718using Windows . ApplicationModel . DataTransfer ;
@@ -82,6 +83,7 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
8283
8384 public bool IsSingleItemOverride { get ; set ; }
8485
86+ [ Obsolete ( "Superseded by Omnibar." ) ]
8587 public bool SearchHasFocus { get ; private set ; }
8688
8789 public bool ShowHomeButton => AppearanceSettingsService . ShowHomeButton ;
@@ -94,6 +96,7 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
9496
9597 private NavigationToolbar ? AddressToolbar => ( MainWindow . Instance . Content as Frame ) ? . FindDescendant < NavigationToolbar > ( ) ;
9698
99+ [ Obsolete ( "Superseded by Omnibar." ) ]
97100 public SearchBoxViewModel SearchBoxViewModel => ( SearchBoxViewModel ) SearchBox ;
98101
99102 public bool HasAdditionalAction =>
@@ -187,15 +190,19 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
187190 public bool CanRefresh { get => _CanRefresh ; set => SetProperty ( ref _CanRefresh , value ) ; }
188191
189192 private string _SearchButtonGlyph = "\uE721 " ;
193+ [ Obsolete ( "Superseded by Omnibar." ) ]
190194 public string SearchButtonGlyph { get => _SearchButtonGlyph ; set => SetProperty ( ref _SearchButtonGlyph , value ) ; }
191195
192196 private bool _ManualEntryBoxLoaded ;
197+ [ Obsolete ( "Superseded by Omnibar." ) ]
193198 public bool ManualEntryBoxLoaded { get => _ManualEntryBoxLoaded ; set => SetProperty ( ref _ManualEntryBoxLoaded , value ) ; }
194199
195200 private bool _ClickablePathLoaded = true ;
201+ [ Obsolete ( "Superseded by Omnibar." ) ]
196202 public bool ClickablePathLoaded { get => _ClickablePathLoaded ; set => SetProperty ( ref _ClickablePathLoaded , value ) ; }
197203
198204 private string _PathControlDisplayText ;
205+ [ Obsolete ( "Superseded by Omnibar." ) ]
199206 public string PathControlDisplayText { get => _PathControlDisplayText ; set => SetProperty ( ref _PathControlDisplayText , value ) ; }
200207
201208 private bool _HasItem = false ;
@@ -205,9 +212,11 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
205212 public Style LayoutThemedIcon { get => _LayoutThemedIcon ; set => SetProperty ( ref _LayoutThemedIcon , value ) ; }
206213
207214 private ISearchBoxViewModel _SearchBox = new SearchBoxViewModel ( ) ;
215+ [ Obsolete ( "Superseded by Omnibar." ) ]
208216 public ISearchBoxViewModel SearchBox { get => _SearchBox ; set => SetProperty ( ref _SearchBox , value ) ; }
209217
210218 private bool _IsSearchBoxVisible ;
219+ [ Obsolete ( "Superseded by Omnibar." ) ]
211220 public bool IsSearchBoxVisible
212221 {
213222 get => _IsSearchBoxVisible ;
@@ -237,11 +246,7 @@ public string? PathText
237246 public string ? OmnibarSearchModeText { get => _OmnibarSearchModeText ; set => SetProperty ( ref _OmnibarSearchModeText , value ) ; }
238247
239248 private string _OmnibarCurrentSelectedModeName = OmnibarPathModeName ;
240- public string OmnibarCurrentSelectedModeName
241- {
242- get => _OmnibarCurrentSelectedModeName ;
243- set => SetProperty ( ref _OmnibarCurrentSelectedModeName , value ) ;
244- }
249+ public string OmnibarCurrentSelectedModeName { get => _OmnibarCurrentSelectedModeName ; set => SetProperty ( ref _OmnibarCurrentSelectedModeName , value ) ; }
245250
246251 private CurrentInstanceViewModel _InstanceViewModel ;
247252 public CurrentInstanceViewModel InstanceViewModel
@@ -544,6 +549,7 @@ x.Item is ZipStorageFile ||
544549 deferral . Complete ( ) ;
545550 }
546551
552+ [ Obsolete ( "Superseded by Omnibar." ) ]
547553 public void PathItemSeparator_DataContextChanged ( FrameworkElement sender , DataContextChangedEventArgs args )
548554 {
549555 var pathSeparatorIcon = sender as FontIcon ;
@@ -557,35 +563,41 @@ public void PathItemSeparator_DataContextChanged(FrameworkElement sender, DataCo
557563 } ) ;
558564 }
559565
566+ [ Obsolete ( "Superseded by Omnibar." ) ]
560567 public void PathboxItemFlyout_Opening ( object sender , object e )
561568 {
562569 ToolbarFlyoutOpening ? . Invoke ( this , new ToolbarFlyoutOpeningEventArgs ( ( MenuFlyout ) sender ) ) ;
563570 }
564571
572+ [ Obsolete ( "Superseded by Omnibar." ) ]
565573 public void PathBoxItemFlyout_Closed ( object sender , object e )
566574 {
567575 ( ( MenuFlyout ) sender ) . Items . Clear ( ) ;
568576 }
569577
578+ [ Obsolete ( "Superseded by Omnibar." ) ]
570579 public void CurrentPathSetTextBox_TextChanged ( object sender , TextChangedEventArgs args )
571580 {
572581 if ( sender is TextBox textBox )
573582 PathBoxQuerySubmitted ? . Invoke ( this , new ToolbarQuerySubmittedEventArgs ( ) { QueryText = textBox . Text } ) ;
574583 }
575584
585+ [ Obsolete ( "Superseded by Omnibar." ) ]
576586 public void VisiblePath_TextChanged ( AutoSuggestBox sender , AutoSuggestBoxTextChangedEventArgs args )
577587 {
578588 if ( args . Reason == AutoSuggestionBoxTextChangeReason . UserInput )
579589 AddressBarTextEntered ? . Invoke ( this , new AddressBarTextEnteredEventArgs ( ) { AddressBarTextField = sender } ) ;
580590 }
581591
592+ [ Obsolete ( "Superseded by Omnibar." ) ]
582593 public void VisiblePath_QuerySubmitted ( AutoSuggestBox sender , AutoSuggestBoxQuerySubmittedEventArgs args )
583594 {
584595 PathBoxQuerySubmitted ? . Invoke ( this , new ToolbarQuerySubmittedEventArgs ( ) { QueryText = args . QueryText } ) ;
585596
586597 ( this as IAddressToolbarViewModel ) . IsEditModeEnabled = false ;
587598 }
588599
600+ [ Obsolete ( "Superseded by Omnibar." ) ]
589601 public void PathBoxItem_PointerPressed ( object sender , PointerRoutedEventArgs e )
590602 {
591603 if ( e . Pointer . PointerDeviceType != Microsoft . UI . Input . PointerDeviceType . Mouse )
@@ -714,6 +726,7 @@ await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidItemDialogTitle.GetLoca
714726 PathControlDisplayText = ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ;
715727 }
716728
729+ [ Obsolete ( "Superseded by Omnibar." ) ]
717730 public void PathBoxItem_PreviewKeyDown ( object sender , KeyRoutedEventArgs e )
718731 {
719732 switch ( e . Key )
@@ -799,6 +812,7 @@ public void UpdateAdditionalActions()
799812 OnPropertyChanged ( nameof ( HasAdditionalAction ) ) ;
800813 }
801814
815+ [ Obsolete ( "Superseded by Omnibar." ) ]
802816 private void CloseSearchBox ( bool doFocus = false )
803817 {
804818 if ( _SearchBox . WasQuerySubmitted )
@@ -823,11 +837,13 @@ private void CloseSearchBox(bool doFocus = false)
823837 }
824838 }
825839
840+ [ Obsolete ( "Superseded by Omnibar." ) ]
826841 public void SearchRegion_GotFocus ( object sender , RoutedEventArgs e )
827842 {
828843 SearchHasFocus = true ;
829844 }
830845
846+ [ Obsolete ( "Superseded by Omnibar." ) ]
831847 public void SearchRegion_LostFocus ( object sender , RoutedEventArgs e )
832848 {
833849 var element = Microsoft . UI . Xaml . Input . FocusManager . GetFocusedElement ( ) ;
@@ -838,6 +854,7 @@ public void SearchRegion_LostFocus(object sender, RoutedEventArgs e)
838854 CloseSearchBox ( ) ;
839855 }
840856
857+ [ Obsolete ( "Superseded by Omnibar." ) ]
841858 private void SearchRegion_Escaped ( object ? sender , ISearchBoxViewModel _SearchBox )
842859 => CloseSearchBox ( true ) ;
843860
@@ -1146,7 +1163,7 @@ void AddNoResultsItem()
11461163 }
11471164 }
11481165
1149- public void PopulateOmnibarSuggestionsForCommandPaletteMode ( )
1166+ public async Task PopulateOmnibarSuggestionsForCommandPaletteMode ( )
11501167 {
11511168 var newSuggestions = new List < NavigationBarSuggestionItem > ( ) ;
11521169
@@ -1187,22 +1204,27 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
11871204 }
11881205 }
11891206
1190- var suggestionItems = Commands
1191- . Where ( command => command . IsExecutable
1192- && command . IsAccessibleGlobally
1193- && ( command . Description . Contains ( OmnibarCommandPaletteModeText , StringComparison . OrdinalIgnoreCase )
1194- || command . Code . ToString ( ) . Contains ( OmnibarCommandPaletteModeText , StringComparison . OrdinalIgnoreCase ) ) )
1195- . Select ( command => new NavigationBarSuggestionItem
1196- {
1197- ThemedIconStyle = command . Glyph . ToThemedIconStyle ( ) ,
1198- Glyph = command . Glyph . BaseGlyph ,
1199- Text = command . Description ,
1200- PrimaryDisplay = command . Description ,
1201- HotKeys = command . HotKeys ,
1202- SearchText = OmnibarCommandPaletteModeText ,
1203- } )
1204- . Where ( item => item . Text != Commands . OpenCommandPalette . Description . ToString ( )
1205- && item . Text != Commands . EditPath . Description . ToString ( ) ) ;
1207+ IEnumerable < NavigationBarSuggestionItem > suggestionItems = null ! ;
1208+
1209+ await Task . Run ( ( ) =>
1210+ {
1211+ suggestionItems = Commands
1212+ . Where ( command => command . IsExecutable
1213+ && command . IsAccessibleGlobally
1214+ && ( command . Description . Contains ( OmnibarCommandPaletteModeText , StringComparison . OrdinalIgnoreCase )
1215+ || command . Code . ToString ( ) . Contains ( OmnibarCommandPaletteModeText , StringComparison . OrdinalIgnoreCase ) ) )
1216+ . Select ( command => new NavigationBarSuggestionItem
1217+ {
1218+ ThemedIconStyle = command . Glyph . ToThemedIconStyle ( ) ,
1219+ Glyph = command . Glyph . BaseGlyph ,
1220+ Text = command . Description ,
1221+ PrimaryDisplay = command . Description ,
1222+ HotKeys = command . HotKeys ,
1223+ SearchText = OmnibarCommandPaletteModeText ,
1224+ } )
1225+ . Where ( item => item . Text != Commands . OpenCommandPalette . Description . ToString ( )
1226+ && item . Text != Commands . EditPath . Description . ToString ( ) ) ;
1227+ } ) ;
12061228
12071229 newSuggestions . AddRange ( suggestionItems ) ;
12081230
@@ -1248,7 +1270,37 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
12481270 }
12491271 }
12501272
1251- [ Obsolete ( "Remove once Omnibar goes out of experimental." ) ]
1273+ public async Task PopulateOmnibarSuggestionsForSearchMode ( )
1274+ {
1275+ OmnibarSearchModeSuggestionItems . Clear ( ) ;
1276+
1277+ if ( ContentPageContext . ShellPage is null )
1278+ return ;
1279+
1280+ ContentPageContext . ShellPage . ShellViewModel . FilesAndFoldersFilter = OmnibarSearchModeText ;
1281+
1282+ // Refresh the browser to apply the search filter
1283+ await ContentPageContext . ShellPage . ShellViewModel . ApplyFilesAndFoldersChangesAsync ( ) ;
1284+
1285+ if ( ! string . IsNullOrWhiteSpace ( OmnibarSearchModeText ) )
1286+ {
1287+ var search = new FolderSearch ( )
1288+ {
1289+ Query = OmnibarSearchModeText ,
1290+ Folder = ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ,
1291+ MaxItemCount = 10 ,
1292+ } ;
1293+
1294+ foreach ( var item in await search . SearchAsync ( ) )
1295+ OmnibarSearchModeSuggestionItems . Add ( new SuggestionModel ( item ) ) ;
1296+ }
1297+ else
1298+ {
1299+ // NOTE: Add to the recent queries
1300+ }
1301+ }
1302+
1303+ [ Obsolete ( "Superseded by Omnibar." ) ]
12521304 public async Task SetAddressBarSuggestionsAsync ( AutoSuggestBox sender , IShellPage shellpage )
12531305 {
12541306 if ( sender . Text is not null && shellpage . ShellViewModel is not null )
0 commit comments