@@ -57,51 +57,71 @@ public async void AddFolderToJumpList(string path)
57
57
58
58
private void AddFolder ( string path )
59
59
{
60
- if ( instance != null && ! JumpListItemPaths . Contains ( path ) )
60
+ if ( instance != null )
61
61
{
62
- string displayName ;
63
- if ( path . Equals ( CommonPaths . DesktopPath , StringComparison . OrdinalIgnoreCase ) )
64
- {
65
- displayName = "ms-resource:///Resources/Desktop" ;
66
- }
67
- else if ( path . Equals ( CommonPaths . DownloadsPath , StringComparison . OrdinalIgnoreCase ) )
68
- {
69
- displayName = "ms-resource:///Resources/Downloads" ;
70
- }
71
- else if ( path . Equals ( CommonPaths . RecycleBinPath , StringComparison . OrdinalIgnoreCase ) )
62
+ string displayName = null ;
63
+ if ( path . EndsWith ( "\\ " ) )
72
64
{
73
- var localSettings = ApplicationData . Current . LocalSettings ;
74
- displayName = localSettings . Values . Get ( "RecycleBin_Title" , "Recycle Bin" ) ;
65
+ // Jumplist item argument can't end with a slash so append a character that can't exist in a directory name to support listing drives.
66
+ var drive = App . DrivesManager . Drives . Where ( drive => drive . Path == path ) . FirstOrDefault ( ) ;
67
+ if ( drive == null )
68
+ {
69
+ return ;
70
+ }
71
+
72
+ displayName = drive . Text ;
73
+ path += '?' ;
75
74
}
76
- else if ( App . LibraryManager . TryGetLibrary ( path , out LibraryLocationItem library ) )
75
+
76
+ if ( displayName == null )
77
77
{
78
- var libName = Path . GetFileNameWithoutExtension ( library . Path ) ;
79
- switch ( libName )
78
+ if ( path . Equals ( CommonPaths . DesktopPath , StringComparison . OrdinalIgnoreCase ) )
79
+ {
80
+ displayName = "ms-resource:///Resources/SidebarDesktop" ;
81
+ }
82
+ else if ( path . Equals ( CommonPaths . DownloadsPath , StringComparison . OrdinalIgnoreCase ) )
83
+ {
84
+ displayName = "ms-resource:///Resources/SidebarDownloads" ;
85
+ }
86
+ else if ( path . Equals ( CommonPaths . RecycleBinPath , StringComparison . OrdinalIgnoreCase ) )
87
+ {
88
+ var localSettings = ApplicationData . Current . LocalSettings ;
89
+ displayName = localSettings . Values . Get ( "RecycleBin_Title" , "Recycle Bin" ) ;
90
+ }
91
+ else if ( App . LibraryManager . TryGetLibrary ( path , out LibraryLocationItem library ) )
80
92
{
81
- case "Documents" :
82
- case "Pictures" :
83
- case "Music" :
84
- case "Videos" :
85
- // Use localized name
86
- displayName = $ "ms-resource:///Resources/Sidebar{ libName } ";
87
- break ;
93
+ var libName = Path . GetFileNameWithoutExtension ( library . Path ) ;
94
+ switch ( libName )
95
+ {
96
+ case "Documents" :
97
+ case "Pictures" :
98
+ case "Music" :
99
+ case "Videos" :
100
+ // Use localized name
101
+ displayName = $ "ms-resource:///Resources/Sidebar{ libName } ";
102
+ break ;
88
103
89
- default :
90
- // Use original name
91
- displayName = library . Text ;
92
- break ;
104
+ default :
105
+ // Use original name
106
+ displayName = library . Text ;
107
+ break ;
108
+ }
109
+ }
110
+ else
111
+ {
112
+ displayName = Path . GetFileName ( path ) ;
93
113
}
94
- }
95
- else
96
- {
97
- displayName = Path . GetFileName ( path ) ;
98
114
}
99
115
100
116
var jumplistItem = JumpListItem . CreateWithArguments ( path , displayName ) ;
101
117
jumplistItem . Description = jumplistItem . Arguments ;
102
118
jumplistItem . GroupName = "ms-resource:///Resources/JumpListRecentGroupHeader" ;
103
119
jumplistItem . Logo = new Uri ( "ms-appx:///Assets/FolderIcon.png" ) ;
104
- instance . Items . Add ( jumplistItem ) ;
120
+
121
+ // Keep newer items at the top.
122
+ instance . Items . Remove ( instance . Items . FirstOrDefault ( x => x . Arguments . Equals ( path , StringComparison . OrdinalIgnoreCase ) ) ) ;
123
+ instance . Items . Insert ( 0 , jumplistItem ) ;
124
+ JumpListItemPaths . Remove ( JumpListItemPaths . FirstOrDefault ( x => x . Equals ( path , StringComparison . OrdinalIgnoreCase ) ) ) ;
105
125
JumpListItemPaths . Add ( path ) ;
106
126
}
107
127
}
@@ -139,4 +159,4 @@ private async Task RefreshAsync()
139
159
}
140
160
}
141
161
}
142
- }
162
+ }
0 commit comments