1
1
using ItemListPresenter ;
2
2
using System ;
3
+ using System . Collections ;
4
+ using System . Collections . ObjectModel ;
3
5
using System . ComponentModel ;
4
6
using System . Diagnostics ;
5
7
using Windows . ApplicationModel . Core ;
8
+ using Windows . Devices . Enumeration ;
9
+ using Windows . Devices . Usb ;
10
+ using Windows . Foundation ;
11
+ using Windows . Storage ;
6
12
using Windows . UI ;
13
+ using Windows . UI . Popups ;
7
14
using Windows . UI . ViewManagement ;
8
15
using Windows . UI . Xaml ;
9
16
using Windows . UI . Xaml . Controls ;
17
+ using Windows . UI . Xaml . Media . Animation ;
10
18
11
19
namespace Files
12
20
{
@@ -23,6 +31,7 @@ public sealed partial class MainPage : Page
23
31
string PicturesPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyPictures ) ;
24
32
string MusicPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyMusic ) ;
25
33
string VideosPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyVideos ) ;
34
+
26
35
public MainPage ( )
27
36
{
28
37
this . InitializeComponent ( ) ;
@@ -36,8 +45,25 @@ public MainPage()
36
45
titleBar . ButtonHoverBackgroundColor = Color . FromArgb ( 75 , 10 , 10 , 10 ) ;
37
46
nv = navView ;
38
47
accessibleAutoSuggestBox = auto_suggest ;
48
+ PopulateNavViewWithExternalDrives ( ) ;
49
+
39
50
}
40
51
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
+
41
67
private static SelectItem select = new SelectItem ( ) ;
42
68
public static SelectItem Select { get { return MainPage . select ; } }
43
69
@@ -52,17 +78,15 @@ private void navView_ItemSelected(Microsoft.UI.Xaml.Controls.NavigationView send
52
78
}
53
79
}
54
80
55
-
56
-
57
-
81
+
58
82
private void auto_suggest_QuerySubmitted ( AutoSuggestBox sender , AutoSuggestBoxQuerySubmittedEventArgs args )
59
83
{
60
84
61
85
}
62
86
63
87
private void navView_Loaded ( object sender , RoutedEventArgs e )
64
88
{
65
-
89
+
66
90
foreach ( Microsoft . UI . Xaml . Controls . NavigationViewItemBase NavItemChoice in nv . MenuItems )
67
91
{
68
92
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
80
104
{
81
105
82
106
var item = args . InvokedItem ;
83
-
107
+ var itemContainer = args . InvokedItemContainer ;
84
108
//var item = Interaction.FindParent<NavigationViewItemBase>(args.InvokedItem as DependencyObject);
85
109
if ( args . IsSettingsInvoked == true )
86
110
{
@@ -129,7 +153,7 @@ private void NavView_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
129
153
ContentFrame . Navigate ( typeof ( GenericFileBrowser ) , VideosPath ) ;
130
154
auto_suggest . PlaceholderText = "Search Videos" ;
131
155
}
132
- else if ( item . ToString ( ) == "Local Disk" )
156
+ else if ( item . ToString ( ) == "Local Disk (C: \\ ) " )
133
157
{
134
158
ItemViewModel . TextState . isVisible = Visibility . Collapsed ;
135
159
ContentFrame . Navigate ( typeof ( GenericFileBrowser ) , @"C:\" ) ;
@@ -141,6 +165,22 @@ private void NavView_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
141
165
ContentFrame . Navigate ( typeof ( GenericFileBrowser ) , OneDrivePath ) ;
142
166
auto_suggest . PlaceholderText = "Search OneDrive" ;
143
167
}
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
+ }
144
184
145
185
}
146
186
}
0 commit comments