11using ItemListPresenter ;
22using System ;
3+ using System . Collections ;
4+ using System . Collections . ObjectModel ;
35using System . ComponentModel ;
46using System . Diagnostics ;
57using Windows . ApplicationModel . Core ;
8+ using Windows . Devices . Enumeration ;
9+ using Windows . Devices . Usb ;
10+ using Windows . Foundation ;
11+ using Windows . Storage ;
612using Windows . UI ;
13+ using Windows . UI . Popups ;
714using Windows . UI . ViewManagement ;
815using Windows . UI . Xaml ;
916using Windows . UI . Xaml . Controls ;
17+ using Windows . UI . Xaml . Media . Animation ;
1018
1119namespace Files
1220{
@@ -23,6 +31,7 @@ public sealed partial class MainPage : Page
2331 string PicturesPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyPictures ) ;
2432 string MusicPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyMusic ) ;
2533 string VideosPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyVideos ) ;
34+
2635 public MainPage ( )
2736 {
2837 this . InitializeComponent ( ) ;
@@ -36,8 +45,25 @@ public MainPage()
3645 titleBar . ButtonHoverBackgroundColor = Color . FromArgb ( 75 , 10 , 10 , 10 ) ;
3746 nv = navView ;
3847 accessibleAutoSuggestBox = auto_suggest ;
48+ PopulateNavViewWithExternalDrives ( ) ;
49+
3950 }
4051
52+ public async void PopulateNavViewWithExternalDrives ( )
53+ {
54+ StorageFolder RemDevicesFolder = KnownFolders . RemovableDevices ;
55+ foreach ( StorageFolder fol in await RemDevicesFolder . GetFoldersAsync ( ) )
56+ {
57+ nv . MenuItems . Add ( new Microsoft . UI . Xaml . Controls . NavigationViewItem ( )
58+ {
59+ Content = "Removable Drive (" + fol . Name + ")" ,
60+ Icon = new SymbolIcon ( ( Symbol ) 0xE88E ) ,
61+ Tag = fol . Name
62+ } ) ;
63+
64+ }
65+ }
66+
4167 private static SelectItem select = new SelectItem ( ) ;
4268 public static SelectItem Select { get { return MainPage . select ; } }
4369
@@ -52,17 +78,15 @@ private void navView_ItemSelected(Microsoft.UI.Xaml.Controls.NavigationView send
5278 }
5379 }
5480
55-
56-
57-
81+
5882 private void auto_suggest_QuerySubmitted ( AutoSuggestBox sender , AutoSuggestBoxQuerySubmittedEventArgs args )
5983 {
6084
6185 }
6286
6387 private void navView_Loaded ( object sender , RoutedEventArgs e )
6488 {
65-
89+
6690 foreach ( Microsoft . UI . Xaml . Controls . NavigationViewItemBase NavItemChoice in nv . MenuItems )
6791 {
6892 if ( NavItemChoice is Microsoft . UI . Xaml . Controls . NavigationViewItem && NavItemChoice . Name . ToString ( ) == "homeIc" )
@@ -80,7 +104,7 @@ private void NavView_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
80104 {
81105
82106 var item = args . InvokedItem ;
83-
107+ var itemContainer = args . InvokedItemContainer ;
84108 //var item = Interaction.FindParent<NavigationViewItemBase>(args.InvokedItem as DependencyObject);
85109 if ( args . IsSettingsInvoked == true )
86110 {
@@ -129,7 +153,7 @@ private void NavView_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
129153 ContentFrame . Navigate ( typeof ( GenericFileBrowser ) , VideosPath ) ;
130154 auto_suggest . PlaceholderText = "Search Videos" ;
131155 }
132- else if ( item . ToString ( ) == "Local Disk" )
156+ else if ( item . ToString ( ) == "Local Disk (C: \\ ) " )
133157 {
134158 ItemViewModel . TextState . isVisible = Visibility . Collapsed ;
135159 ContentFrame . Navigate ( typeof ( GenericFileBrowser ) , @"C:\" ) ;
@@ -141,6 +165,22 @@ private void NavView_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
141165 ContentFrame . Navigate ( typeof ( GenericFileBrowser ) , OneDrivePath ) ;
142166 auto_suggest . PlaceholderText = "Search OneDrive" ;
143167 }
168+ else
169+ {
170+ var tagOfInvokedItem = ( nv . MenuItems [ nv . MenuItems . IndexOf ( itemContainer ) ] as Microsoft . UI . Xaml . Controls . NavigationViewItem ) . Tag ;
171+
172+ if ( StorageFolder . GetFolderFromPathAsync ( tagOfInvokedItem . ToString ( ) ) != null )
173+ {
174+ ItemViewModel . TextState . isVisible = Visibility . Collapsed ;
175+ ContentFrame . Navigate ( typeof ( GenericFileBrowser ) , tagOfInvokedItem ) ;
176+ auto_suggest . PlaceholderText = "Search " + tagOfInvokedItem ;
177+ }
178+ else
179+ {
180+
181+ }
182+
183+ }
144184
145185 }
146186 }
0 commit comments