Skip to content

Commit 09f6502

Browse files
Luke BlevinsLuke Blevins
authored andcommitted
Add Copy and Paste Support for Multiple/Individual Files
1 parent 9e12679 commit 09f6502

File tree

3 files changed

+30
-54
lines changed

3 files changed

+30
-54
lines changed

Files.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
<AppInstallerUpdateFrequency>1</AppInstallerUpdateFrequency>
2525
<AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
2626
<AppxPackageDir>C:\Users\lukeb\Documents\Packages\</AppxPackageDir>
27-
<PackageCertificateThumbprint>8B355EE80FDC6E5376DCC25B991A3CDED92C4333</PackageCertificateThumbprint>
28-
<AppxBundle>Always</AppxBundle>
27+
<PackageCertificateThumbprint>40C19AD60464664359C53F014D2D7703AB1320FD</PackageCertificateThumbprint>
28+
<AppxBundle>Never</AppxBundle>
2929
</PropertyGroup>
3030
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
3131
<DebugSymbols>true</DebugSymbols>

GenericFileBrowser.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159

160160
<Grid Padding="50,200,50,0">
161161

162-
<controls:DataGrid FocusVisualPrimaryThickness="0" SelectionMode="Single" IsDoubleTapEnabled="True" x:FieldModifier="public" x:Name="AllView" Drop="AllView_DropAsync" AutoGenerateColumns="False" CanDrag="False" AllowDrop="True" DragOver="AllView_DragOver" IsRightTapEnabled="True" CanUserReorderColumns="False" IsReadOnly="True" ItemsSource="{x:Bind local2:ItemViewModel.FilesAndFolders}" Margin="0,0,0,0" Padding="0, 0, 0, 0" HorizontalAlignment="Left">
162+
<controls:DataGrid FocusVisualPrimaryThickness="0" SelectionMode="Extended" IsDoubleTapEnabled="True" x:FieldModifier="public" x:Name="AllView" Drop="AllView_DropAsync" AutoGenerateColumns="False" CanDrag="False" AllowDrop="True" DragOver="AllView_DragOver" IsRightTapEnabled="True" CanUserReorderColumns="False" IsReadOnly="True" ItemsSource="{x:Bind local2:ItemViewModel.FilesAndFolders}" Margin="0,0,0,0" Padding="0, 0, 0, 0" HorizontalAlignment="Left">
163163

164164
<controls:DataGrid.Resources>
165165
<MenuFlyout x:Name="HeaderRightClickMenu" x:Key="HeaderRightClickFlyout">

ItemInteractions.cs

Lines changed: 27 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -226,30 +226,46 @@ public static async void CopyItem_ClickAsync(object sender, RoutedEventArgs e)
226226
{
227227
DataPackage dataPackage = new DataPackage();
228228
dataPackage.RequestedOperation = DataPackageOperation.Copy;
229-
var DataGridSelectedItem = ItemViewModel.FilesAndFolders[GenericFileBrowser.data.SelectedIndex];
230-
if(DataGridSelectedItem != null)
229+
if(GenericFileBrowser.data.SelectedItems.Count != 0)
231230
{
232-
var path = ItemViewModel.PUIP.Path;
233-
var fol = await StorageFolder.GetFolderFromPathAsync(path);
234-
var item = await fol.GetItemAsync(DataGridSelectedItem.FileName);
235231
List<IStorageItem> items = new List<IStorageItem>();
236-
items.Add(item);
232+
foreach (ListedItem StorItem in GenericFileBrowser.data.SelectedItems)
233+
{
234+
if(StorItem.FileExtension != "Folder")
235+
{
236+
var item = await StorageFile.GetFileFromPathAsync(StorItem.FilePath);
237+
items.Add(item);
238+
}
239+
else
240+
{
241+
var item = await StorageFolder.GetFolderFromPathAsync(StorItem.FilePath);
242+
items.Add(item);
243+
}
244+
}
245+
//var DataGridSelectedItem = ItemViewModel.FilesAndFolders[GenericFileBrowser.data.SelectedIndex];
246+
PathSnapshot = ItemViewModel.PUIP.Path;
247+
//var fol = await StorageFolder.GetFolderFromPathAsync(path);
248+
//foreach(IStorageItem it in fol)
249+
//{
250+
251+
//}
252+
//var item = await fol.GetItemAsync(DataGridSelectedItem.FileName);
237253
IEnumerable<IStorageItem> EnumerableOfItems = items;
238254
dataPackage.SetStorageItems(EnumerableOfItems);
239255
Clipboard.SetContent(dataPackage);
240256

241257
}
242258
}
243-
259+
static string PathSnapshot;
244260
public static async void PasteItem_ClickAsync(object sender, RoutedEventArgs e)
245261
{
246-
// TODO: Add progress box and collision for this operation
262+
// TODO: Add progress box and collision options for this operation
247263
var DestinationPath = ItemViewModel.PUIP.Path;
248264
DataPackageView packageView = Clipboard.GetContent();
249265
var ItemsToPaste = await packageView.GetStorageItemsAsync();
250266
foreach(IStorageItem item in ItemsToPaste)
251267
{
252-
StorageFolder SourceFolder = await StorageFolder.GetFolderFromPathAsync(item.Path);
268+
StorageFolder SourceFolder = await StorageFolder.GetFolderFromPathAsync(PathSnapshot);
253269

254270
if (item.IsOfType(StorageItemTypes.Folder))
255271
{
@@ -263,55 +279,15 @@ public static async void PasteItem_ClickAsync(object sender, RoutedEventArgs e)
263279
}
264280

265281
}
282+
Navigation.NavigationActions.Refresh_Click(null, null);
266283

267284
}
268285

269286
public static async void CloneDirectory(string root, string dest)
270287
{
271288
StorageFolder SourceFolder = await StorageFolder.GetFolderFromPathAsync(root);
272289
StorageFolder DestinationFolder = await StorageFolder.GetFolderFromPathAsync(dest);
273-
//// Check for clone of source folder in destination folder
274-
//var FolderCreate = await DestinationFolder.TryGetItemAsync(SourceFolder.Name);
275-
//// if not there, then create it
276-
//if (FolderCreate == null)
277-
//{
278-
// await DestinationFolder.CreateFolderAsync(SourceFolder.Name);
279-
// Debug.WriteLine("Source folder clone not found in destination");
280-
//}
281-
//// If there, then update dest folder to reflect this
282-
//else
283-
//{
284-
// DestinationFolder = await StorageFolder.GetFolderFromPathAsync(dest + @"\" + SourceFolder.Name);
285-
// foreach (var directory in await SourceFolder.GetFoldersAsync())
286-
// {
287-
// string DirName = directory.Name;
288-
// if (await DestinationFolder.TryGetItemAsync(DirName) == null)
289-
// {
290-
// await DestinationFolder.CreateFolderAsync(DirName);
291-
// }
292-
// CloneDirectory(directory.Path, dest + @"\" + DirName);
293-
// }
294-
//}
295-
296-
var FolderCreate = await DestinationFolder.TryGetItemAsync(SourceFolder.Name);
297-
// Create initial root directory in dest if not there already
298-
if (FolderCreate == null)
299-
{
300-
await DestinationFolder.CreateFolderAsync(SourceFolder.Name);
301-
Debug.WriteLine("Source folder clone not found in destination");
302-
}
303-
foreach (var directory in await SourceFolder.GetFoldersAsync())
304-
{
305-
string DirName = directory.Name;
306-
if (await DestinationFolder.TryGetItemAsync(DirName) == null)
307-
{
308-
await DestinationFolder.CreateFolderAsync(DirName);
309-
}
310-
}
311-
312-
313-
314-
290+
315291
}
316292
}
317293

0 commit comments

Comments
 (0)