@@ -143,10 +143,11 @@ public static async void PhotoAlbumItemList_ClickAsync(object sender, ItemClickE
143
143
}
144
144
}
145
145
146
+ public static DataGrid dataGrid ;
146
147
147
148
public static void AllView_RightTapped ( object sender , RightTappedRoutedEventArgs e )
148
149
{
149
- DataGrid dataGrid = ( DataGrid ) sender ;
150
+ dataGrid = ( DataGrid ) sender ;
150
151
var RowPressed = FindParent < DataGridRow > ( e . OriginalSource as DependencyObject ) ;
151
152
152
153
// If user clicks on header
@@ -213,6 +214,21 @@ public static async void OpenItem_Click(object sender, RoutedEventArgs e)
213
214
214
215
public static void ShareItem_Click ( object sender , RoutedEventArgs e )
215
216
{
217
+ DataTransferManager manager = DataTransferManager . GetForCurrentView ( ) ;
218
+ manager . DataRequested += Manager_DataRequested ;
219
+ DataTransferManager . ShowShareUI ( ) ;
220
+ }
221
+
222
+ private static void Manager_DataRequested ( DataTransferManager sender , DataRequestedEventArgs args )
223
+ {
224
+ foreach ( IStorageItem item in dataGrid . ItemsSource )
225
+ {
226
+
227
+ }
228
+ DataRequest dataRequest = args . Request ;
229
+ dataRequest . Data . SetStorageItems ( dataGrid . ItemsSource as IEnumerable < IStorageItem > ) ;
230
+ dataRequest . Data . Properties . Title = "Data Shared From Files UWP" ;
231
+ dataRequest . Data . Properties . Description = "The files/folders you selected will be shared" ;
216
232
217
233
}
218
234
@@ -277,15 +293,15 @@ public static async void PasteItem_ClickAsync(object sender, RoutedEventArgs e)
277
293
var DestinationPath = ItemViewModel . PUIP . Path ;
278
294
DataPackageView packageView = Clipboard . GetContent ( ) ;
279
295
var ItemsToPaste = await packageView . GetStorageItemsAsync ( ) ;
296
+
280
297
foreach ( IStorageItem item in ItemsToPaste )
281
298
{
282
- StorageFolder SourceFolder = await StorageFolder . GetFolderFromPathAsync ( PathSnapshot ) ;
283
-
299
+
284
300
if ( item . IsOfType ( StorageItemTypes . Folder ) )
285
301
{
286
- //CloneDirectory (item.Path, DestinationPath);
287
- StorageFolder ClipboardFolder = await StorageFolder . GetFolderFromPathAsync ( item . Path ) ;
288
- //await ClipboardFolder.
302
+ CloneDirectoryAsync ( item . Path , DestinationPath , item . Name ) ;
303
+
304
+
289
305
}
290
306
else if ( item . IsOfType ( StorageItemTypes . File ) )
291
307
{
@@ -294,15 +310,35 @@ public static async void PasteItem_ClickAsync(object sender, RoutedEventArgs e)
294
310
}
295
311
296
312
}
297
- Navigation . NavigationActions . Refresh_Click ( null , null ) ;
313
+ NavigationActions . Refresh_Click ( null , null ) ;
298
314
299
315
}
300
-
301
- public static async void CloneDirectory ( string root , string dest )
316
+ static int passNum = 0 ;
317
+ private static async void CloneDirectoryAsync ( string SourcePath , string DestinationPath , string DirName )
302
318
{
303
- StorageFolder SourceFolder = await StorageFolder . GetFolderFromPathAsync ( root ) ;
304
- StorageFolder DestinationFolder = await StorageFolder . GetFolderFromPathAsync ( dest ) ;
305
-
319
+ passNum ++ ;
320
+ StorageFolder SourceFolder = await StorageFolder . GetFolderFromPathAsync ( SourcePath ) ;
321
+ StorageFolder DestinationFolder = await StorageFolder . GetFolderFromPathAsync ( DestinationPath ) ;
322
+
323
+ if ( passNum == 1 )
324
+ {
325
+ await DestinationFolder . CreateFolderAsync ( DirName ) ;
326
+ DestinationPath = DestinationPath + @"\" + DirName ;
327
+ DestinationFolder = await StorageFolder . GetFolderFromPathAsync ( DestinationPath ) ;
328
+ // SourcePath = SourcePath + @"\" + DirName;
329
+ // SourceFolder = await StorageFolder.GetFolderFromPathAsync(SourcePath);
330
+ }
331
+
332
+ Debug . WriteLine ( "Pass " + passNum ) ;
333
+ foreach ( StorageFile file in await SourceFolder . GetFilesAsync ( ) )
334
+ {
335
+ await file . CopyAsync ( DestinationFolder ) ;
336
+ }
337
+ foreach ( StorageFolder folder in await SourceFolder . GetFoldersAsync ( ) )
338
+ {
339
+ await DestinationFolder . CreateFolderAsync ( folder . DisplayName ) ;
340
+ CloneDirectoryAsync ( folder . Path , DestinationPath + @"\" + folder . DisplayName , folder . DisplayName ) ;
341
+ }
306
342
}
307
343
}
308
344
0 commit comments