2020using System . Collections ;
2121using Windows . Foundation ;
2222using Windows . UI . Xaml . Controls . Primitives ;
23+ using System . IO ;
2324
2425namespace Files . Interacts
2526{
@@ -60,7 +61,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
6061 App . ViewModel . TextState . isVisible = Visibility . Collapsed ;
6162 History . ForwardList . Clear ( ) ;
6263 App . ViewModel . FS . isEnabled = false ;
63- App . ViewModel . FilesAndFolders . Clear ( ) ;
64+ App . ViewModel . CancelLoadAndClearFiles ( ) ;
6465 if ( clickedOnItem . FilePath == Environment . GetFolderPath ( Environment . SpecialFolder . DesktopDirectory ) )
6566 {
6667 App . PathText . Text = "Desktop" ;
@@ -221,7 +222,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
221222 App . ViewModel . TextState . isVisible = Visibility . Collapsed ;
222223 History . ForwardList . Clear ( ) ;
223224 App . ViewModel . FS . isEnabled = false ;
224- App . ViewModel . FilesAndFolders . Clear ( ) ;
225+ App . ViewModel . CancelLoadAndClearFiles ( ) ;
225226 if ( clickedOnItem . FilePath == Environment . GetFolderPath ( Environment . SpecialFolder . DesktopDirectory ) )
226227 {
227228 App . PathText . Text = "Desktop" ;
@@ -454,7 +455,7 @@ public static async void OpenItem_Click(object sender, RoutedEventArgs e)
454455 App . ViewModel . TextState . isVisible = Visibility . Collapsed ;
455456 History . ForwardList . Clear ( ) ;
456457 App . ViewModel . FS . isEnabled = false ;
457- App . ViewModel . FilesAndFolders . Clear ( ) ;
458+ App . ViewModel . CancelLoadAndClearFiles ( ) ;
458459 App . ViewModel . Universal . path = RowData . FilePath ;
459460 App . ViewModel . AddItemsToCollectionAsync ( App . ViewModel . Universal . path , GenericFileBrowser . GFBPageName ) ;
460461 }
@@ -476,7 +477,7 @@ public static async void OpenItem_Click(object sender, RoutedEventArgs e)
476477 App . ViewModel . TextState . isVisible = Visibility . Collapsed ;
477478 History . ForwardList . Clear ( ) ;
478479 App . ViewModel . FS . isEnabled = false ;
479- App . ViewModel . FilesAndFolders . Clear ( ) ;
480+ App . ViewModel . CancelLoadAndClearFiles ( ) ;
480481 App . ViewModel . Universal . path = RowData . FilePath ;
481482 App . ViewModel . AddItemsToCollectionAsync ( RowData . FilePath , PhotoAlbum . PAPageName ) ;
482483 }
@@ -567,7 +568,7 @@ public static async void DeleteItem_Click(object sender, RoutedEventArgs e)
567568 await item . DeleteAsync ( StorageDeleteOption . Default ) ;
568569
569570 }
570- App . ViewModel . FilesAndFolders . Remove ( storItem ) ;
571+ App . ViewModel . RemoveFileOrFolder ( storItem ) ;
571572 }
572573 Debug . WriteLine ( "Ended for loop" ) ;
573574 History . ForwardList . Clear ( ) ;
@@ -594,7 +595,7 @@ public static async void DeleteItem_Click(object sender, RoutedEventArgs e)
594595 await item . DeleteAsync ( StorageDeleteOption . Default ) ;
595596
596597 }
597- App . ViewModel . FilesAndFolders . Remove ( storItem ) ;
598+ App . ViewModel . RemoveFileOrFolder ( storItem ) ;
598599 }
599600 Debug . WriteLine ( "Ended for loop" ) ;
600601 History . ForwardList . Clear ( ) ;
@@ -625,16 +626,36 @@ public static async void RenameItem_Click(object sender, RoutedEventArgs e)
625626 {
626627 var item = await StorageFolder . GetFolderFromPathAsync ( RowData . FilePath ) ;
627628 await item . RenameAsync ( input , NameCollisionOption . FailIfExists ) ;
628- App . ViewModel . FilesAndFolders . Remove ( RowData ) ;
629- App . ViewModel . FilesAndFolders . Add ( new ListedItem ( ) { FileName = input , FileDate = "Now" , EmptyImgVis = Visibility . Collapsed , FolderImg = Visibility . Visible , FileIconVis = Visibility . Collapsed , FileType = "Folder" , FileImg = null , FilePath = ( App . ViewModel . Universal . path + "\\ " + input ) } ) ;
629+ App . ViewModel . RemoveFileOrFolder ( RowData ) ;
630+ App . ViewModel . AddFileOrFolder ( new ListedItem ( item . FolderRelativeId )
631+ {
632+ FileName = input ,
633+ FileDateReal = DateTimeOffset . Now ,
634+ EmptyImgVis = Visibility . Collapsed ,
635+ FolderImg = Visibility . Visible ,
636+ FileIconVis = Visibility . Collapsed ,
637+ FileType = "Folder" ,
638+ FileImg = null ,
639+ FilePath = Path . Combine ( App . ViewModel . Universal . path , input )
640+ } ) ;
630641 }
631642 else
632643 {
633644 var item = await StorageFile . GetFileFromPathAsync ( RowData . FilePath ) ;
634645 await item . RenameAsync ( input + RowData . DotFileExtension , NameCollisionOption . FailIfExists ) ;
635- App . ViewModel . FilesAndFolders . Remove ( RowData ) ;
636- App . ViewModel . FilesAndFolders . Add ( new ListedItem ( ) { FileName = input , FileDate = "Now" , EmptyImgVis = Visibility . Visible , FolderImg = Visibility . Collapsed , FileIconVis = Visibility . Collapsed , FileType = RowData . FileType , FileImg = null , FilePath = ( App . ViewModel . Universal . path + "\\ " + input + RowData . DotFileExtension ) , DotFileExtension = RowData . DotFileExtension } ) ;
637-
646+ App . ViewModel . RemoveFileOrFolder ( RowData ) ;
647+ App . ViewModel . AddFileOrFolder ( new ListedItem ( item . FolderRelativeId )
648+ {
649+ FileName = input ,
650+ FileDateReal = DateTimeOffset . Now ,
651+ EmptyImgVis = Visibility . Visible ,
652+ FolderImg = Visibility . Collapsed ,
653+ FileIconVis = Visibility . Collapsed ,
654+ FileType = RowData . FileType ,
655+ FileImg = null ,
656+ FilePath = Path . Combine ( App . ViewModel . Universal . path , input + RowData . DotFileExtension ) ,
657+ DotFileExtension = RowData . DotFileExtension
658+ } ) ;
638659 }
639660 }
640661
@@ -659,16 +680,36 @@ public static async void RenameItem_Click(object sender, RoutedEventArgs e)
659680 {
660681 var item = await StorageFolder . GetFolderFromPathAsync ( BoxData . FilePath ) ;
661682 await item . RenameAsync ( input , NameCollisionOption . FailIfExists ) ;
662- App . ViewModel . FilesAndFolders . Remove ( BoxData ) ;
663- App . ViewModel . FilesAndFolders . Add ( new ListedItem ( ) { FileName = input , FileDate = "Now" , EmptyImgVis = Visibility . Collapsed , FolderImg = Visibility . Visible , FileIconVis = Visibility . Collapsed , FileType = "Folder" , FileImg = null , FilePath = ( App . ViewModel . Universal . path + "\\ " + input ) } ) ;
683+ App . ViewModel . RemoveFileOrFolder ( BoxData ) ;
684+ App . ViewModel . AddFileOrFolder ( new ListedItem ( item . FolderRelativeId )
685+ {
686+ FileName = input ,
687+ FileDateReal = DateTimeOffset . Now ,
688+ EmptyImgVis = Visibility . Collapsed ,
689+ FolderImg = Visibility . Visible ,
690+ FileIconVis = Visibility . Collapsed ,
691+ FileType = "Folder" ,
692+ FileImg = null ,
693+ FilePath = Path . Combine ( App . ViewModel . Universal . path , input )
694+ } ) ;
664695 }
665696 else
666697 {
667698 var item = await StorageFile . GetFileFromPathAsync ( BoxData . FilePath ) ;
668699 await item . RenameAsync ( input + BoxData . DotFileExtension , NameCollisionOption . FailIfExists ) ;
669- App . ViewModel . FilesAndFolders . Remove ( BoxData ) ;
670- App . ViewModel . FilesAndFolders . Add ( new ListedItem ( ) { FileName = input , FileDate = "Now" , EmptyImgVis = Visibility . Visible , FolderImg = Visibility . Collapsed , FileIconVis = Visibility . Collapsed , FileType = BoxData . FileType , FileImg = null , FilePath = ( App . ViewModel . Universal . path + "\\ " + input + BoxData . DotFileExtension ) , DotFileExtension = BoxData . DotFileExtension } ) ;
671-
700+ App . ViewModel . RemoveFileOrFolder ( BoxData ) ;
701+ App . ViewModel . AddFileOrFolder ( new ListedItem ( item . FolderRelativeId )
702+ {
703+ FileName = input ,
704+ FileDateReal = DateTimeOffset . Now ,
705+ EmptyImgVis = Visibility . Visible ,
706+ FolderImg = Visibility . Collapsed ,
707+ FileIconVis = Visibility . Collapsed ,
708+ FileType = BoxData . FileType ,
709+ FileImg = null ,
710+ FilePath = Path . Combine ( App . ViewModel . Universal . path , input + BoxData . DotFileExtension ) ,
711+ DotFileExtension = BoxData . DotFileExtension
712+ } ) ;
672713 }
673714 }
674715
0 commit comments