/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Actions/FileSystem/BaseDeleteAction.cs
53 строки
1 KB
yair100
Code Quality: Add Category, ExtendedLabel, AutomationId and AccessKey to actions (#18308)
27 мар 2026, 00:40
Не верифицирован
27 мар 2026, 00:40
6ef1f17
Код
Авторство
О чём код?
// Copyright (c) Files Community // Licensed under the MIT License. using Windows.Storage; namespace Files.App.Actions { internal abstract class BaseDeleteAction : BaseUIAction { private readonly IFoldersSettingsService settings; protected readonly IContentPageContext context; public virtual ActionCategory Category => ActionCategory.FileSystem; public override bool IsExecutable => context.HasSelection && (!context.ShellPage?.SlimContentPage?.IsRenamingItem ?? false) && UIHelpers.CanShowDialog; public BaseDeleteAction() { settings = Ioc.Default.GetRequiredService<IFoldersSettingsService>(); context = Ioc.Default.GetRequiredService<IContentPageContext>(); context.PropertyChanged += Context_PropertyChanged; } protected async Task DeleteItemsAsync(bool permanently) { var items = context.SelectedItems.Select(item => StorageHelpers.FromPathAndType( item.ItemPath, item.PrimaryItemAttribute is StorageItemTypes.File ? FilesystemItemType.File : FilesystemItemType.Directory)); if (context.ShellPage is IShellPage shellPage) { await shellPage.FilesystemHelpers.DeleteItemsAsync(items, settings.DeleteConfirmationPolicy, permanently, true); await shellPage.ShellViewModel.ApplyFilesAndFoldersChangesAsync(); } } private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName is nameof(IContentPageContext.HasSelection)) OnPropertyChanged(nameof(IsExecutable)); } } }