1- using CommunityToolkit . Mvvm . DependencyInjection ;
2- using Files . App . Commands ;
3- using Files . App . Contexts ;
1+ using Files . App . Commands ;
42using Files . App . Extensions ;
5- using Files . App . Filesystem ;
6- using Files . App . Helpers ;
7- using Files . Backend . Services . Settings ;
8- using System . ComponentModel ;
9- using System . Linq ;
103using System . Threading . Tasks ;
11- using Windows . Storage ;
124
135namespace Files . App . Actions
146{
15- internal class DeleteItemAction : BaseUIAction , IAction
7+ internal class DeleteItemAction : BaseDeleteAction , IAction
168 {
17- private readonly IContentPageContext context = Ioc . Default . GetRequiredService < IContentPageContext > ( ) ;
18-
19- private readonly IFoldersSettingsService settings = Ioc . Default . GetRequiredService < IFoldersSettingsService > ( ) ;
20-
219 public string Label { get ; } = "Delete" . GetLocalizedResource ( ) ;
2210
2311 public string Description => "DeleteItemDescription" . GetLocalizedResource ( ) ;
@@ -26,32 +14,11 @@ internal class DeleteItemAction : BaseUIAction, IAction
2614
2715 public HotKey HotKey { get ; } = new ( Keys . Delete ) ;
2816
29- public override bool IsExecutable =>
30- context . HasSelection &&
31- ( ! context . ShellPage ? . SlimContentPage ? . IsRenamingItem ?? false ) &&
32- UIHelpers . CanShowDialog ;
33-
34- public DeleteItemAction ( )
35- {
36- context . PropertyChanged += Context_PropertyChanged ;
37- }
38-
39- public async Task ExecuteAsync ( )
40- {
41- if ( context . ShellPage is null || ! IsExecutable )
42- return ;
43-
44- var items = context . SelectedItems . Select ( item => StorageHelpers . FromPathAndType ( item . ItemPath ,
45- item . PrimaryItemAttribute is StorageItemTypes . File ? FilesystemItemType . File : FilesystemItemType . Directory ) ) ;
46-
47- await context . ShellPage . FilesystemHelpers . DeleteItemsAsync ( items , settings . DeleteConfirmationPolicy , false , true ) ;
48- await context . ShellPage . FilesystemViewModel . ApplyFilesAndFoldersChangesAsync ( ) ;
49- }
17+ public HotKey SecondHotKey { get ; } = new ( Keys . D , KeyModifiers . Ctrl ) ;
5018
51- private void Context_PropertyChanged ( object ? sender , PropertyChangedEventArgs e )
19+ public Task ExecuteAsync ( )
5220 {
53- if ( e . PropertyName is nameof ( IContentPageContext . HasSelection ) )
54- OnPropertyChanged ( nameof ( IsExecutable ) ) ;
21+ return DeleteItems ( false ) ;
5522 }
5623 }
5724}
0 commit comments