Skip to content

Commit cedbcc3

Browse files
committed
Ensure items to delete during Cut operation persist through navigations
1 parent 0b9705f commit cedbcc3

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

Files UWP/App.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Files.Interacts;
22
using Files.Navigation;
33
using System;
4+
using System.Collections.Generic;
45
using System.Diagnostics;
56
using System.Threading;
67
using Windows.ApplicationModel;
@@ -74,6 +75,9 @@ private void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExce
7475
}
7576

7677
public static PasteState PS { get; set; } = new PasteState();
78+
79+
public static List<string> pathsToDeleteAfterPaste = new List<string>();
80+
7781
/// <summary>
7882
/// Invoked when the application is launched normally by the end user. Other entry points
7983
/// will be used such as when the application is launched to open a specific file.

Files UWP/Interacts/Interaction.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -897,22 +897,30 @@ public async void RenameItem_Click(object sender, RoutedEventArgs e)
897897
}
898898
}
899899

900-
List<string> pathsToDeleteAfterPaste = new List<string>();
901900

902901
public List<DataGridRow> dataGridRows = new List<DataGridRow>();
903902
public async void CutItem_Click(object sender, RoutedEventArgs e)
904903
{
905904
DataPackage dataPackage = new DataPackage();
906905
dataPackage.RequestedOperation = DataPackageOperation.Move;
907-
pathsToDeleteAfterPaste.Clear();
906+
App.pathsToDeleteAfterPaste.Clear();
908907
List<IStorageItem> items = new List<IStorageItem>();
909908
if (typeof(PageType) == typeof(GenericFileBrowser))
910909
{
911910
var CurrentInstance = ItemViewModel<GenericFileBrowser>.GetCurrentSelectedTabInstance<ProHome>();
912911
if ((CurrentInstance.accessibleContentFrame.Content as GenericFileBrowser).data.SelectedItems.Count != 0)
913912
{
913+
dataGridRows.Clear();
914914
FindChildren<DataGridRow>(dataGridRows, (CurrentInstance.accessibleContentFrame.Content as GenericFileBrowser).GFBPageName.Content);
915915

916+
// First, reset DataGrid Rows that may be in "cut" command mode
917+
foreach (DataGridRow row in dataGridRows)
918+
{
919+
if (row.Opacity < 1)
920+
{
921+
row.Opacity = 1;
922+
}
923+
}
916924

917925
foreach (ListedItem StorItem in (CurrentInstance.accessibleContentFrame.Content as GenericFileBrowser).data.SelectedItems)
918926
{
@@ -925,7 +933,7 @@ public async void CutItem_Click(object sender, RoutedEventArgs e)
925933
}
926934
}
927935
var RowPressed = FindParent<DataGridRow>((CurrentInstance.accessibleContentFrame.Content as GenericFileBrowser).data as DependencyObject);
928-
pathsToDeleteAfterPaste.Add(StorItem.FilePath);
936+
App.pathsToDeleteAfterPaste.Add(StorItem.FilePath);
929937
if (StorItem.FileType != "Folder")
930938
{
931939
var item = await StorageFile.GetFileFromPathAsync(StorItem.FilePath);
@@ -947,7 +955,7 @@ public async void CutItem_Click(object sender, RoutedEventArgs e)
947955
{
948956
foreach (ListedItem StorItem in (type as PhotoAlbum).gv.SelectedItems)
949957
{
950-
pathsToDeleteAfterPaste.Add(StorItem.FilePath);
958+
App.pathsToDeleteAfterPaste.Add(StorItem.FilePath);
951959
if (StorItem.FileType != "Folder")
952960
{
953961
var item = await StorageFile.GetFileFromPathAsync(StorItem.FilePath);
@@ -1056,7 +1064,7 @@ public async void PasteItem_ClickAsync(object sender, RoutedEventArgs e)
10561064

10571065
if (packageView.RequestedOperation == DataPackageOperation.Move)
10581066
{
1059-
foreach (string path in pathsToDeleteAfterPaste)
1067+
foreach (string path in App.pathsToDeleteAfterPaste)
10601068
{
10611069
if (path.Contains("."))
10621070
{
@@ -1070,7 +1078,7 @@ public async void PasteItem_ClickAsync(object sender, RoutedEventArgs e)
10701078
}
10711079
}
10721080
}
1073-
NavigationActions.Refresh_Click(null, null);
1081+
10741082
}
10751083

10761084
public async void CloneDirectoryAsync(string SourcePath, string DestinationPath, string sourceRootName)

0 commit comments

Comments
 (0)