/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Actions/Content/Install/InstallFontAction.cs
65 строк
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 InstallFontAction : ObservableObject, IAction { private readonly IContentPageContext context; private static readonly StatusCenterViewModel StatusCenterViewModel = Ioc.Default.GetRequiredService<StatusCenterViewModel>(); public string Label => Strings.InstallFont.GetLocalizedResource(); public string Description => Strings.InstallFontDescription.GetLocalizedFormatResource(context.SelectedItems.Count); public RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.Actions.FontInstall"); public ActionCategory Category => ActionCategory.Install; public bool IsExecutable => context.SelectedItems.Any() && context.SelectedItems.All(x => FileExtensionHelpers.IsFontFile(x.FileExtension)) && context.PageType != ContentPageTypes.RecycleBin && context.PageType != ContentPageTypes.ZipFolder; public InstallFontAction() { context = Ioc.Default.GetRequiredService<IContentPageContext>(); context.PropertyChanged += Context_PropertyChanged; } public async Task ExecuteAsync(object? parameter = null) { if (context?.ShellPage?.ShellViewModel.WorkingDirectory is null) return; var banner = StatusCenterHelper.AddCard_InstallFont(context.ShellPage.ShellViewModel.WorkingDirectory.CreateEnumerable(), ReturnResult.InProgress, context.SelectedItems.Count); banner.IsCancelable = false; var paths = context.SelectedItems.Select(item => item.ItemPath).ToArray(); await Win32Helper.InstallFontsAsync(paths, false); StatusCenterViewModel.RemoveItem(banner); StatusCenterHelper.AddCard_InstallFont(context.ShellPage.ShellViewModel.WorkingDirectory.CreateEnumerable(), ReturnResult.Success, context.SelectedItems.Count); } public void Context_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(IContentPageContext.SelectedItems): case nameof(IContentPageContext.PageType): OnPropertyChanged(nameof(IsExecutable)); break; } } } }