/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Actions/Shelf/CopyItemFromShelfAction.cs
57 строк
2 KB
d2dyno
Code Quality: Continued working on Shelf Pane (#17308)
04 май 2026, 07:57
Не верифицирован
04 май 2026, 07:57
2968da7
Код
Авторство
О чём код?
// Copyright (c) Files Community // Licensed under the MIT License. using Windows.ApplicationModel.DataTransfer; namespace Files.App.Actions { [GeneratedRichCommand] internal sealed partial class CopyItemFromShelfAction : ObservableObject, IAction { private readonly IShelfContext shelfContext; private readonly IContentPageContext contentPageContext; private readonly StatusCenterViewModel statusCenterViewModel; public string Label => Strings.Copy.GetLocalizedResource(); public string Description => Strings.CopyItemDescription.GetLocalizedFormatResource(shelfContext.SelectedItems.Count); public ActionCategory Category => ActionCategory.FileSystem; public RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.Copy"); public bool IsExecutable => shelfContext.HasSelection && contentPageContext.ShellPage?.ShellViewModel is not null; public bool IsAccessibleGlobally => false; public CopyItemFromShelfAction() { shelfContext = Ioc.Default.GetRequiredService<IShelfContext>(); contentPageContext = Ioc.Default.GetRequiredService<IContentPageContext>(); statusCenterViewModel = Ioc.Default.GetRequiredService<StatusCenterViewModel>(); shelfContext.PropertyChanged += ShelfContext_PropertyChanged; } public async Task ExecuteAsync(object? parameter = null) { if (contentPageContext.ShellPage?.ShellViewModel is not { } shellViewModel) return; var items = shelfContext.SelectedItems.Select(x => x.Inner).ToArray(); await TransferHelpers.ExecuteTransferAsync(items, shellViewModel, statusCenterViewModel, DataPackageOperation.Copy); } private void ShelfContext_PropertyChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName is nameof(IShelfContext.HasSelection)) OnPropertyChanged(nameof(IsExecutable)); } } }