26
26
using Windows . Storage . Streams ;
27
27
using System . ComponentModel ;
28
28
using System . Diagnostics ;
29
+ using Windows . ApplicationModel . DataTransfer ;
30
+ using System . Collections ;
31
+ using System . Collections . Generic ;
32
+ using System . Linq ;
33
+ using Windows . Storage . Search ;
34
+ using Windows . UI . Popups ;
29
35
30
36
namespace Interact
31
37
{
@@ -43,6 +49,8 @@ public Interaction(Page p)
43
49
page = p ;
44
50
}
45
51
52
+ public static MessageDialog message ;
53
+ private static Uri site_uri = new Uri ( @"https://duke58701.wixsite.com/files-windows10/sideloading-help" ) ;
46
54
47
55
// Double-tap event for DataGrid
48
56
public static async void List_ItemClick ( object sender , DoubleTappedRoutedEventArgs e )
@@ -66,11 +74,22 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
66
74
GenericFileBrowser . P . path = clickedOnItem . FilePath ;
67
75
GenericFileBrowser . UpdateAllBindings ( ) ;
68
76
}
77
+ else if ( clickedOnItem . FileExtension == "Executable" )
78
+ {
79
+ message = new MessageDialog ( "We noticed you’re trying to run an executable file. This type of file may be a security risk to your device, and is not supported by the Universal Windows Platform. If you're not sure what this means, check out the Microsoft Store for a large selection of secure apps, games, and more." ) ;
80
+ message . Title = "Unsupported Functionality" ;
81
+ message . Commands . Add ( new UICommand ( "Continue..." , new UICommandInvokedHandler ( Interaction . CommandInvokedHandler ) ) ) ;
82
+ message . Commands . Add ( new UICommand ( "Cancel" ) ) ;
83
+ await message . ShowAsync ( ) ;
84
+ }
69
85
else
70
86
{
71
87
StorageFile file = await StorageFile . GetFileFromPathAsync ( clickedOnItem . FilePath ) ;
72
- var options = new Windows . System . LauncherOptions ( ) ;
73
- options . DisplayApplicationPicker = true ;
88
+ var options = new LauncherOptions
89
+ {
90
+ DisplayApplicationPicker = true
91
+
92
+ } ;
74
93
await Launcher . LaunchFileAsync ( file , options ) ;
75
94
}
76
95
}
@@ -84,6 +103,11 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
84
103
85
104
}
86
105
106
+ private static async void CommandInvokedHandler ( IUICommand command )
107
+ {
108
+ await Launcher . LaunchUriAsync ( new Uri ( "ms-windows-store://home" ) ) ;
109
+ }
110
+
87
111
public static async void PhotoAlbumItemList_ClickAsync ( object sender , ItemClickEventArgs e )
88
112
{
89
113
GridView grid = sender as GridView ;
@@ -193,13 +217,98 @@ public static void CutItem_Click(object sender, RoutedEventArgs e)
193
217
194
218
}
195
219
196
- public static void CopyItem_Click ( object sender , RoutedEventArgs e )
220
+ public static async void CopyItem_ClickAsync ( object sender , RoutedEventArgs e )
197
221
{
222
+ DataPackage dataPackage = new DataPackage ( ) ;
223
+ dataPackage . RequestedOperation = DataPackageOperation . Copy ;
224
+ var DataGridSelectedItem = ItemViewModel . FilesAndFolders [ GenericFileBrowser . data . SelectedIndex ] ;
225
+ if ( DataGridSelectedItem != null )
226
+ {
227
+ var path = ItemViewModel . PUIP . Path ;
228
+ var fol = await StorageFolder . GetFolderFromPathAsync ( path ) ;
229
+ var item = await fol . GetItemAsync ( DataGridSelectedItem . FileName ) ;
230
+ List < IStorageItem > items = new List < IStorageItem > ( ) ;
231
+ items . Add ( item ) ;
232
+ IEnumerable < IStorageItem > EnumerableOfItems = items ;
233
+ dataPackage . SetStorageItems ( EnumerableOfItems ) ;
234
+ Clipboard . SetContent ( dataPackage ) ;
235
+
236
+ }
237
+ }
238
+
239
+ public static async void PasteItem_ClickAsync ( object sender , RoutedEventArgs e )
240
+ {
241
+ // TODO: Add progress box and collision for this operation
242
+ var DestinationPath = ItemViewModel . PUIP . Path ;
243
+ DataPackageView packageView = Clipboard . GetContent ( ) ;
244
+ var ItemsToPaste = await packageView . GetStorageItemsAsync ( ) ;
245
+ foreach ( IStorageItem item in ItemsToPaste )
246
+ {
247
+ StorageFolder SourceFolder = await StorageFolder . GetFolderFromPathAsync ( item . Path ) ;
248
+
249
+ if ( item . IsOfType ( StorageItemTypes . Folder ) )
250
+ {
251
+ CloneDirectory ( item . Path , DestinationPath ) ;
252
+
253
+ }
254
+ else if ( item . IsOfType ( StorageItemTypes . File ) )
255
+ {
256
+ StorageFile DestinationFile = await StorageFile . GetFileFromPathAsync ( item . Path ) ;
257
+ await DestinationFile . CopyAsync ( await StorageFolder . GetFolderFromPathAsync ( DestinationPath ) ) ;
258
+ }
259
+
260
+ }
261
+
262
+ }
263
+
264
+ public static async void CloneDirectory ( string root , string dest )
265
+ {
266
+ StorageFolder SourceFolder = await StorageFolder . GetFolderFromPathAsync ( root ) ;
267
+ StorageFolder DestinationFolder = await StorageFolder . GetFolderFromPathAsync ( dest ) ;
268
+ //// Check for clone of source folder in destination folder
269
+ //var FolderCreate = await DestinationFolder.TryGetItemAsync(SourceFolder.Name);
270
+ //// if not there, then create it
271
+ //if (FolderCreate == null)
272
+ //{
273
+ // await DestinationFolder.CreateFolderAsync(SourceFolder.Name);
274
+ // Debug.WriteLine("Source folder clone not found in destination");
275
+ //}
276
+ //// If there, then update dest folder to reflect this
277
+ //else
278
+ //{
279
+ // DestinationFolder = await StorageFolder.GetFolderFromPathAsync(dest + @"\" + SourceFolder.Name);
280
+ // foreach (var directory in await SourceFolder.GetFoldersAsync())
281
+ // {
282
+ // string DirName = directory.Name;
283
+ // if (await DestinationFolder.TryGetItemAsync(DirName) == null)
284
+ // {
285
+ // await DestinationFolder.CreateFolderAsync(DirName);
286
+ // }
287
+ // CloneDirectory(directory.Path, dest + @"\" + DirName);
288
+ // }
289
+ //}
290
+
291
+ var FolderCreate = await DestinationFolder . TryGetItemAsync ( SourceFolder . Name ) ;
292
+ // Create initial root directory in dest if not there already
293
+ if ( FolderCreate == null )
294
+ {
295
+ await DestinationFolder . CreateFolderAsync ( SourceFolder . Name ) ;
296
+ Debug . WriteLine ( "Source folder clone not found in destination" ) ;
297
+ }
298
+ foreach ( var directory in await SourceFolder . GetFoldersAsync ( ) )
299
+ {
300
+ string DirName = directory . Name ;
301
+ if ( await DestinationFolder . TryGetItemAsync ( DirName ) == null )
302
+ {
303
+ await DestinationFolder . CreateFolderAsync ( DirName ) ;
304
+ }
305
+ }
306
+
307
+
308
+
198
309
199
310
}
200
311
}
201
312
202
-
203
313
204
-
205
314
}
0 commit comments