Skip to content

Commit 892c8c8

Browse files
committed
[WIP] Creating the command for the Recycle bin restoration.
1 parent 4c1ff5e commit 892c8c8

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

src/Files.Uwp/Helpers/RecycleBinHelpers.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,42 @@ public async Task EmptyRecycleBin()
104104
}
105105
}
106106

107+
108+
public static Task S_RestoreRecycleBin()
109+
{
110+
await new RecycleBinHelpers().RestoreRecycleBin();
111+
}
112+
113+
public async Task EmptyRecycleBin()
114+
{
115+
var ConfirmEmptyBinDialog = new ContentDialog()
116+
{
117+
Title = "ConfirmRestoreBinDialogTitle".GetLocalized(),
118+
Content = "ConfirmRestoreBinDialogContent".GetLocalized(),
119+
PrimaryButtonText = "Yes".GetLocalized(),
120+
SecondaryButtonText = "Cancel".GetLocalized(),
121+
DefaultButton = ContentDialogButton.Primary
122+
};
123+
124+
ContentDialogResult result = await ConfirmEmptyBinDialog.ShowAsync();
125+
126+
if (result == ContentDialogResult.Primary)
127+
{
128+
var connection = await ServiceConnection;
129+
if (connection != null)
130+
{
131+
var value = new ValueSet()
132+
{
133+
{ "Arguments", "RecycleBin" },
134+
{ "action", "Empty" }
135+
};
136+
137+
// Send request to fulltrust process to empty Recycle Bin
138+
await connection.SendMessageAsync(value);
139+
}
140+
}
141+
}
142+
107143
public async Task<bool> HasRecycleBin(string path)
108144
{
109145
if (string.IsNullOrEmpty(path) || path.StartsWith(@"\\?\", StringComparison.Ordinal))

src/Files.Uwp/Interacts/BaseLayoutCommandImplementationModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ public virtual async void EmptyRecycleBin(RoutedEventArgs e)
187187
await RecycleBinHelpers.S_EmptyRecycleBin();
188188
}
189189

190+
public virtual async void RestoreRecycleBin(RoutedEventArgs e)
191+
{
192+
await RecycleBinHelpers.S_RestoreRecycleBin();
193+
}
194+
190195
public virtual async void QuickLook(RoutedEventArgs e)
191196
{
192197
await QuickLookHelpers.ToggleQuickLook(associatedInstance);

src/Files.Uwp/Interacts/BaseLayoutCommandsViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ private void InitializeCommands()
3838
UnpinDirectoryFromFavoritesCommand = new RelayCommand<RoutedEventArgs>(CommandsModel.UnpinDirectoryFromFavorites);
3939
OpenItemCommand = new RelayCommand<RoutedEventArgs>(CommandsModel.OpenItem);
4040
EmptyRecycleBinCommand = new RelayCommand<RoutedEventArgs>(CommandsModel.EmptyRecycleBin);
41+
RestoreRecycleBinCommand = new RelayCommand<RoutedEventArgs>(CommandsModel.RestoreRecycleBin);
4142
QuickLookCommand = new RelayCommand<RoutedEventArgs>(CommandsModel.QuickLook);
4243
CopyItemCommand = new RelayCommand<RoutedEventArgs>(CommandsModel.CopyItem);
4344
CutItemCommand = new RelayCommand<RoutedEventArgs>(CommandsModel.CutItem);
@@ -104,6 +105,8 @@ private void InitializeCommands()
104105

105106
public ICommand EmptyRecycleBinCommand { get; private set; }
106107

108+
public ICommand RestoreRecycleBinCommand { get; private set; }
109+
107110
public ICommand QuickLookCommand { get; private set; }
108111

109112
public ICommand CopyItemCommand { get; private set; }

src/Files.Uwp/Interacts/IBaseLayoutCommandImplementationModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public interface IBaseLayoutCommandImplementationModel : IDisposable
3030

3131
void EmptyRecycleBin(RoutedEventArgs e);
3232

33+
void RestoreRecycleBin(RoutedEventArgs e);
34+
3335
void QuickLook(RoutedEventArgs e);
3436

3537
void CopyItem(RoutedEventArgs e);

0 commit comments

Comments
 (0)