/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Actions/FileSystem/CopyItemPathWithQuotesAction.cs
61 строка
1 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 Windows.ApplicationModel.DataTransfer; namespace Files.App.Actions { [GeneratedRichCommand] internal sealed class CopyItemPathWithQuotesAction : IAction { private readonly IContentPageContext context; public string Label => Strings.CopyItemPathWithQuotes.GetLocalizedResource(); public string Description => Strings.CopyItemPathWithQuotesDescription.GetLocalizedResource(); public ActionCategory Category => ActionCategory.FileSystem; public RichGlyph Glyph => new RichGlyph(themedIconStyle: "App.ThemedIcons.CopyAsPath"); public HotKey HotKey => new(Keys.C, KeyModifiers.CtrlAlt); public bool IsExecutable => context.HasSelection; public CopyItemPathWithQuotesAction() { context = Ioc.Default.GetRequiredService<IContentPageContext>(); } public Task ExecuteAsync(object? parameter = null) { if (context.ShellPage?.SlimContentPage is not null) { var selectedItems = context.ShellPage.SlimContentPage.SelectedItems; var path = selectedItems is not null ? string.Join("\n", selectedItems.Select(item => $"\"{item.ItemPath}\"")) : context.ShellPage.ShellViewModel.WorkingDirectory; if (FtpHelpers.IsFtpPath(path)) path = path.Replace('\\', '/'); SafetyExtensions.IgnoreExceptions(() => { DataPackage data = new(); data.SetText(path); Clipboard.SetContent(data); Clipboard.Flush(); }); } return Task.CompletedTask; } } }