/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Actions/Content/PreviewPopup/LaunchPreviewPopupAction.cs
73 строки
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 LaunchPreviewPopupAction : ObservableObject, IAction { private readonly IContentPageContext context; private readonly IPreviewPopupService previewPopupService; public string Label => Strings.LaunchPreviewPopup.GetLocalizedResource(); public string Description => Strings.LaunchPreviewPopupDescription.GetLocalizedResource(); public ActionCategory Category => ActionCategory.Show; public HotKey HotKey => new(Keys.Space); public bool IsExecutable => context.SelectedItems.Count == 1 && (!context.ShellPage?.SlimContentPage?.IsRenamingItem ?? false); public LaunchPreviewPopupAction() { context = Ioc.Default.GetRequiredService<IContentPageContext>(); previewPopupService = Ioc.Default.GetRequiredService<IPreviewPopupService>(); context.PropertyChanged += Context_PropertyChanged; } public async Task ExecuteAsync(object? parameter = null) { var provider = await previewPopupService.GetProviderAsync(); if (provider is null) return; var itemPath = context.SelectedItem?.ItemPath; if (itemPath is not null) await provider.TogglePreviewPopupAsync(itemPath); } private async Task SwitchPopupPreviewAsync() { if (IsExecutable) { var provider = await previewPopupService.GetProviderAsync(); if (provider is null) return; var itemPath = context.SelectedItem?.ItemPath; if (itemPath is not null) await provider.SwitchPreviewAsync(itemPath); } } public async void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(IContentPageContext.SelectedItems): OnPropertyChanged(nameof(IsExecutable)); await SwitchPopupPreviewAsync(); break; } } } }