@@ -474,19 +474,39 @@ private async static void Manager_DataRequested(DataTransferManager sender, Data
474474 {
475475 DataRequestDeferral dataRequestDeferral = args . Request . GetDeferral ( ) ;
476476 List < IStorageItem > items = new List < IStorageItem > ( ) ;
477- foreach ( ListedItem li in dataGrid . SelectedItems )
477+ if ( page . Name == "GenericItemView" )
478478 {
479- if ( li . FileExtension == "Folder" )
479+ foreach ( ListedItem li in dataGrid . SelectedItems )
480480 {
481- var folderAsItem = await StorageFolder . GetFolderFromPathAsync ( li . FilePath ) ;
482- items . Add ( folderAsItem ) ;
481+ if ( li . FileExtension == "Folder" )
482+ {
483+ var folderAsItem = await StorageFolder . GetFolderFromPathAsync ( li . FilePath ) ;
484+ items . Add ( folderAsItem ) ;
485+ }
486+ else
487+ {
488+ var fileAsItem = await StorageFile . GetFileFromPathAsync ( li . FilePath ) ;
489+ items . Add ( fileAsItem ) ;
490+ }
483491 }
484- else
492+ }
493+ else if ( page . Name == "PhotoAlbumViewer" )
494+ {
495+ foreach ( ListedItem li in PhotoAlbum . gv . SelectedItems )
485496 {
486- var fileAsItem = await StorageFile . GetFileFromPathAsync ( li . FilePath ) ;
487- items . Add ( fileAsItem ) ;
497+ if ( li . FileExtension == "Folder" )
498+ {
499+ var folderAsItem = await StorageFolder . GetFolderFromPathAsync ( li . FilePath ) ;
500+ items . Add ( folderAsItem ) ;
501+ }
502+ else
503+ {
504+ var fileAsItem = await StorageFile . GetFileFromPathAsync ( li . FilePath ) ;
505+ items . Add ( fileAsItem ) ;
506+ }
488507 }
489508 }
509+
490510 DataRequest dataRequest = args . Request ;
491511 dataRequest . Data . SetStorageItems ( items ) ;
492512 dataRequest . Data . Properties . Title = "Data Shared From Files" ;
@@ -563,38 +583,74 @@ public static async void DeleteItem_Click(object sender, RoutedEventArgs e)
563583
564584 public static async void RenameItem_Click ( object sender , RoutedEventArgs e )
565585 {
566- try
586+ if ( page . Name == "GenericItemView" )
567587 {
568- var ItemSelected = GenericFileBrowser . data . SelectedIndex ;
569- var RowData = ItemViewModel . FilesAndFolders [ ItemSelected ] ;
570- await GenericFileBrowser . NameBox . ShowAsync ( ) ;
571- var input = GenericFileBrowser . inputForRename ;
572- if ( input != null )
588+ try
573589 {
574- if ( RowData . FileExtension == "Folder" )
575- {
576- var item = await StorageFolder . GetFolderFromPathAsync ( RowData . FilePath ) ;
577- await item . RenameAsync ( input , NameCollisionOption . FailIfExists ) ;
578- ItemViewModel . FilesAndFolders . Remove ( RowData ) ;
579- ItemViewModel . FilesAndFolders . Add ( new ListedItem ( ) { FileName = input , FileDate = "Now" , EmptyImgVis = Visibility . Collapsed , FolderImg = Visibility . Visible , FileIconVis = Visibility . Collapsed , FileExtension = "Folder" , FileImg = null , FilePath = ( ItemViewModel . PUIP . Path + "\\ " + input ) } ) ;
580- }
581- else
590+ var ItemSelected = GenericFileBrowser . data . SelectedIndex ;
591+ var RowData = ItemViewModel . FilesAndFolders [ ItemSelected ] ;
592+ await GenericFileBrowser . NameBox . ShowAsync ( ) ;
593+ var input = GenericFileBrowser . inputForRename ;
594+ if ( input != null )
582595 {
583- var item = await StorageFile . GetFileFromPathAsync ( RowData . FilePath ) ;
584- await item . RenameAsync ( input + RowData . DotFileExtension , NameCollisionOption . FailIfExists ) ;
585- ItemViewModel . FilesAndFolders . Remove ( RowData ) ;
586- ItemViewModel . FilesAndFolders . Add ( new ListedItem ( ) { FileName = input , FileDate = "Now" , EmptyImgVis = Visibility . Visible , FolderImg = Visibility . Collapsed , FileIconVis = Visibility . Collapsed , FileExtension = RowData . FileExtension , FileImg = null , FilePath = ( ItemViewModel . PUIP . Path + "\\ " + input + RowData . DotFileExtension ) , DotFileExtension = RowData . DotFileExtension } ) ;
596+ if ( RowData . FileExtension == "Folder" )
597+ {
598+ var item = await StorageFolder . GetFolderFromPathAsync ( RowData . FilePath ) ;
599+ await item . RenameAsync ( input , NameCollisionOption . FailIfExists ) ;
600+ ItemViewModel . FilesAndFolders . Remove ( RowData ) ;
601+ ItemViewModel . FilesAndFolders . Add ( new ListedItem ( ) { FileName = input , FileDate = "Now" , EmptyImgVis = Visibility . Collapsed , FolderImg = Visibility . Visible , FileIconVis = Visibility . Collapsed , FileExtension = "Folder" , FileImg = null , FilePath = ( ItemViewModel . PUIP . Path + "\\ " + input ) } ) ;
602+ }
603+ else
604+ {
605+ var item = await StorageFile . GetFileFromPathAsync ( RowData . FilePath ) ;
606+ await item . RenameAsync ( input + RowData . DotFileExtension , NameCollisionOption . FailIfExists ) ;
607+ ItemViewModel . FilesAndFolders . Remove ( RowData ) ;
608+ ItemViewModel . FilesAndFolders . Add ( new ListedItem ( ) { FileName = input , FileDate = "Now" , EmptyImgVis = Visibility . Visible , FolderImg = Visibility . Collapsed , FileIconVis = Visibility . Collapsed , FileExtension = RowData . FileExtension , FileImg = null , FilePath = ( ItemViewModel . PUIP . Path + "\\ " + input + RowData . DotFileExtension ) , DotFileExtension = RowData . DotFileExtension } ) ;
587609
610+ }
588611 }
612+
613+ }
614+ catch ( Exception )
615+ {
616+ MessageDialog itemAlreadyExistsDialog = new MessageDialog ( "An item with this name already exists in this folder" , "Try again" ) ;
617+ await itemAlreadyExistsDialog . ShowAsync ( ) ;
589618 }
590-
591619 }
592- catch ( Exception )
620+ else if ( page . Name == "PhotoAlbumViewer" )
593621 {
594- MessageDialog itemAlreadyExistsDialog = new MessageDialog ( "An item with this name already exists in this folder" , "Try again" ) ;
595- await itemAlreadyExistsDialog . ShowAsync ( ) ;
596- }
622+ try
623+ {
624+ var ItemSelected = PhotoAlbum . gv . SelectedIndex ;
625+ var BoxData = ItemViewModel . FilesAndFolders [ ItemSelected ] ;
626+ await PhotoAlbum . NameBox . ShowAsync ( ) ;
627+ var input = PhotoAlbum . inputForRename ;
628+ if ( input != null )
629+ {
630+ if ( BoxData . FileExtension == "Folder" )
631+ {
632+ var item = await StorageFolder . GetFolderFromPathAsync ( BoxData . FilePath ) ;
633+ await item . RenameAsync ( input , NameCollisionOption . FailIfExists ) ;
634+ ItemViewModel . FilesAndFolders . Remove ( BoxData ) ;
635+ ItemViewModel . FilesAndFolders . Add ( new ListedItem ( ) { FileName = input , FileDate = "Now" , EmptyImgVis = Visibility . Collapsed , FolderImg = Visibility . Visible , FileIconVis = Visibility . Collapsed , FileExtension = "Folder" , FileImg = null , FilePath = ( ItemViewModel . PUIP . Path + "\\ " + input ) } ) ;
636+ }
637+ else
638+ {
639+ var item = await StorageFile . GetFileFromPathAsync ( BoxData . FilePath ) ;
640+ await item . RenameAsync ( input + BoxData . DotFileExtension , NameCollisionOption . FailIfExists ) ;
641+ ItemViewModel . FilesAndFolders . Remove ( BoxData ) ;
642+ ItemViewModel . FilesAndFolders . Add ( new ListedItem ( ) { FileName = input , FileDate = "Now" , EmptyImgVis = Visibility . Visible , FolderImg = Visibility . Collapsed , FileIconVis = Visibility . Collapsed , FileExtension = BoxData . FileExtension , FileImg = null , FilePath = ( ItemViewModel . PUIP . Path + "\\ " + input + BoxData . DotFileExtension ) , DotFileExtension = BoxData . DotFileExtension } ) ;
597643
644+ }
645+ }
646+
647+ }
648+ catch ( Exception )
649+ {
650+ MessageDialog itemAlreadyExistsDialog = new MessageDialog ( "An item with this name already exists in this folder" , "Try again" ) ;
651+ await itemAlreadyExistsDialog . ShowAsync ( ) ;
652+ }
653+ }
598654 History . ForwardList . Clear ( ) ;
599655 ItemViewModel . FS . isEnabled = false ;
600656 }
@@ -606,11 +662,11 @@ public async static void CutItem_Click(object sender, RoutedEventArgs e)
606662 DataPackage dataPackage = new DataPackage ( ) ;
607663 dataPackage . RequestedOperation = DataPackageOperation . Move ;
608664 pathsToDeleteAfterPaste . Clear ( ) ;
665+ List < IStorageItem > items = new List < IStorageItem > ( ) ;
609666 if ( page . Name == "GenericItemView" )
610667 {
611668 if ( GenericFileBrowser . data . SelectedItems . Count != 0 )
612669 {
613- List < IStorageItem > items = new List < IStorageItem > ( ) ;
614670 foreach ( ListedItem StorItem in GenericFileBrowser . data . SelectedItems )
615671 {
616672 pathsToDeleteAfterPaste . Add ( StorItem . FilePath ) ;
@@ -625,25 +681,43 @@ public async static void CutItem_Click(object sender, RoutedEventArgs e)
625681 items . Add ( item ) ;
626682 }
627683 }
628-
629- IEnumerable < IStorageItem > EnumerableOfItems = items ;
630- dataPackage . SetStorageItems ( EnumerableOfItems ) ;
631- Clipboard . SetContent ( dataPackage ) ;
632-
633-
634684 }
635685 }
686+ else if ( page . Name == "PhotoAlbumViewer" )
687+ {
688+ if ( PhotoAlbum . gv . SelectedItems . Count != 0 )
689+ {
690+ foreach ( ListedItem StorItem in PhotoAlbum . gv . SelectedItems )
691+ {
692+ pathsToDeleteAfterPaste . Add ( StorItem . FilePath ) ;
693+ if ( StorItem . FileExtension != "Folder" )
694+ {
695+ var item = await StorageFile . GetFileFromPathAsync ( StorItem . FilePath ) ;
696+ items . Add ( item ) ;
697+ }
698+ else
699+ {
700+ var item = await StorageFolder . GetFolderFromPathAsync ( StorItem . FilePath ) ;
701+ items . Add ( item ) ;
702+ }
703+ }
704+ }
705+ }
706+ IEnumerable < IStorageItem > EnumerableOfItems = items ;
707+ dataPackage . SetStorageItems ( EnumerableOfItems ) ;
708+ Clipboard . SetContent ( dataPackage ) ;
636709 }
637-
710+ public static string CopySourcePath ;
638711 public static async void CopyItem_ClickAsync ( object sender , RoutedEventArgs e )
639712 {
713+ CopySourcePath = ItemViewModel . PUIP . Path ;
640714 DataPackage dataPackage = new DataPackage ( ) ;
641715 dataPackage . RequestedOperation = DataPackageOperation . Copy ;
716+ List < IStorageItem > items = new List < IStorageItem > ( ) ;
642717 if ( page . Name == "GenericItemView" )
643718 {
644719 if ( GenericFileBrowser . data . SelectedItems . Count != 0 )
645720 {
646- List < IStorageItem > items = new List < IStorageItem > ( ) ;
647721 foreach ( ListedItem StorItem in GenericFileBrowser . data . SelectedItems )
648722 {
649723 if ( StorItem . FileExtension != "Folder" )
@@ -657,18 +731,12 @@ public static async void CopyItem_ClickAsync(object sender, RoutedEventArgs e)
657731 items . Add ( item ) ;
658732 }
659733 }
660-
661- IEnumerable < IStorageItem > EnumerableOfItems = items ;
662- dataPackage . SetStorageItems ( EnumerableOfItems ) ;
663- Clipboard . SetContent ( dataPackage ) ;
664-
665734 }
666735 }
667736 else if ( page . Name == "PhotoAlbumViewer" )
668737 {
669738 if ( PhotoAlbum . gv . SelectedItems . Count != 0 )
670739 {
671- List < IStorageItem > items = new List < IStorageItem > ( ) ;
672740 foreach ( ListedItem StorItem in PhotoAlbum . gv . SelectedItems )
673741 {
674742 if ( StorItem . FileExtension != "Folder" )
@@ -682,22 +750,19 @@ public static async void CopyItem_ClickAsync(object sender, RoutedEventArgs e)
682750 items . Add ( item ) ;
683751 }
684752 }
685-
686- IEnumerable < IStorageItem > EnumerableOfItems = items ;
687- dataPackage . SetStorageItems ( EnumerableOfItems ) ;
688- Clipboard . SetContent ( dataPackage ) ;
689-
690753 }
691754 }
692-
755+ IEnumerable < IStorageItem > EnumerableOfItems = items ;
756+ dataPackage . SetStorageItems ( EnumerableOfItems ) ;
757+ Clipboard . SetContent ( dataPackage ) ;
758+
693759 }
694760
695761 public static async void PasteItem_ClickAsync ( object sender , RoutedEventArgs e )
696762 {
697- // TODO: Add progress box and collision options for this operation
698763 var DestinationPath = ItemViewModel . PUIP . Path ;
699764 DataPackageView packageView = Clipboard . GetContent ( ) ;
700-
765+ var oldCount = ItemViewModel . FilesAndFolders . Count ;
701766 var ItemsToPaste = await packageView . GetStorageItemsAsync ( ) ;
702767 foreach ( IStorageItem item in ItemsToPaste )
703768 {
@@ -711,7 +776,7 @@ public static async void PasteItem_ClickAsync(object sender, RoutedEventArgs e)
711776 await ClipboardFile . CopyAsync ( await StorageFolder . GetFolderFromPathAsync ( DestinationPath ) , item . Name , NameCollisionOption . GenerateUniqueName ) ;
712777 }
713778 }
714- NavigationActions . Refresh_Click ( null , null ) ;
779+
715780 if ( packageView . RequestedOperation == DataPackageOperation . Move )
716781 {
717782 foreach ( string path in pathsToDeleteAfterPaste )
@@ -728,6 +793,16 @@ public static async void PasteItem_ClickAsync(object sender, RoutedEventArgs e)
728793 }
729794 }
730795 }
796+ if ( page . Name == "GenericItemView" )
797+ {
798+ NavigationActions . Refresh_Click ( null , null ) ;
799+ }
800+ else if ( page . Name == "PhotoAlbumViewer" )
801+ {
802+ PhotoAlbumNavActions . Refresh_Click ( null , null ) ;
803+ }
804+
805+
731806 }
732807
733808 public static async void CloneDirectoryAsync ( string SourcePath , string DestinationPath , string sourceRootName )
0 commit comments