/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Actions/FileSystem/PasteItemAsShortcutAction.cs
66 строк
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 sealed partial class PasteItemAsShortcutAction : ObservableObject, IAction { private readonly IContentPageContext context; public string Label => Strings.PasteShortcut.GetLocalizedResource(); public string Description => Strings.PasteShortcutDescription.GetLocalizedResource(); public ActionCategory Category => ActionCategory.FileSystem; public RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.Paste"); public bool IsExecutable => GetIsExecutable(); public PasteItemAsShortcutAction() { context = Ioc.Default.GetRequiredService<IContentPageContext>(); context.PropertyChanged += Context_PropertyChanged; App.AppModel.PropertyChanged += AppModel_PropertyChanged; } public Task ExecuteAsync(object? parameter = null) { if (context.ShellPage is null) return Task.CompletedTask; string path = context.ShellPage.ShellViewModel.WorkingDirectory; return UIFilesystemHelpers.PasteItemAsShortcutAsync(path, context.ShellPage); } public bool GetIsExecutable() { return App.AppModel.IsPasteEnabled && context.PageType != ContentPageTypes.Home && context.PageType != ContentPageTypes.RecycleBin && context.PageType != ContentPageTypes.SearchResults && context.PageType != ContentPageTypes.ReleaseNotes && context.PageType != ContentPageTypes.Settings; } private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName is nameof(IContentPageContext.PageType)) OnPropertyChanged(nameof(IsExecutable)); } private void AppModel_PropertyChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName is nameof(AppModel.IsPasteEnabled)) OnPropertyChanged(nameof(IsExecutable)); } } }