20
20
using System . Collections ;
21
21
using Windows . Foundation ;
22
22
using Windows . UI . Xaml . Controls . Primitives ;
23
+ using System . IO ;
23
24
24
25
namespace Files . Interacts
25
26
{
@@ -60,7 +61,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
60
61
App . ViewModel . TextState . isVisible = Visibility . Collapsed ;
61
62
History . ForwardList . Clear ( ) ;
62
63
App . ViewModel . FS . isEnabled = false ;
63
- App . ViewModel . FilesAndFolders . Clear ( ) ;
64
+ App . ViewModel . CancelLoadAndClearFiles ( ) ;
64
65
if ( clickedOnItem . FilePath == Environment . GetFolderPath ( Environment . SpecialFolder . DesktopDirectory ) )
65
66
{
66
67
App . PathText . Text = "Desktop" ;
@@ -221,7 +222,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
221
222
App . ViewModel . TextState . isVisible = Visibility . Collapsed ;
222
223
History . ForwardList . Clear ( ) ;
223
224
App . ViewModel . FS . isEnabled = false ;
224
- App . ViewModel . FilesAndFolders . Clear ( ) ;
225
+ App . ViewModel . CancelLoadAndClearFiles ( ) ;
225
226
if ( clickedOnItem . FilePath == Environment . GetFolderPath ( Environment . SpecialFolder . DesktopDirectory ) )
226
227
{
227
228
App . PathText . Text = "Desktop" ;
@@ -454,7 +455,7 @@ public static async void OpenItem_Click(object sender, RoutedEventArgs e)
454
455
App . ViewModel . TextState . isVisible = Visibility . Collapsed ;
455
456
History . ForwardList . Clear ( ) ;
456
457
App . ViewModel . FS . isEnabled = false ;
457
- App . ViewModel . FilesAndFolders . Clear ( ) ;
458
+ App . ViewModel . CancelLoadAndClearFiles ( ) ;
458
459
App . ViewModel . Universal . path = RowData . FilePath ;
459
460
App . ViewModel . AddItemsToCollectionAsync ( App . ViewModel . Universal . path , GenericFileBrowser . GFBPageName ) ;
460
461
}
@@ -476,7 +477,7 @@ public static async void OpenItem_Click(object sender, RoutedEventArgs e)
476
477
App . ViewModel . TextState . isVisible = Visibility . Collapsed ;
477
478
History . ForwardList . Clear ( ) ;
478
479
App . ViewModel . FS . isEnabled = false ;
479
- App . ViewModel . FilesAndFolders . Clear ( ) ;
480
+ App . ViewModel . CancelLoadAndClearFiles ( ) ;
480
481
App . ViewModel . Universal . path = RowData . FilePath ;
481
482
App . ViewModel . AddItemsToCollectionAsync ( RowData . FilePath , PhotoAlbum . PAPageName ) ;
482
483
}
@@ -567,7 +568,7 @@ public static async void DeleteItem_Click(object sender, RoutedEventArgs e)
567
568
await item . DeleteAsync ( StorageDeleteOption . Default ) ;
568
569
569
570
}
570
- App . ViewModel . FilesAndFolders . Remove ( storItem ) ;
571
+ App . ViewModel . RemoveFileOrFolder ( storItem ) ;
571
572
}
572
573
Debug . WriteLine ( "Ended for loop" ) ;
573
574
History . ForwardList . Clear ( ) ;
@@ -594,7 +595,7 @@ public static async void DeleteItem_Click(object sender, RoutedEventArgs e)
594
595
await item . DeleteAsync ( StorageDeleteOption . Default ) ;
595
596
596
597
}
597
- App . ViewModel . FilesAndFolders . Remove ( storItem ) ;
598
+ App . ViewModel . RemoveFileOrFolder ( storItem ) ;
598
599
}
599
600
Debug . WriteLine ( "Ended for loop" ) ;
600
601
History . ForwardList . Clear ( ) ;
@@ -625,16 +626,36 @@ public static async void RenameItem_Click(object sender, RoutedEventArgs e)
625
626
{
626
627
var item = await StorageFolder . GetFolderFromPathAsync ( RowData . FilePath ) ;
627
628
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
+ } ) ;
630
641
}
631
642
else
632
643
{
633
644
var item = await StorageFile . GetFileFromPathAsync ( RowData . FilePath ) ;
634
645
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
+ } ) ;
638
659
}
639
660
}
640
661
@@ -659,16 +680,36 @@ public static async void RenameItem_Click(object sender, RoutedEventArgs e)
659
680
{
660
681
var item = await StorageFolder . GetFolderFromPathAsync ( BoxData . FilePath ) ;
661
682
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
+ } ) ;
664
695
}
665
696
else
666
697
{
667
698
var item = await StorageFile . GetFileFromPathAsync ( BoxData . FilePath ) ;
668
699
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
+ } ) ;
672
713
}
673
714
}
674
715
0 commit comments