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
var newSuggestions = new List < NavigationBarSuggestionItem > ( ) ;
1152
1169
@@ -1187,22 +1204,27 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
1187
1204
}
1188
1205
}
1189
1206
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
+ } ) ;
1206
1228
1207
1229
newSuggestions . AddRange ( suggestionItems ) ;
1208
1230
@@ -1248,7 +1270,37 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
1248
1270
}
1249
1271
}
1250
1272
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." ) ]
1252
1304
public async Task SetAddressBarSuggestionsAsync ( AutoSuggestBox sender , IShellPage shellpage )
1253
1305
{
1254
1306
if ( sender . Text is not null && shellpage . ShellViewModel is not null )
0 commit comments