12
12
using Microsoft . UI . Xaml . Input ;
13
13
using Microsoft . UI . Xaml . Media . Imaging ;
14
14
using System . IO ;
15
+ using System . Threading . Tasks ;
15
16
using System . Windows . Input ;
16
17
using Windows . AI . Actions ;
17
18
using Windows . ApplicationModel . DataTransfer ;
@@ -82,6 +83,7 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
82
83
83
84
public bool IsSingleItemOverride { get ; set ; }
84
85
86
+ [ Obsolete ( "Superseded by Omnibar." ) ]
85
87
public bool SearchHasFocus { get ; private set ; }
86
88
87
89
public bool ShowHomeButton => AppearanceSettingsService . ShowHomeButton ;
@@ -94,6 +96,7 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
94
96
95
97
private NavigationToolbar ? AddressToolbar => ( MainWindow . Instance . Content as Frame ) ? . FindDescendant < NavigationToolbar > ( ) ;
96
98
99
+ [ Obsolete ( "Superseded by Omnibar." ) ]
97
100
public SearchBoxViewModel SearchBoxViewModel => ( SearchBoxViewModel ) SearchBox ;
98
101
99
102
public bool HasAdditionalAction =>
@@ -187,15 +190,19 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
187
190
public bool CanRefresh { get => _CanRefresh ; set => SetProperty ( ref _CanRefresh , value ) ; }
188
191
189
192
private string _SearchButtonGlyph = "\uE721 " ;
193
+ [ Obsolete ( "Superseded by Omnibar." ) ]
190
194
public string SearchButtonGlyph { get => _SearchButtonGlyph ; set => SetProperty ( ref _SearchButtonGlyph , value ) ; }
191
195
192
196
private bool _ManualEntryBoxLoaded ;
197
+ [ Obsolete ( "Superseded by Omnibar." ) ]
193
198
public bool ManualEntryBoxLoaded { get => _ManualEntryBoxLoaded ; set => SetProperty ( ref _ManualEntryBoxLoaded , value ) ; }
194
199
195
200
private bool _ClickablePathLoaded = true ;
201
+ [ Obsolete ( "Superseded by Omnibar." ) ]
196
202
public bool ClickablePathLoaded { get => _ClickablePathLoaded ; set => SetProperty ( ref _ClickablePathLoaded , value ) ; }
197
203
198
204
private string _PathControlDisplayText ;
205
+ [ Obsolete ( "Superseded by Omnibar." ) ]
199
206
public string PathControlDisplayText { get => _PathControlDisplayText ; set => SetProperty ( ref _PathControlDisplayText , value ) ; }
200
207
201
208
private bool _HasItem = false ;
@@ -205,9 +212,11 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
205
212
public Style LayoutThemedIcon { get => _LayoutThemedIcon ; set => SetProperty ( ref _LayoutThemedIcon , value ) ; }
206
213
207
214
private ISearchBoxViewModel _SearchBox = new SearchBoxViewModel ( ) ;
215
+ [ Obsolete ( "Superseded by Omnibar." ) ]
208
216
public ISearchBoxViewModel SearchBox { get => _SearchBox ; set => SetProperty ( ref _SearchBox , value ) ; }
209
217
210
218
private bool _IsSearchBoxVisible ;
219
+ [ Obsolete ( "Superseded by Omnibar." ) ]
211
220
public bool IsSearchBoxVisible
212
221
{
213
222
get => _IsSearchBoxVisible ;
@@ -237,11 +246,7 @@ public string? PathText
237
246
public string ? OmnibarSearchModeText { get => _OmnibarSearchModeText ; set => SetProperty ( ref _OmnibarSearchModeText , value ) ; }
238
247
239
248
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 ) ; }
245
250
246
251
private CurrentInstanceViewModel _InstanceViewModel ;
247
252
public CurrentInstanceViewModel InstanceViewModel
@@ -544,6 +549,7 @@ x.Item is ZipStorageFile ||
544
549
deferral . Complete ( ) ;
545
550
}
546
551
552
+ [ Obsolete ( "Superseded by Omnibar." ) ]
547
553
public void PathItemSeparator_DataContextChanged ( FrameworkElement sender , DataContextChangedEventArgs args )
548
554
{
549
555
var pathSeparatorIcon = sender as FontIcon ;
@@ -557,35 +563,41 @@ public void PathItemSeparator_DataContextChanged(FrameworkElement sender, DataCo
557
563
} ) ;
558
564
}
559
565
566
+ [ Obsolete ( "Superseded by Omnibar." ) ]
560
567
public void PathboxItemFlyout_Opening ( object sender , object e )
561
568
{
562
569
ToolbarFlyoutOpening ? . Invoke ( this , new ToolbarFlyoutOpeningEventArgs ( ( MenuFlyout ) sender ) ) ;
563
570
}
564
571
572
+ [ Obsolete ( "Superseded by Omnibar." ) ]
565
573
public void PathBoxItemFlyout_Closed ( object sender , object e )
566
574
{
567
575
( ( MenuFlyout ) sender ) . Items . Clear ( ) ;
568
576
}
569
577
578
+ [ Obsolete ( "Superseded by Omnibar." ) ]
570
579
public void CurrentPathSetTextBox_TextChanged ( object sender , TextChangedEventArgs args )
571
580
{
572
581
if ( sender is TextBox textBox )
573
582
PathBoxQuerySubmitted ? . Invoke ( this , new ToolbarQuerySubmittedEventArgs ( ) { QueryText = textBox . Text } ) ;
574
583
}
575
584
585
+ [ Obsolete ( "Superseded by Omnibar." ) ]
576
586
public void VisiblePath_TextChanged ( AutoSuggestBox sender , AutoSuggestBoxTextChangedEventArgs args )
577
587
{
578
588
if ( args . Reason == AutoSuggestionBoxTextChangeReason . UserInput )
579
589
AddressBarTextEntered ? . Invoke ( this , new AddressBarTextEnteredEventArgs ( ) { AddressBarTextField = sender } ) ;
580
590
}
581
591
592
+ [ Obsolete ( "Superseded by Omnibar." ) ]
582
593
public void VisiblePath_QuerySubmitted ( AutoSuggestBox sender , AutoSuggestBoxQuerySubmittedEventArgs args )
583
594
{
584
595
PathBoxQuerySubmitted ? . Invoke ( this , new ToolbarQuerySubmittedEventArgs ( ) { QueryText = args . QueryText } ) ;
585
596
586
597
( this as IAddressToolbarViewModel ) . IsEditModeEnabled = false ;
587
598
}
588
599
600
+ [ Obsolete ( "Superseded by Omnibar." ) ]
589
601
public void PathBoxItem_PointerPressed ( object sender , PointerRoutedEventArgs e )
590
602
{
591
603
if ( e . Pointer . PointerDeviceType != Microsoft . UI . Input . PointerDeviceType . Mouse )
@@ -714,6 +726,7 @@ await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidItemDialogTitle.GetLoca
714
726
PathControlDisplayText = ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ;
715
727
}
716
728
729
+ [ Obsolete ( "Superseded by Omnibar." ) ]
717
730
public void PathBoxItem_PreviewKeyDown ( object sender , KeyRoutedEventArgs e )
718
731
{
719
732
switch ( e . Key )
@@ -799,6 +812,7 @@ public void UpdateAdditionalActions()
799
812
OnPropertyChanged ( nameof ( HasAdditionalAction ) ) ;
800
813
}
801
814
815
+ [ Obsolete ( "Superseded by Omnibar." ) ]
802
816
private void CloseSearchBox ( bool doFocus = false )
803
817
{
804
818
if ( _SearchBox . WasQuerySubmitted )
@@ -823,11 +837,13 @@ private void CloseSearchBox(bool doFocus = false)
823
837
}
824
838
}
825
839
840
+ [ Obsolete ( "Superseded by Omnibar." ) ]
826
841
public void SearchRegion_GotFocus ( object sender , RoutedEventArgs e )
827
842
{
828
843
SearchHasFocus = true ;
829
844
}
830
845
846
+ [ Obsolete ( "Superseded by Omnibar." ) ]
831
847
public void SearchRegion_LostFocus ( object sender , RoutedEventArgs e )
832
848
{
833
849
var element = Microsoft . UI . Xaml . Input . FocusManager . GetFocusedElement ( ) ;
@@ -838,6 +854,7 @@ public void SearchRegion_LostFocus(object sender, RoutedEventArgs e)
838
854
CloseSearchBox ( ) ;
839
855
}
840
856
857
+ [ Obsolete ( "Superseded by Omnibar." ) ]
841
858
private void SearchRegion_Escaped ( object ? sender , ISearchBoxViewModel _SearchBox )
842
859
=> CloseSearchBox ( true ) ;
843
860
@@ -1146,7 +1163,7 @@ void AddNoResultsItem()
1146
1163
}
1147
1164
}
1148
1165
1149
- public void PopulateOmnibarSuggestionsForCommandPaletteMode ( )
1166
+ public async Task PopulateOmnibarSuggestionsForCommandPaletteMode ( )
1150
1167
{
1151
1168
if ( ContentPageContext . SelectedItems . Count == 1 && ContentPageContext . SelectedItem is not null && ! ContentPageContext . SelectedItem . IsFolder )
1152
1169
{
@@ -1185,20 +1202,25 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
1185
1202
}
1186
1203
}
1187
1204
1188
- var suggestionItems = Commands
1189
- . Where ( command => command . IsExecutable
1190
- && command . IsAccessibleGlobally
1191
- && ( command . Description . Contains ( OmnibarCommandPaletteModeText , StringComparison . OrdinalIgnoreCase )
1192
- || command . Code . ToString ( ) . Contains ( OmnibarCommandPaletteModeText , StringComparison . OrdinalIgnoreCase ) ) )
1193
- . Select ( command => new NavigationBarSuggestionItem
1194
- {
1195
- ThemedIconStyle = command . Glyph . ToThemedIconStyle ( ) ,
1196
- Glyph = command . Glyph . BaseGlyph ,
1197
- Text = command . Description ,
1198
- PrimaryDisplay = command . Description ,
1199
- HotKeys = command . HotKeys ,
1200
- SearchText = OmnibarCommandPaletteModeText ,
1201
- } ) ;
1205
+ IEnumerable < NavigationBarSuggestionItem > suggestionItems = null ! ;
1206
+
1207
+ await Task . Run ( ( ) =>
1208
+ {
1209
+ suggestionItems = Commands
1210
+ . Where ( command => command . IsExecutable
1211
+ && command . IsAccessibleGlobally
1212
+ && ( command . Description . Contains ( OmnibarCommandPaletteModeText , StringComparison . OrdinalIgnoreCase )
1213
+ || command . Code . ToString ( ) . Contains ( OmnibarCommandPaletteModeText , StringComparison . OrdinalIgnoreCase ) ) )
1214
+ . Select ( command => new NavigationBarSuggestionItem
1215
+ {
1216
+ ThemedIconStyle = command . Glyph . ToThemedIconStyle ( ) ,
1217
+ Glyph = command . Glyph . BaseGlyph ,
1218
+ Text = command . Description ,
1219
+ PrimaryDisplay = command . Description ,
1220
+ HotKeys = command . HotKeys ,
1221
+ SearchText = OmnibarCommandPaletteModeText ,
1222
+ } ) ;
1223
+ } ) ;
1202
1224
1203
1225
foreach ( var item in suggestionItems )
1204
1226
{
@@ -1216,7 +1238,37 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
1216
1238
}
1217
1239
}
1218
1240
1219
- [ Obsolete ( "Remove once Omnibar goes out of experimental." ) ]
1241
+ public async Task PopulateOmnibarSuggestionsForSearchMode ( )
1242
+ {
1243
+ OmnibarSearchModeSuggestionItems . Clear ( ) ;
1244
+
1245
+ if ( ContentPageContext . ShellPage is null )
1246
+ return ;
1247
+
1248
+ ContentPageContext . ShellPage . ShellViewModel . FilesAndFoldersFilter = OmnibarSearchModeText ;
1249
+
1250
+ // Refresh the browser to apply the search filter
1251
+ await ContentPageContext . ShellPage . ShellViewModel . ApplyFilesAndFoldersChangesAsync ( ) ;
1252
+
1253
+ if ( ! string . IsNullOrWhiteSpace ( OmnibarSearchModeText ) )
1254
+ {
1255
+ var search = new FolderSearch ( )
1256
+ {
1257
+ Query = OmnibarSearchModeText ,
1258
+ Folder = ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ,
1259
+ MaxItemCount = 10 ,
1260
+ } ;
1261
+
1262
+ foreach ( var item in await search . SearchAsync ( ) )
1263
+ OmnibarSearchModeSuggestionItems . Add ( new SuggestionModel ( item ) ) ;
1264
+ }
1265
+ else
1266
+ {
1267
+ // NOTE: Add to the recent queries
1268
+ }
1269
+ }
1270
+
1271
+ [ Obsolete ( "Superseded by Omnibar." ) ]
1220
1272
public async Task SetAddressBarSuggestionsAsync ( AutoSuggestBox sender , IShellPage shellpage )
1221
1273
{
1222
1274
if ( sender . Text is not null && shellpage . ShellViewModel is not null )
0 commit comments