1
1
using Files . Common ;
2
+ using Files . Enums ;
2
3
using Files . Filesystem ;
3
4
using Files . Helpers ;
4
5
using Files . UserControls . MultitaskingControl ;
@@ -250,17 +251,14 @@ public static async Task AddNewTabByPathAsync(Type type, string path, int atInde
250
251
NavigationArg = path
251
252
} ;
252
253
tabItem . Control . ContentChanged += Control_ContentChanged ;
253
- await SetSelectedTabInfoAsync ( tabItem , path ) ;
254
+ await UpdateTabInfo ( tabItem , path ) ;
254
255
AppInstances . Insert ( atIndex == - 1 ? AppInstances . Count : atIndex , tabItem ) ;
255
256
}
256
257
257
- private static async Task SetSelectedTabInfoAsync ( TabItem selectedTabItem , string currentPath , string tabHeader = null )
258
+ private static async Task < ( string tabLocationHeader , Microsoft . UI . Xaml . Controls . IconSource tabIcon ) > GetSelectedTabInfoAsync ( string currentPath )
258
259
{
259
- selectedTabItem . AllowStorageItemDrop = true ;
260
-
261
260
string tabLocationHeader ;
262
261
Microsoft . UI . Xaml . Controls . FontIconSource fontIconSource = new Microsoft . UI . Xaml . Controls . FontIconSource ( ) ;
263
- Microsoft . UI . Xaml . Controls . IconSource tabIcon ;
264
262
fontIconSource . FontFamily = App . Current . Resources [ "FluentUIGlyphs" ] as FontFamily ;
265
263
266
264
if ( currentPath == null || currentPath == "SidebarSettings/Text" . GetLocalized ( ) )
@@ -332,7 +330,7 @@ private static async Task SetSelectedTabInfoAsync(TabItem selectedTabItem, strin
332
330
333
331
if ( matchingDrive != null )
334
332
{
335
- //Go through types and set the icon according to type
333
+ // Go through types and set the icon according to type
336
334
string type = GetDriveTypeIcon ( matchingDrive ) ;
337
335
if ( ! string . IsNullOrWhiteSpace ( type ) )
338
336
{
@@ -359,15 +357,20 @@ private static async Task SetSelectedTabInfoAsync(TabItem selectedTabItem, strin
359
357
{
360
358
fontIconSource . Glyph = "\xea55 " ; //Folder icon
361
359
tabLocationHeader = currentPath . TrimEnd ( Path . DirectorySeparatorChar , Path . AltDirectorySeparatorChar ) . Split ( '\\ ' , StringSplitOptions . RemoveEmptyEntries ) . Last ( ) ;
360
+
361
+ FilesystemResult < StorageFolderWithPath > rootItem = await FilesystemTasks . Wrap ( ( ) => DrivesManager . GetRootFromPathAsync ( currentPath ) ) ;
362
+ if ( rootItem )
363
+ {
364
+ StorageFolder currentFolder = await FilesystemTasks . Wrap ( ( ) => StorageFileExtensions . DangerousGetFolderFromPathAsync ( currentPath , rootItem ) ) ;
365
+ if ( currentFolder != null && ! string . IsNullOrEmpty ( currentFolder . DisplayName ) )
366
+ {
367
+ tabLocationHeader = currentFolder . DisplayName ;
368
+ }
369
+ }
362
370
}
363
371
}
364
- if ( tabHeader != null )
365
- {
366
- tabLocationHeader = tabHeader ;
367
- }
368
- tabIcon = fontIconSource ;
369
- selectedTabItem . Header = tabLocationHeader ;
370
- selectedTabItem . IconSource = tabIcon ;
372
+
373
+ return ( tabLocationHeader , fontIconSource ) ;
371
374
}
372
375
373
376
private static async void Control_ContentChanged ( object sender , TabItemArguments e )
@@ -382,22 +385,24 @@ private static async void Control_ContentChanged(object sender, TabItemArguments
382
385
383
386
private static async Task UpdateTabInfo ( TabItem tabItem , object navigationArg )
384
387
{
388
+ tabItem . AllowStorageItemDrop = true ;
385
389
if ( navigationArg is PaneNavigationArguments paneArgs )
386
390
{
387
- var leftHeader = ! string . IsNullOrEmpty ( paneArgs . LeftPaneNavPathParam ) ? new DirectoryInfo ( paneArgs . LeftPaneNavPathParam ) . Name : null ;
388
- var rightHeader = ! string . IsNullOrEmpty ( paneArgs . RightPaneNavPathParam ) ? new DirectoryInfo ( paneArgs . RightPaneNavPathParam ) . Name : null ;
389
- if ( leftHeader != null && rightHeader != null )
391
+ if ( ! string . IsNullOrEmpty ( paneArgs . LeftPaneNavPathParam ) && ! string . IsNullOrEmpty ( paneArgs . RightPaneNavPathParam ) )
390
392
{
391
- await SetSelectedTabInfoAsync ( tabItem , paneArgs . LeftPaneNavPathParam , $ "{ leftHeader } | { rightHeader } ") ;
393
+ var leftTabInfo = await GetSelectedTabInfoAsync ( paneArgs . LeftPaneNavPathParam ) ;
394
+ var rightTabInfo = await GetSelectedTabInfoAsync ( paneArgs . RightPaneNavPathParam ) ;
395
+ tabItem . Header = $ "{ leftTabInfo . tabLocationHeader } | { rightTabInfo . tabLocationHeader } ";
396
+ tabItem . IconSource = leftTabInfo . tabIcon ;
392
397
}
393
398
else
394
399
{
395
- await SetSelectedTabInfoAsync ( tabItem , paneArgs . LeftPaneNavPathParam ) ;
400
+ ( tabItem . Header , tabItem . IconSource ) = await GetSelectedTabInfoAsync ( paneArgs . LeftPaneNavPathParam ) ;
396
401
}
397
402
}
398
403
else if ( navigationArg is string pathArgs )
399
404
{
400
- await SetSelectedTabInfoAsync ( tabItem , pathArgs ) ;
405
+ ( tabItem . Header , tabItem . IconSource ) = await GetSelectedTabInfoAsync ( pathArgs ) ;
401
406
}
402
407
}
403
408
0 commit comments