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 EnableOmnibar => GeneralSettingsService . EnableOmnibar ;
@@ -93,6 +95,7 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
93
95
94
96
private NavigationToolbar ? AddressToolbar => ( MainWindow . Instance . Content as Frame ) ? . FindDescendant < NavigationToolbar > ( ) ;
95
97
98
+ [ Obsolete ( "Superseded by Omnibar." ) ]
96
99
public SearchBoxViewModel SearchBoxViewModel => ( SearchBoxViewModel ) SearchBox ;
97
100
98
101
public bool HasAdditionalAction =>
@@ -186,15 +189,19 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
186
189
public bool CanRefresh { get => _CanRefresh ; set => SetProperty ( ref _CanRefresh , value ) ; }
187
190
188
191
private string _SearchButtonGlyph = "\uE721 " ;
192
+ [ Obsolete ( "Superseded by Omnibar." ) ]
189
193
public string SearchButtonGlyph { get => _SearchButtonGlyph ; set => SetProperty ( ref _SearchButtonGlyph , value ) ; }
190
194
191
195
private bool _ManualEntryBoxLoaded ;
196
+ [ Obsolete ( "Superseded by Omnibar." ) ]
192
197
public bool ManualEntryBoxLoaded { get => _ManualEntryBoxLoaded ; set => SetProperty ( ref _ManualEntryBoxLoaded , value ) ; }
193
198
194
199
private bool _ClickablePathLoaded = true ;
200
+ [ Obsolete ( "Superseded by Omnibar." ) ]
195
201
public bool ClickablePathLoaded { get => _ClickablePathLoaded ; set => SetProperty ( ref _ClickablePathLoaded , value ) ; }
196
202
197
203
private string _PathControlDisplayText ;
204
+ [ Obsolete ( "Superseded by Omnibar." ) ]
198
205
public string PathControlDisplayText { get => _PathControlDisplayText ; set => SetProperty ( ref _PathControlDisplayText , value ) ; }
199
206
200
207
private bool _HasItem = false ;
@@ -204,9 +211,11 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
204
211
public Style LayoutThemedIcon { get => _LayoutThemedIcon ; set => SetProperty ( ref _LayoutThemedIcon , value ) ; }
205
212
206
213
private ISearchBoxViewModel _SearchBox = new SearchBoxViewModel ( ) ;
214
+ [ Obsolete ( "Superseded by Omnibar." ) ]
207
215
public ISearchBoxViewModel SearchBox { get => _SearchBox ; set => SetProperty ( ref _SearchBox , value ) ; }
208
216
209
217
private bool _IsSearchBoxVisible ;
218
+ [ Obsolete ( "Superseded by Omnibar." ) ]
210
219
public bool IsSearchBoxVisible
211
220
{
212
221
get => _IsSearchBoxVisible ;
@@ -236,11 +245,7 @@ public string? PathText
236
245
public string ? OmnibarSearchModeText { get => _OmnibarSearchModeText ; set => SetProperty ( ref _OmnibarSearchModeText , value ) ; }
237
246
238
247
private string _OmnibarCurrentSelectedModeName = OmnibarPathModeName ;
239
- public string OmnibarCurrentSelectedModeName
240
- {
241
- get => _OmnibarCurrentSelectedModeName ;
242
- set => SetProperty ( ref _OmnibarCurrentSelectedModeName , value ) ;
243
- }
248
+ public string OmnibarCurrentSelectedModeName { get => _OmnibarCurrentSelectedModeName ; set => SetProperty ( ref _OmnibarCurrentSelectedModeName , value ) ; }
244
249
245
250
private CurrentInstanceViewModel _InstanceViewModel ;
246
251
public CurrentInstanceViewModel InstanceViewModel
@@ -540,6 +545,7 @@ x.Item is ZipStorageFile ||
540
545
deferral . Complete ( ) ;
541
546
}
542
547
548
+ [ Obsolete ( "Superseded by Omnibar." ) ]
543
549
public void PathItemSeparator_DataContextChanged ( FrameworkElement sender , DataContextChangedEventArgs args )
544
550
{
545
551
var pathSeparatorIcon = sender as FontIcon ;
@@ -553,35 +559,41 @@ public void PathItemSeparator_DataContextChanged(FrameworkElement sender, DataCo
553
559
} ) ;
554
560
}
555
561
562
+ [ Obsolete ( "Superseded by Omnibar." ) ]
556
563
public void PathboxItemFlyout_Opening ( object sender , object e )
557
564
{
558
565
ToolbarFlyoutOpening ? . Invoke ( this , new ToolbarFlyoutOpeningEventArgs ( ( MenuFlyout ) sender ) ) ;
559
566
}
560
567
568
+ [ Obsolete ( "Superseded by Omnibar." ) ]
561
569
public void PathBoxItemFlyout_Closed ( object sender , object e )
562
570
{
563
571
( ( MenuFlyout ) sender ) . Items . Clear ( ) ;
564
572
}
565
573
574
+ [ Obsolete ( "Superseded by Omnibar." ) ]
566
575
public void CurrentPathSetTextBox_TextChanged ( object sender , TextChangedEventArgs args )
567
576
{
568
577
if ( sender is TextBox textBox )
569
578
PathBoxQuerySubmitted ? . Invoke ( this , new ToolbarQuerySubmittedEventArgs ( ) { QueryText = textBox . Text } ) ;
570
579
}
571
580
581
+ [ Obsolete ( "Superseded by Omnibar." ) ]
572
582
public void VisiblePath_TextChanged ( AutoSuggestBox sender , AutoSuggestBoxTextChangedEventArgs args )
573
583
{
574
584
if ( args . Reason == AutoSuggestionBoxTextChangeReason . UserInput )
575
585
AddressBarTextEntered ? . Invoke ( this , new AddressBarTextEnteredEventArgs ( ) { AddressBarTextField = sender } ) ;
576
586
}
577
587
588
+ [ Obsolete ( "Superseded by Omnibar." ) ]
578
589
public void VisiblePath_QuerySubmitted ( AutoSuggestBox sender , AutoSuggestBoxQuerySubmittedEventArgs args )
579
590
{
580
591
PathBoxQuerySubmitted ? . Invoke ( this , new ToolbarQuerySubmittedEventArgs ( ) { QueryText = args . QueryText } ) ;
581
592
582
593
( this as IAddressToolbarViewModel ) . IsEditModeEnabled = false ;
583
594
}
584
595
596
+ [ Obsolete ( "Superseded by Omnibar." ) ]
585
597
public void PathBoxItem_PointerPressed ( object sender , PointerRoutedEventArgs e )
586
598
{
587
599
if ( e . Pointer . PointerDeviceType != Microsoft . UI . Input . PointerDeviceType . Mouse )
@@ -710,6 +722,7 @@ await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidItemDialogTitle.GetLoca
710
722
PathControlDisplayText = ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ;
711
723
}
712
724
725
+ [ Obsolete ( "Superseded by Omnibar." ) ]
713
726
public void PathBoxItem_PreviewKeyDown ( object sender , KeyRoutedEventArgs e )
714
727
{
715
728
switch ( e . Key )
@@ -794,6 +807,7 @@ public void UpdateAdditionalActions()
794
807
OnPropertyChanged ( nameof ( HasAdditionalAction ) ) ;
795
808
}
796
809
810
+ [ Obsolete ( "Superseded by Omnibar." ) ]
797
811
private void CloseSearchBox ( bool doFocus = false )
798
812
{
799
813
if ( _SearchBox . WasQuerySubmitted )
@@ -818,11 +832,13 @@ private void CloseSearchBox(bool doFocus = false)
818
832
}
819
833
}
820
834
835
+ [ Obsolete ( "Superseded by Omnibar." ) ]
821
836
public void SearchRegion_GotFocus ( object sender , RoutedEventArgs e )
822
837
{
823
838
SearchHasFocus = true ;
824
839
}
825
840
841
+ [ Obsolete ( "Superseded by Omnibar." ) ]
826
842
public void SearchRegion_LostFocus ( object sender , RoutedEventArgs e )
827
843
{
828
844
var element = Microsoft . UI . Xaml . Input . FocusManager . GetFocusedElement ( ) ;
@@ -833,6 +849,7 @@ public void SearchRegion_LostFocus(object sender, RoutedEventArgs e)
833
849
CloseSearchBox ( ) ;
834
850
}
835
851
852
+ [ Obsolete ( "Superseded by Omnibar." ) ]
836
853
private void SearchRegion_Escaped ( object ? sender , ISearchBoxViewModel _SearchBox )
837
854
=> CloseSearchBox ( true ) ;
838
855
@@ -1153,7 +1170,7 @@ void AddNoResultsItem()
1153
1170
}
1154
1171
}
1155
1172
1156
- public void PopulateOmnibarSuggestionsForCommandPaletteMode ( )
1173
+ public async Task PopulateOmnibarSuggestionsForCommandPaletteMode ( )
1157
1174
{
1158
1175
var newSuggestions = new List < NavigationBarSuggestionItem > ( ) ;
1159
1176
@@ -1194,22 +1211,27 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
1194
1211
}
1195
1212
}
1196
1213
1197
- var suggestionItems = Commands
1198
- . Where ( command => command . IsExecutable
1199
- && command . IsAccessibleGlobally
1200
- && ( command . Description . Contains ( OmnibarCommandPaletteModeText , StringComparison . OrdinalIgnoreCase )
1201
- || command . Code . ToString ( ) . Contains ( OmnibarCommandPaletteModeText , StringComparison . OrdinalIgnoreCase ) ) )
1202
- . Select ( command => new NavigationBarSuggestionItem
1203
- {
1204
- ThemedIconStyle = command . Glyph . ToThemedIconStyle ( ) ,
1205
- Glyph = command . Glyph . BaseGlyph ,
1206
- Text = command . Description ,
1207
- PrimaryDisplay = command . Description ,
1208
- HotKeys = command . HotKeys ,
1209
- SearchText = OmnibarCommandPaletteModeText ,
1210
- } )
1211
- . Where ( item => item . Text != Commands . OpenCommandPalette . Description . ToString ( )
1212
- && item . Text != Commands . EditPath . Description . ToString ( ) ) ;
1214
+ IEnumerable < NavigationBarSuggestionItem > suggestionItems = null ! ;
1215
+
1216
+ await Task . Run ( ( ) =>
1217
+ {
1218
+ suggestionItems = Commands
1219
+ . Where ( command => command . IsExecutable
1220
+ && command . IsAccessibleGlobally
1221
+ && ( command . Description . Contains ( OmnibarCommandPaletteModeText , StringComparison . OrdinalIgnoreCase )
1222
+ || command . Code . ToString ( ) . Contains ( OmnibarCommandPaletteModeText , StringComparison . OrdinalIgnoreCase ) ) )
1223
+ . Select ( command => new NavigationBarSuggestionItem
1224
+ {
1225
+ ThemedIconStyle = command . Glyph . ToThemedIconStyle ( ) ,
1226
+ Glyph = command . Glyph . BaseGlyph ,
1227
+ Text = command . Description ,
1228
+ PrimaryDisplay = command . Description ,
1229
+ HotKeys = command . HotKeys ,
1230
+ SearchText = OmnibarCommandPaletteModeText ,
1231
+ } )
1232
+ . Where ( item => item . Text != Commands . OpenCommandPalette . Description . ToString ( )
1233
+ && item . Text != Commands . EditPath . Description . ToString ( ) ) ;
1234
+ } ) ;
1213
1235
1214
1236
newSuggestions . AddRange ( suggestionItems ) ;
1215
1237
@@ -1257,20 +1279,19 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
1257
1279
1258
1280
public async Task PopulateOmnibarSuggestionsForSearchMode ( )
1259
1281
{
1282
+ OmnibarSearchModeSuggestionItems . Clear ( ) ;
1283
+
1260
1284
if ( ContentPageContext . ShellPage is null )
1261
1285
return ;
1262
1286
1263
- List < SuggestionModel > newSuggestions = [ ] ;
1287
+ ContentPageContext . ShellPage . ShellViewModel . FilesAndFoldersFilter = OmnibarSearchModeText ;
1264
1288
1265
- if ( string . IsNullOrWhiteSpace ( OmnibarSearchModeText ) )
1266
- {
1267
- var previousSearchQueries = UserSettingsService . GeneralSettingsService . PreviousSearchQueriesList ;
1268
- if ( previousSearchQueries is not null )
1269
- newSuggestions . AddRange ( previousSearchQueries . Select ( query => new SuggestionModel ( query , true ) ) ) ;
1270
- }
1271
- else
1289
+ // Refresh the browser to apply the search filter
1290
+ await ContentPageContext . ShellPage . ShellViewModel . ApplyFilesAndFoldersChangesAsync ( ) ;
1291
+
1292
+ if ( ! string . IsNullOrWhiteSpace ( OmnibarSearchModeText ) )
1272
1293
{
1273
- var search = new FolderSearch
1294
+ var search = new FolderSearch ( )
1274
1295
{
1275
1296
Query = OmnibarSearchModeText ,
1276
1297
Folder = ContentPageContext . ShellPage . ShellViewModel . WorkingDirectory ,
@@ -1298,7 +1319,7 @@ public async Task PopulateOmnibarSuggestionsForSearchMode()
1298
1319
}
1299
1320
1300
1321
1301
- [ Obsolete ( "Remove once Omnibar goes out of experimental ." ) ]
1322
+ [ Obsolete ( "Superseded by Omnibar." ) ]
1302
1323
public async Task SetAddressBarSuggestionsAsync ( AutoSuggestBox sender , IShellPage shellpage )
1303
1324
{
1304
1325
if ( sender . Text is not null && shellpage . ShellViewModel is not null )
0 commit comments