diff --git a/src/AppCommon/FileTime.App.Core.Abstraction/Services/ISystemClipboardService.cs b/src/AppCommon/FileTime.App.Core.Abstraction/Services/ISystemClipboardService.cs index 9e1926b..b8c1f0e 100644 --- a/src/AppCommon/FileTime.App.Core.Abstraction/Services/ISystemClipboardService.cs +++ b/src/AppCommon/FileTime.App.Core.Abstraction/Services/ISystemClipboardService.cs @@ -3,4 +3,5 @@ namespace FileTime.App.Core.Services; public interface ISystemClipboardService { Task CopyToClipboardAsync(string text); + Task GetFiles(); } \ No newline at end of file diff --git a/src/AppCommon/FileTime.App.Core.Abstraction/UserCommand/PasteFilesFromClipboardCommand.cs b/src/AppCommon/FileTime.App.Core.Abstraction/UserCommand/PasteFilesFromClipboardCommand.cs new file mode 100644 index 0000000..5100f3b --- /dev/null +++ b/src/AppCommon/FileTime.App.Core.Abstraction/UserCommand/PasteFilesFromClipboardCommand.cs @@ -0,0 +1,19 @@ +using FileTime.App.Core.Models.Enums; + +namespace FileTime.App.Core.UserCommand; + +public class PasteFilesFromClipboardCommand : IIdentifiableUserCommand +{ + public const string PasteMergeCommandName = "paste_clipboard_merge"; + + public static readonly PasteFilesFromClipboardCommand Merge = new(PasteMode.Merge, PasteMergeCommandName); + public PasteMode PasteMode { get; } + + private PasteFilesFromClipboardCommand(PasteMode pasteMode, string commandName) + { + PasteMode = pasteMode; + UserCommandID = commandName; + } + + public string UserCommandID { get; } +} \ No newline at end of file diff --git a/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/ItemManipulationUserCommandHandlerService.cs b/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/ItemManipulationUserCommandHandlerService.cs index f1fb4da..2565379 100644 --- a/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/ItemManipulationUserCommandHandlerService.cs +++ b/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/ItemManipulationUserCommandHandlerService.cs @@ -27,6 +27,7 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi private readonly ITimelessContentProvider _timelessContentProvider; private readonly ICommandScheduler _commandScheduler; private readonly IServiceProvider _serviceProvider; + private readonly ISystemClipboardService _systemClipboardService; private readonly BindedCollection? _markedItems; private IContainer? _currentLocation; @@ -38,7 +39,8 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi ILogger logger, ITimelessContentProvider timelessContentProvider, ICommandScheduler commandScheduler, - IServiceProvider serviceProvider) : base(appState, timelessContentProvider) + IServiceProvider serviceProvider, + ISystemClipboardService systemClipboardService) : base(appState, timelessContentProvider) { _userCommandHandlerService = userCommandHandlerService; _clipboardService = clipboardService; @@ -47,6 +49,7 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi _timelessContentProvider = timelessContentProvider; _commandScheduler = commandScheduler; _serviceProvider = serviceProvider; + _systemClipboardService = systemClipboardService; SaveSelectedTab(t => _selectedTab = t); SaveCurrentLocation(l => _currentLocation = l); @@ -62,9 +65,15 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi new TypeUserCommandHandler(Paste), new TypeUserCommandHandler(CreateContainer), new TypeUserCommandHandler(CreateElement), + new TypeUserCommandHandler(PasteFilesFromClipboard), }); } + private async Task PasteFilesFromClipboard(PasteFilesFromClipboardCommand arg) + { + await _systemClipboardService.GetFiles(); + } + private async Task MarkItem() { if (_selectedTab == null || _currentSelectedItem?.BaseItem?.FullName == null) return; diff --git a/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs b/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs index 1c20fbd..1a6f755 100644 --- a/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs +++ b/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs @@ -38,6 +38,7 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler AddUserCommand(PasteCommand.Merge); AddUserCommand(PasteCommand.Overwrite); AddUserCommand(PasteCommand.Skip); + AddUserCommand(PasteFilesFromClipboardCommand.Merge); AddUserCommand(PauseCommandSchedulerCommand.Instance); AddUserCommand(RefreshCommand.Instance); AddUserCommand(StartCommandSchedulerCommand.Instance); diff --git a/src/GuiApp/Avalonia/FileTime.GuiApp.Abstractions/Configuration/MainConfiguration.cs b/src/GuiApp/Avalonia/FileTime.GuiApp.Abstractions/Configuration/MainConfiguration.cs index 1ac0107..77480f7 100644 --- a/src/GuiApp/Avalonia/FileTime.GuiApp.Abstractions/Configuration/MainConfiguration.cs +++ b/src/GuiApp/Avalonia/FileTime.GuiApp.Abstractions/Configuration/MainConfiguration.cs @@ -74,6 +74,7 @@ public static class MainConfiguration new(PasteCommand.PasteMergeCommandName, new[] {Key.P, Key.P}), new(PasteCommand.PasteOverwriteCommandName, new[] {Key.P, Key.O}), new(PasteCommand.PasteSkipCommandName, new[] {Key.P, Key.S}), + new(PasteFilesFromClipboardCommand.PasteMergeCommandName, new[] {Key.C, Key.X}), //new CommandBindingConfiguration(ConfigCommand.PinFavorite, new[] { Key.F, Key.P }), //new CommandBindingConfiguration(ConfigCommand.PreviousTimelineBlock, Key.H ), //new CommandBindingConfiguration(ConfigCommand.PreviousTimelineCommand, Key.K ), diff --git a/src/GuiApp/Avalonia/FileTime.GuiApp/Services/SystemClipboardService.cs b/src/GuiApp/Avalonia/FileTime.GuiApp/Services/SystemClipboardService.cs index 4fa8790..e903c4c 100644 --- a/src/GuiApp/Avalonia/FileTime.GuiApp/Services/SystemClipboardService.cs +++ b/src/GuiApp/Avalonia/FileTime.GuiApp/Services/SystemClipboardService.cs @@ -9,9 +9,26 @@ public class SystemClipboardService : ISystemClipboardService public async Task CopyToClipboardAsync(string text) { var clipboard = AvaloniaLocator.Current.GetService(); - if (clipboard is not null) - { - await clipboard.SetTextAsync(text); - } + + if (clipboard is null) { return; } + + await clipboard.SetTextAsync(text); + } + public async Task GetFiles() + { + var clipboard = AvaloniaLocator.Current.GetService(); + + if (clipboard is null) { return; } + + await clipboard.ClearAsync(); + + var formats = await clipboard.GetFormatsAsync(); + if (!formats.Contains("asd")) return; + var obj = (await clipboard.GetDataAsync("PNG")); + /*var ms = new MemoryStream(); + Serializer.Serialize(ms, obj); + byte[] data = ms.ToArray().Skip(4).ToArray(); + ms = new MemoryStream(data);*/ + ; } } \ No newline at end of file