@@ -161,6 +161,7 @@ private async void DisplayConsentDialog()
161
161
public static bool IsStopRequested = false ;
162
162
public static bool IsTerminated = true ;
163
163
164
+
164
165
public async void GetItemsAsync ( string path )
165
166
{
166
167
Stopwatch stopwatch = new Stopwatch ( ) ;
@@ -173,123 +174,123 @@ public async void GetItemsAsync(string path)
173
174
folder = await StorageFolder . GetFolderFromPathAsync ( path ) ; // Set location to the current directory specified in path
174
175
175
176
176
- QueryOptions options = new QueryOptions ( )
177
- {
178
- FolderDepth = FolderDepth . Shallow ,
179
- IndexerOption = IndexerOption . UseIndexerWhenAvailable
177
+ QueryOptions options = new QueryOptions ( )
178
+ {
179
+ FolderDepth = FolderDepth . Shallow ,
180
+ IndexerOption = IndexerOption . UseIndexerWhenAvailable
180
181
181
- } ;
182
- string [ ] otherProperties = new string [ ]
183
- {
184
- SystemProperties . Title
185
- } ;
182
+ } ;
183
+ string [ ] otherProperties = new string [ ]
184
+ {
185
+ SystemProperties . Title
186
+ } ;
186
187
187
- options . SetPropertyPrefetch ( PropertyPrefetchOptions . None , otherProperties ) ;
188
- SortEntry sort = new SortEntry ( )
189
- {
190
- AscendingOrder = true ,
191
- PropertyName = "System.ItemNameDisplay"
192
- } ;
193
- options . SortOrder . Add ( sort ) ;
188
+ options . SetPropertyPrefetch ( PropertyPrefetchOptions . None , otherProperties ) ;
189
+ SortEntry sort = new SortEntry ( )
190
+ {
191
+ AscendingOrder = true ,
192
+ PropertyName = "System.ItemNameDisplay"
193
+ } ;
194
+ options . SortOrder . Add ( sort ) ;
194
195
195
- StorageFileQueryResult fileQueryResult = folder . CreateFileQueryWithOptions ( options ) ;
196
- StorageFolderQueryResult folderQueryResult = folder . CreateFolderQueryWithOptions ( options ) ;
197
- folderList = await folder . GetFoldersAsync ( ) ; // Create a read-only list of all folders in location
198
- fileList = await folder . GetFilesAsync ( ) ; // Create a read-only list of all files in location
199
- int NumOfFolders = folderList . Count ; // How many folders are in the list
200
- int NumOfFiles = fileList . Count ; // How many files are in the list
201
- int NumOfItems = NumOfFiles + NumOfFolders ;
202
- int NumItemsRead = 0 ;
203
-
204
- if ( NumOfItems == 0 )
205
- {
206
- TextState . isVisible = Visibility . Visible ;
207
- return ;
208
- }
209
-
210
- PUIH . Header = "Loading " + NumOfItems + " items" ;
196
+ StorageFileQueryResult fileQueryResult = folder . CreateFileQueryWithOptions ( options ) ;
197
+ StorageFolderQueryResult folderQueryResult = folder . CreateFolderQueryWithOptions ( options ) ;
198
+ folderList = await folder . GetFoldersAsync ( ) ; // Create a read-only list of all folders in location
199
+ fileList = await folder . GetFilesAsync ( ) ; // Create a read-only list of all files in location
200
+ int NumOfFolders = folderList . Count ; // How many folders are in the list
201
+ int NumOfFiles = fileList . Count ; // How many files are in the list
202
+ int NumOfItems = NumOfFiles + NumOfFolders ;
203
+ int NumItemsRead = 0 ;
204
+
205
+ if ( NumOfItems == 0 )
206
+ {
207
+ TextState . isVisible = Visibility . Visible ;
208
+ return ;
209
+ }
211
210
212
- if ( NumOfItems >= 250 )
213
- {
214
- PVIS . isVisible = Visibility . Visible ;
215
- }
211
+ PUIH . Header = "Loading " + NumOfItems + " items" ;
216
212
217
- if ( NumOfFolders > 0 )
218
- {
219
- foreach ( StorageFolder fol in folderList )
213
+ if ( NumOfItems >= 250 )
220
214
{
221
- if ( IsStopRequested )
222
- {
223
- IsStopRequested = false ;
224
- IsTerminated = true ;
225
- return ;
226
- }
227
- int ProgressReported = ( NumItemsRead * 100 / NumOfItems ) ;
228
- UpdateProgUI ( ProgressReported ) ;
229
- gotFolName = fol . Name . ToString ( ) ;
230
- gotFolDate = fol . DateCreated . ToString ( ) ;
231
- gotFolPath = fol . Path . ToString ( ) ;
232
- gotFolType = "Folder" ;
233
- gotFolImg = Visibility . Visible ;
234
- gotFileImgVis = Visibility . Collapsed ;
235
- FilesAndFolders . Add ( new ListedItem ( ) { ItemIndex = FilesAndFolders . Count , FileImg = null , FileIconVis = gotFileImgVis , FolderImg = gotFolImg , FileName = gotFolName , FileDate = gotFolDate , FileExtension = gotFolType , FilePath = gotFolPath } ) ;
236
-
237
- NumItemsRead ++ ;
215
+ PVIS . isVisible = Visibility . Visible ;
238
216
}
239
-
240
- }
241
217
242
- if ( NumOfFiles > 0 )
243
- {
244
- foreach ( StorageFile f in fileList )
218
+ if ( NumOfFolders > 0 )
245
219
{
246
- if ( IsStopRequested )
247
- {
248
- IsStopRequested = false ;
249
- IsTerminated = true ;
250
- return ;
251
- }
252
- int ProgressReported = ( NumItemsRead * 100 / NumOfItems ) ;
253
- UpdateProgUI ( ProgressReported ) ;
254
- gotName = f . Name . ToString ( ) ;
255
- gotDate = f . DateCreated . ToString ( ) ; // In the future, parse date to human readable format
256
- if ( f . FileType . ToString ( ) == ".exe" )
257
- {
258
- gotType = "Executable" ;
259
- }
260
- else
261
- {
262
- gotType = f . FileType . ToString ( ) ;
263
- }
264
- gotPath = f . Path . ToString ( ) ;
265
- gotFolImg = Visibility . Collapsed ;
266
- if ( isPhotoAlbumMode == false )
220
+ foreach ( StorageFolder fol in folderList )
267
221
{
268
- const uint requestedSize = 20 ;
269
- const ThumbnailMode thumbnailMode = ThumbnailMode . ListView ;
270
- const ThumbnailOptions thumbnailOptions = ThumbnailOptions . UseCurrentScale ;
271
- gotFileImg = await f . GetThumbnailAsync ( thumbnailMode , requestedSize , thumbnailOptions ) ;
272
- }
273
- else
274
- {
275
- const uint requestedSize = 275 ;
276
- const ThumbnailMode thumbnailMode = ThumbnailMode . PicturesView ;
277
- const ThumbnailOptions thumbnailOptions = ThumbnailOptions . ResizeThumbnail ;
278
- gotFileImg = await f . GetThumbnailAsync ( thumbnailMode , requestedSize , thumbnailOptions ) ;
222
+ if ( IsStopRequested )
223
+ {
224
+ IsStopRequested = false ;
225
+ IsTerminated = true ;
226
+ return ;
227
+ }
228
+ int ProgressReported = ( NumItemsRead * 100 / NumOfItems ) ;
229
+ UpdateProgUI ( ProgressReported ) ;
230
+ gotFolName = fol . Name . ToString ( ) ;
231
+ gotFolDate = fol . DateCreated . ToString ( ) ;
232
+ gotFolPath = fol . Path . ToString ( ) ;
233
+ gotFolType = "Folder" ;
234
+ gotFolImg = Visibility . Visible ;
235
+ gotFileImgVis = Visibility . Collapsed ;
236
+ FilesAndFolders . Add ( new ListedItem ( ) { ItemIndex = FilesAndFolders . Count , FileImg = null , FileIconVis = gotFileImgVis , FolderImg = gotFolImg , FileName = gotFolName , FileDate = gotFolDate , FileExtension = gotFolType , FilePath = gotFolPath } ) ;
237
+
238
+ NumItemsRead ++ ;
279
239
}
240
+
241
+ }
280
242
281
- BitmapImage icon = new BitmapImage ( ) ;
282
- if ( gotFileImg != null )
243
+ if ( NumOfFiles > 0 )
244
+ {
245
+ foreach ( StorageFile f in fileList )
283
246
{
284
- icon . SetSource ( gotFileImg . CloneStream ( ) ) ;
247
+ if ( IsStopRequested )
248
+ {
249
+ IsStopRequested = false ;
250
+ IsTerminated = true ;
251
+ return ;
252
+ }
253
+ int ProgressReported = ( NumItemsRead * 100 / NumOfItems ) ;
254
+ UpdateProgUI ( ProgressReported ) ;
255
+ gotName = f . Name . ToString ( ) ;
256
+ gotDate = f . DateCreated . ToString ( ) ; // In the future, parse date to human readable format
257
+ if ( f . FileType . ToString ( ) == ".exe" )
258
+ {
259
+ gotType = "Executable" ;
260
+ }
261
+ else
262
+ {
263
+ gotType = f . FileType . ToString ( ) ;
264
+ }
265
+ gotPath = f . Path . ToString ( ) ;
266
+ gotFolImg = Visibility . Collapsed ;
267
+ if ( isPhotoAlbumMode == false )
268
+ {
269
+ const uint requestedSize = 20 ;
270
+ const ThumbnailMode thumbnailMode = ThumbnailMode . ListView ;
271
+ const ThumbnailOptions thumbnailOptions = ThumbnailOptions . UseCurrentScale ;
272
+ gotFileImg = await f . GetThumbnailAsync ( thumbnailMode , requestedSize , thumbnailOptions ) ;
273
+ }
274
+ else
275
+ {
276
+ const uint requestedSize = 275 ;
277
+ const ThumbnailMode thumbnailMode = ThumbnailMode . PicturesView ;
278
+ const ThumbnailOptions thumbnailOptions = ThumbnailOptions . ResizeThumbnail ;
279
+ gotFileImg = await f . GetThumbnailAsync ( thumbnailMode , requestedSize , thumbnailOptions ) ;
280
+ }
281
+
282
+ BitmapImage icon = new BitmapImage ( ) ;
283
+ if ( gotFileImg != null )
284
+ {
285
+ icon . SetSource ( gotFileImg . CloneStream ( ) ) ;
286
+ }
287
+ gotFileImgVis = Visibility . Visible ;
288
+ FilesAndFolders . Add ( new ListedItem ( ) { FileImg = icon , FileIconVis = gotFileImgVis , FolderImg = gotFolImg , FileName = gotName , FileDate = gotDate , FileExtension = gotType , FilePath = gotPath } ) ;
289
+ NumItemsRead ++ ;
285
290
}
286
- gotFileImgVis = Visibility . Visible ;
287
- FilesAndFolders . Add ( new ListedItem ( ) { FileImg = icon , FileIconVis = gotFileImgVis , FolderImg = gotFolImg , FileName = gotName , FileDate = gotDate , FileExtension = gotType , FilePath = gotPath } ) ;
288
- NumItemsRead ++ ;
289
- }
290
291
291
292
292
- }
293
+ }
293
294
294
295
PVIS . isVisible = Visibility . Collapsed ;
295
296
IsTerminated = true ;
0 commit comments