@@ -47,20 +47,13 @@ public class ItemViewModel
47
47
{
48
48
public static ObservableCollection < Classic_ListedFolderItem > classicFolderList = new ObservableCollection < Classic_ListedFolderItem > ( ) ;
49
49
public static ObservableCollection < Classic_ListedFolderItem > ClassicFolderList { get { return classicFolderList ; } }
50
+
50
51
public static ObservableCollection < ListedItem > classicFileList = new ObservableCollection < ListedItem > ( ) ;
51
52
public static ObservableCollection < ListedItem > ClassicFileList { get { return classicFileList ; } }
52
53
53
54
public static ObservableCollection < ListedItem > filesAndFolders = new ObservableCollection < ListedItem > ( ) ;
54
55
public static ObservableCollection < ListedItem > FilesAndFolders { get { return filesAndFolders ; } }
55
56
56
- string DesktopPath = Environment . GetFolderPath ( Environment . SpecialFolder . DesktopDirectory ) ;
57
- string DocumentsPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyDocuments ) ;
58
- string DownloadsPath = Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) + @"\Downloads" ;
59
- string OneDrivePath = Environment . GetFolderPath ( Environment . SpecialFolder . UserProfile ) + @"\OneDrive" ;
60
- string PicturesPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyPictures ) ;
61
- string MusicPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyMusic ) ;
62
- string VideosPath = Environment . GetFolderPath ( Environment . SpecialFolder . MyVideos ) ;
63
-
64
57
StorageFolder folder ;
65
58
static string gotName ;
66
59
static string gotDate ;
@@ -163,6 +156,7 @@ public static ProgressUIVisibility PVIS
163
156
164
157
public ItemViewModel ( string ViewPath , Page p )
165
158
{
159
+
166
160
pageName = p . Name ;
167
161
// Personalize retrieved items for view they are displayed in
168
162
if ( p . Name == "GenericItemView" || p . Name == "ClassicModePage" )
@@ -222,6 +216,9 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
222
216
PUIP . Path = path ;
223
217
try
224
218
{
219
+
220
+ PVIS . isVisible = Visibility . Visible ;
221
+ TextState . isVisible = Visibility . Collapsed ;
225
222
folder = await StorageFolder . GetFolderFromPathAsync ( path ) ;
226
223
QueryOptions options = new QueryOptions ( )
227
224
{
@@ -248,16 +245,16 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
248
245
249
246
StorageFolderQueryResult folderQueryResult = folder . CreateFolderQueryWithOptions ( options ) ;
250
247
IReadOnlyList < StorageFolder > folders = await folderQueryResult . GetFoldersAsync ( index , step ) ;
251
- while ( folders . Count != 0 )
248
+ int foldersCountSnapshot = folders . Count ;
249
+ while ( folders . Count != 0 )
252
250
{
253
251
foreach ( StorageFolder folder in folders )
254
252
{
255
253
if ( token . IsCancellationRequested )
256
254
{
257
255
return ;
258
256
}
259
- //int ProgressReported = (NumItemsRead * 100 / NumOfItems);
260
- //UpdateProgUI(ProgressReported);
257
+
261
258
gotFolName = folder . Name . ToString ( ) ;
262
259
gotFolDate = folder . DateCreated . ToString ( ) ;
263
260
gotFolPath = folder . Path . ToString ( ) ;
@@ -282,7 +279,7 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
282
279
index = 0 ;
283
280
StorageFileQueryResult fileQueryResult = folder . CreateFileQueryWithOptions ( options ) ;
284
281
IReadOnlyList < StorageFile > files = await fileQueryResult . GetFilesAsync ( index , step ) ;
285
-
282
+ int filesCountSnapshot = files . Count ;
286
283
while ( files . Count != 0 )
287
284
{
288
285
foreach ( StorageFile file in files )
@@ -291,8 +288,7 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
291
288
{
292
289
return ;
293
290
}
294
- //int ProgressReported = (NumItemsRead * 100 / NumOfItems);
295
- //UpdateProgUI(ProgressReported);
291
+
296
292
gotName = file . Name . ToString ( ) ;
297
293
gotDate = file . DateCreated . ToString ( ) ; // In the future, parse date to human readable format
298
294
if ( file . FileType . ToString ( ) == ".exe" )
@@ -339,11 +335,15 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
339
335
index += step ;
340
336
files = await fileQueryResult . GetFilesAsync ( index , step ) ;
341
337
}
338
+ if ( foldersCountSnapshot + filesCountSnapshot == 0 )
339
+ {
340
+ TextState . isVisible = Visibility . Visible ;
341
+ }
342
342
if ( pageName != "ClassicModePage" )
343
343
{
344
344
PVIS . isVisible = Visibility . Collapsed ;
345
345
}
346
-
346
+ PVIS . isVisible = Visibility . Collapsed ;
347
347
}
348
348
catch ( UnauthorizedAccessException )
349
349
{
@@ -352,158 +352,15 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
352
352
catch ( System . Runtime . InteropServices . COMException e )
353
353
{
354
354
Frame rootFrame = Window . Current . Content as Frame ;
355
- MessageDialog driveGone = new MessageDialog ( e . Message , "Drive Not Found " ) ;
355
+ MessageDialog driveGone = new MessageDialog ( e . Message , "Drive Unplugged " ) ;
356
356
await driveGone . ShowAsync ( ) ;
357
357
rootFrame . Navigate ( typeof ( MainPage ) , new SuppressNavigationTransitionInfo ( ) ) ;
358
358
}
359
359
stopwatch . Stop ( ) ;
360
360
Debug . WriteLine ( "Loading of: " + path + " completed in " + stopwatch . ElapsedMilliseconds + " Milliseconds." ) ;
361
361
}
362
362
363
- //public async void GetItemsAsync(string path, CancellationToken token)
364
- //{
365
- // Stopwatch stopwatch = new Stopwatch();
366
- // stopwatch.Start();
367
-
368
- // PUIP.Path = path;
369
- // try
370
- // {
371
- // folder = await StorageFolder.GetFolderFromPathAsync(path); // Set location to the current directory specified in path
372
- // folderList = await folder.GetFoldersAsync(); // Create a read-only list of all folders in location
373
- // if (token.IsCancellationRequested == true)
374
- // {
375
- // return;
376
- // }
377
- // fileList = await folder.GetFilesAsync(); // Create a read-only list of all files in location
378
- // NumOfFolders = folderList.Count; // How many folders are in the list
379
- // NumOfFiles = fileList.Count; // How many files are in the list
380
- // NumOfItems = NumOfFiles + NumOfFolders;
381
- // NumItemsRead = 0;
382
-
383
- // if (NumOfItems == 0)
384
- // {
385
- // TextState.isVisible = Visibility.Visible;
386
- // }
387
-
388
- // PUIH.Header = "Loading " + NumOfItems + " items";
389
- // ButtonText.buttonText = "Hide";
390
-
391
- // if (NumOfItems >= 250)
392
- // {
393
- // PVIS.isVisible = Visibility.Visible;
394
- // }
395
- // if (NumOfFolders > 0)
396
- // {
397
- // foreach (StorageFolder fol in folderList)
398
- // {
399
- // if (token.IsCancellationRequested == true)
400
- // {
401
- // return;
402
- // }
403
- // int ProgressReported = (NumItemsRead * 100 / NumOfItems);
404
- // UpdateProgUI(ProgressReported);
405
- // gotFolName = fol.Name.ToString();
406
- // gotFolDate = fol.DateCreated.ToString();
407
- // gotFolPath = fol.Path.ToString();
408
- // gotFolType = "Folder";
409
- // gotFolImg = Visibility.Visible;
410
- // gotFileImgVis = Visibility.Collapsed;
411
-
412
-
413
- // if (pageName == "ClassicModePage")
414
- // {
415
- // ClassicFolderList.Add(new Classic_ListedFolderItem() { FileName = gotFolName, FileDate = gotFolDate, FileExtension = gotFolType, FilePath = gotFolPath });
416
- // }
417
- // else
418
- // {
419
- // FilesAndFolders.Add(new ListedItem() { ItemIndex = FilesAndFolders.Count, FileImg = null, FileIconVis = gotFileImgVis, FolderImg = gotFolImg, FileName = gotFolName, FileDate = gotFolDate, FileExtension = gotFolType, FilePath = gotFolPath });
420
- // }
421
-
422
-
423
- // NumItemsRead++;
424
- // }
425
-
426
- // }
427
-
428
- // if (NumOfFiles > 0)
429
- // {
430
- // foreach (StorageFile f in fileList)
431
- // {
432
- // if (token.IsCancellationRequested == true)
433
- // {
434
- // return;
435
- // }
436
- // int ProgressReported = (NumItemsRead * 100 / NumOfItems);
437
- // UpdateProgUI(ProgressReported);
438
- // gotName = f.Name.ToString();
439
- // gotDate = f.DateCreated.ToString(); // In the future, parse date to human readable format
440
- // if (f.FileType.ToString() == ".exe")
441
- // {
442
- // gotType = "Executable";
443
- // }
444
- // else
445
- // {
446
- // gotType = f.DisplayType;
447
- // }
448
- // gotPath = f.Path.ToString();
449
- // gotFolImg = Visibility.Collapsed;
450
- // if (isPhotoAlbumMode == false)
451
- // {
452
- // const uint requestedSize = 20;
453
- // const ThumbnailMode thumbnailMode = ThumbnailMode.ListView;
454
- // const ThumbnailOptions thumbnailOptions = ThumbnailOptions.UseCurrentScale;
455
- // gotFileImg = await f.GetThumbnailAsync(thumbnailMode, requestedSize, thumbnailOptions);
456
- // }
457
- // else
458
- // {
459
- // const uint requestedSize = 275;
460
- // const ThumbnailMode thumbnailMode = ThumbnailMode.PicturesView;
461
- // const ThumbnailOptions thumbnailOptions = ThumbnailOptions.ResizeThumbnail;
462
- // gotFileImg = await f.GetThumbnailAsync(thumbnailMode, requestedSize, thumbnailOptions);
463
- // }
464
-
465
- // BitmapImage icon = new BitmapImage();
466
- // if (gotFileImg != null)
467
- // {
468
- // icon.SetSource(gotFileImg.CloneStream());
469
- // }
470
- // gotFileImgVis = Visibility.Visible;
471
-
472
- // if (pageName == "ClassicModePage")
473
- // {
474
- // ClassicFileList.Add(new ListedItem() { FileImg = icon, FileIconVis = gotFileImgVis, FolderImg = gotFolImg, FileName = gotName, FileDate = gotDate, FileExtension = gotType, FilePath = gotPath });
475
- // }
476
- // else
477
- // {
478
- // FilesAndFolders.Add(new ListedItem() { FileImg = icon, FileIconVis = gotFileImgVis, FolderImg = gotFolImg, FileName = gotName, FileDate = gotDate, FileExtension = gotType, FilePath = gotPath });
479
- // }
480
- // NumItemsRead++;
481
- // }
482
-
483
-
484
- // }
485
- // if (pageName != "ClassicModePage")
486
- // {
487
- // PVIS.isVisible = Visibility.Collapsed;
488
- // }
489
-
490
-
491
- // }
492
- // catch (UnauthorizedAccessException)
493
- // {
494
- // DisplayConsentDialog();
495
- // }
496
- // catch (System.Runtime.InteropServices.COMException e)
497
- // {
498
- // Frame rootFrame = Window.Current.Content as Frame;
499
- // MessageDialog driveGone = new MessageDialog(e.Message, "Drive Not Found");
500
- // await driveGone.ShowAsync();
501
- // rootFrame.Navigate(typeof(MainPage), new SuppressNavigationTransitionInfo());
502
- // }
503
- // stopwatch.Stop();
504
- // Debug.WriteLine("Loading of: " + path + " completed in " + stopwatch.ElapsedMilliseconds + " Milliseconds.");
505
-
506
- //}
363
+
507
364
508
365
public static ProgressPercentage progressPER = new ProgressPercentage ( ) ;
509
366
@@ -530,15 +387,13 @@ public static async void DisplayCollisionUIWithArgs(string header, string subHea
530
387
CollisionBoxHeader . Header = header ;
531
388
CollisionBoxSubHeader . SubHeader = subHeader ;
532
389
await GenericFileBrowser . collisionBox . ShowAsync ( ) ;
533
- //CollisionUIVisibility.isVisible = Visibility.Visible;
534
390
}
535
391
536
392
public static async void DisplayReviewUIWithArgs ( string header , string subHeader )
537
393
{
538
394
ConflictBoxHeader . Header = header ;
539
395
ConflictBoxSubHeader . SubHeader = subHeader ;
540
396
await GenericFileBrowser . reviewBox . ShowAsync ( ) ;
541
- //ConflictUIVisibility.isVisible = Visibility.Visible;
542
397
}
543
398
544
399
public static async void FillTreeNode ( object item , Microsoft . UI . Xaml . Controls . TreeView EntireControl )
0 commit comments