@@ -47,20 +47,13 @@ public class ItemViewModel
4747 {
4848 public static ObservableCollection < Classic_ListedFolderItem > classicFolderList = new ObservableCollection < Classic_ListedFolderItem > ( ) ;
4949 public static ObservableCollection < Classic_ListedFolderItem > ClassicFolderList { get { return classicFolderList ; } }
50+
5051 public static ObservableCollection < ListedItem > classicFileList = new ObservableCollection < ListedItem > ( ) ;
5152 public static ObservableCollection < ListedItem > ClassicFileList { get { return classicFileList ; } }
5253
5354 public static ObservableCollection < ListedItem > filesAndFolders = new ObservableCollection < ListedItem > ( ) ;
5455 public static ObservableCollection < ListedItem > FilesAndFolders { get { return filesAndFolders ; } }
5556
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-
6457 StorageFolder folder ;
6558 static string gotName ;
6659 static string gotDate ;
@@ -163,6 +156,7 @@ public static ProgressUIVisibility PVIS
163156
164157 public ItemViewModel ( string ViewPath , Page p )
165158 {
159+
166160 pageName = p . Name ;
167161 // Personalize retrieved items for view they are displayed in
168162 if ( p . Name == "GenericItemView" || p . Name == "ClassicModePage" )
@@ -222,6 +216,9 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
222216 PUIP . Path = path ;
223217 try
224218 {
219+
220+ PVIS . isVisible = Visibility . Visible ;
221+ TextState . isVisible = Visibility . Collapsed ;
225222 folder = await StorageFolder . GetFolderFromPathAsync ( path ) ;
226223 QueryOptions options = new QueryOptions ( )
227224 {
@@ -248,16 +245,16 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
248245
249246 StorageFolderQueryResult folderQueryResult = folder . CreateFolderQueryWithOptions ( options ) ;
250247 IReadOnlyList < StorageFolder > folders = await folderQueryResult . GetFoldersAsync ( index , step ) ;
251- while ( folders . Count != 0 )
248+ int foldersCountSnapshot = folders . Count ;
249+ while ( folders . Count != 0 )
252250 {
253251 foreach ( StorageFolder folder in folders )
254252 {
255253 if ( token . IsCancellationRequested )
256254 {
257255 return ;
258256 }
259- //int ProgressReported = (NumItemsRead * 100 / NumOfItems);
260- //UpdateProgUI(ProgressReported);
257+
261258 gotFolName = folder . Name . ToString ( ) ;
262259 gotFolDate = folder . DateCreated . ToString ( ) ;
263260 gotFolPath = folder . Path . ToString ( ) ;
@@ -282,7 +279,7 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
282279 index = 0 ;
283280 StorageFileQueryResult fileQueryResult = folder . CreateFileQueryWithOptions ( options ) ;
284281 IReadOnlyList < StorageFile > files = await fileQueryResult . GetFilesAsync ( index , step ) ;
285-
282+ int filesCountSnapshot = files . Count ;
286283 while ( files . Count != 0 )
287284 {
288285 foreach ( StorageFile file in files )
@@ -291,8 +288,7 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
291288 {
292289 return ;
293290 }
294- //int ProgressReported = (NumItemsRead * 100 / NumOfItems);
295- //UpdateProgUI(ProgressReported);
291+
296292 gotName = file . Name . ToString ( ) ;
297293 gotDate = file . DateCreated . ToString ( ) ; // In the future, parse date to human readable format
298294 if ( file . FileType . ToString ( ) == ".exe" )
@@ -339,11 +335,15 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
339335 index += step ;
340336 files = await fileQueryResult . GetFilesAsync ( index , step ) ;
341337 }
338+ if ( foldersCountSnapshot + filesCountSnapshot == 0 )
339+ {
340+ TextState . isVisible = Visibility . Visible ;
341+ }
342342 if ( pageName != "ClassicModePage" )
343343 {
344344 PVIS . isVisible = Visibility . Collapsed ;
345345 }
346-
346+ PVIS . isVisible = Visibility . Collapsed ;
347347 }
348348 catch ( UnauthorizedAccessException )
349349 {
@@ -352,158 +352,15 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
352352 catch ( System . Runtime . InteropServices . COMException e )
353353 {
354354 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 " ) ;
356356 await driveGone . ShowAsync ( ) ;
357357 rootFrame . Navigate ( typeof ( MainPage ) , new SuppressNavigationTransitionInfo ( ) ) ;
358358 }
359359 stopwatch . Stop ( ) ;
360360 Debug . WriteLine ( "Loading of: " + path + " completed in " + stopwatch . ElapsedMilliseconds + " Milliseconds." ) ;
361361 }
362362
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+
507364
508365 public static ProgressPercentage progressPER = new ProgressPercentage ( ) ;
509366
@@ -530,15 +387,13 @@ public static async void DisplayCollisionUIWithArgs(string header, string subHea
530387 CollisionBoxHeader . Header = header ;
531388 CollisionBoxSubHeader . SubHeader = subHeader ;
532389 await GenericFileBrowser . collisionBox . ShowAsync ( ) ;
533- //CollisionUIVisibility.isVisible = Visibility.Visible;
534390 }
535391
536392 public static async void DisplayReviewUIWithArgs ( string header , string subHeader )
537393 {
538394 ConflictBoxHeader . Header = header ;
539395 ConflictBoxSubHeader . SubHeader = subHeader ;
540396 await GenericFileBrowser . reviewBox . ShowAsync ( ) ;
541- //ConflictUIVisibility.isVisible = Visibility.Visible;
542397 }
543398
544399 public static async void FillTreeNode ( object item , Microsoft . UI . Xaml . Controls . TreeView EntireControl )
0 commit comments