/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Actions/FileSystem/FormatDriveAction.cs
49 строк
2 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. namespace Files.App.Actions { [GeneratedRichCommand] internal partial class FormatDriveAction : ObservableObject, IAction { private readonly IContentPageContext context = Ioc.Default.GetRequiredService<IContentPageContext>(); private readonly DrivesViewModel drivesViewModel = Ioc.Default.GetRequiredService<DrivesViewModel>(); public string Label => Strings.FormatDriveText.GetLocalizedResource(); public string Description => Strings.FormatDriveDescription.GetLocalizedResource(); public virtual ActionCategory Category => ActionCategory.FileSystem; public virtual bool IsExecutable => context.HasItem && !context.HasSelection && drivesViewModel.Drives .Cast<DriveItem>() .FirstOrDefault(x => string.Equals(x.Path, context.Folder?.ItemPath)) is DriveItem driveItem && !(driveItem.Type == DriveType.Network || string.Equals(context.Folder?.ItemPath, $@"{Constants.UserEnvironmentPaths.SystemDrivePath}\", StringComparison.OrdinalIgnoreCase)); public virtual bool IsAccessibleGlobally => true; public FormatDriveAction() { context.PropertyChanged += Context_PropertyChanged; } public virtual Task ExecuteAsync(object? parameter = null) { return Win32Helper.OpenFormatDriveDialog(context.Folder?.ItemPath ?? string.Empty); } public void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName is nameof(IContentPageContext.HasItem)) OnPropertyChanged(nameof(IsExecutable)); } } }