/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Actions/Open/EditInNotepadAction.cs
53 строки
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. using Files.Shared.Helpers; namespace Files.App.Actions { [GeneratedRichCommand] internal sealed partial class EditInNotepadAction : ObservableObject, IAction { private readonly IContentPageContext context; public string Label => Strings.EditInNotepad.GetLocalizedResource(); public string Description => Strings.EditInNotepadDescription.GetLocalizedResource(); public ActionCategory Category => ActionCategory.Open; public RichGlyph Glyph => new("\uE70F"); public bool IsExecutable => context.SelectedItems.Any() && context.PageType != ContentPageTypes.RecycleBin && context.PageType != ContentPageTypes.ZipFolder && context.SelectedItems.All(x => FileExtensionHelpers.IsBatchFile(x.FileExtension) || FileExtensionHelpers.IsAhkFile(x.FileExtension) || FileExtensionHelpers.IsCmdFile(x.FileExtension)); public EditInNotepadAction() { context = Ioc.Default.GetRequiredService<IContentPageContext>(); context.PropertyChanged += Context_PropertyChanged; } public Task ExecuteAsync(object? parameter = null) { return Task.WhenAll(context.SelectedItems.Select(item => Win32Helper.RunPowershellCommandAsync($"notepad '{item.ItemPath}\'", PowerShellExecutionOptions.Hidden))); } private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(IContentPageContext.SelectedItems): OnPropertyChanged(nameof(IsExecutable)); break; } } } }