Copy
This commit is contained in:
@@ -10,8 +10,8 @@ using FileTime.Core.Interactions;
|
||||
using FileTime.Core.Models;
|
||||
using FileTime.Core.Timeline;
|
||||
using InitableService;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using CopyCommand = FileTime.Core.Command.Copy.CopyCommand;
|
||||
|
||||
namespace FileTime.App.Core.Services.UserCommandHandler;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
private IItemViewModel? _currentSelectedItem;
|
||||
private readonly IUserCommandHandlerService _userCommandHandlerService;
|
||||
private readonly IClipboardService _clipboardService;
|
||||
private readonly IInputInterface _inputInterface;
|
||||
private readonly IUserCommunicationService _userCommunicationService;
|
||||
private readonly ILogger<ItemManipulationUserCommandHandlerService> _logger;
|
||||
private readonly ICommandScheduler _commandScheduler;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
@@ -32,7 +32,7 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
IAppState appState,
|
||||
IUserCommandHandlerService userCommandHandlerService,
|
||||
IClipboardService clipboardService,
|
||||
IInputInterface inputInterface,
|
||||
IUserCommunicationService userCommunicationService,
|
||||
ILogger<ItemManipulationUserCommandHandlerService> logger,
|
||||
ITimelessContentProvider timelessContentProvider,
|
||||
ICommandScheduler commandScheduler,
|
||||
@@ -40,7 +40,7 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
{
|
||||
_userCommandHandlerService = userCommandHandlerService;
|
||||
_clipboardService = clipboardService;
|
||||
_inputInterface = inputInterface;
|
||||
_userCommunicationService = userCommunicationService;
|
||||
_logger = logger;
|
||||
_commandScheduler = commandScheduler;
|
||||
_serviceProvider = serviceProvider;
|
||||
@@ -72,7 +72,7 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
private Task Copy()
|
||||
{
|
||||
_clipboardService.Clear();
|
||||
_clipboardService.SetCommand<CopyCommand>();
|
||||
_clipboardService.SetCommand<FileTime.Core.Command.Copy.CopyCommand>();
|
||||
|
||||
if ((_markedItems?.Collection?.Count ?? 0) > 0)
|
||||
{
|
||||
@@ -120,17 +120,38 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
await Paste(TransportMode.Skip);
|
||||
}
|
||||
|
||||
private Task Paste(TransportMode skip)
|
||||
private async Task Paste(TransportMode mode)
|
||||
{
|
||||
if (_clipboardService.CommandType is null) return Task.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
if (_clipboardService.CommandType is null)
|
||||
{
|
||||
_userCommunicationService.ShowToastMessage("Clipboard is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
var command = (ITransportationCommand) _serviceProvider.GetRequiredService(_clipboardService.CommandType);
|
||||
command.TransportMode = mode;
|
||||
|
||||
command.Sources.Clear();
|
||||
|
||||
foreach (var item in _clipboardService.Content)
|
||||
{
|
||||
command.Sources.Add(item);
|
||||
}
|
||||
|
||||
command.Target = _currentLocation?.FullName;
|
||||
|
||||
_clipboardService.Clear();
|
||||
|
||||
if (command is IRequireInputCommand requireInput) await requireInput.ReadInputs();
|
||||
|
||||
await AddCommand(command);
|
||||
}
|
||||
|
||||
private async Task CreateContainer()
|
||||
{
|
||||
var containerNameInput = new TextInputElement("Container name");
|
||||
|
||||
await _inputInterface.ReadInputs(containerNameInput);
|
||||
await _userCommunicationService.ReadInputs(containerNameInput);
|
||||
|
||||
//TODO: message on empty result
|
||||
var newContainerName = containerNameInput.Value;
|
||||
@@ -140,14 +161,14 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
var command = _serviceProvider
|
||||
.GetInitableResolver(_currentLocation.FullName, newContainerName)
|
||||
.GetRequiredService<CreateContainerCommand>();
|
||||
await _commandScheduler.AddCommand(command);
|
||||
await AddCommand(command);
|
||||
}
|
||||
|
||||
private async Task CreateElement()
|
||||
{
|
||||
var containerNameInput = new TextInputElement("Element name");
|
||||
|
||||
await _inputInterface.ReadInputs(containerNameInput);
|
||||
await _userCommunicationService.ReadInputs(containerNameInput);
|
||||
|
||||
//TODO: message on empty result
|
||||
var newContainerName = containerNameInput.Value;
|
||||
@@ -157,6 +178,11 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
var command = _serviceProvider
|
||||
.GetInitableResolver(_currentLocation.FullName, newContainerName)
|
||||
.GetRequiredService<CreateElementCommand>();
|
||||
await AddCommand(command);
|
||||
}
|
||||
|
||||
private async Task AddCommand(ICommand command)
|
||||
{
|
||||
await _commandScheduler.AddCommand(command);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class NavigationUserCommandHandlerService : UserCommandHandlerServiceBase
|
||||
private readonly ILocalContentProvider _localContentProvider;
|
||||
private readonly IUserCommandHandlerService _userCommandHandlerService;
|
||||
private readonly ITimelessContentProvider _timelessContentProvider;
|
||||
private readonly IInputInterface _inputInterface;
|
||||
private readonly IUserCommunicationService _userCommunicationService;
|
||||
private ITabViewModel? _selectedTab;
|
||||
private IContainer? _currentLocation;
|
||||
private IItemViewModel? _currentSelectedItem;
|
||||
@@ -32,14 +32,14 @@ public class NavigationUserCommandHandlerService : UserCommandHandlerServiceBase
|
||||
ILocalContentProvider localContentProvider,
|
||||
IUserCommandHandlerService userCommandHandlerService,
|
||||
ITimelessContentProvider timelessContentProvider,
|
||||
IInputInterface inputInterface) : base(appState)
|
||||
IUserCommunicationService userCommunicationService) : base(appState)
|
||||
{
|
||||
_appState = appState;
|
||||
_serviceProvider = serviceProvider;
|
||||
_localContentProvider = localContentProvider;
|
||||
_userCommandHandlerService = userCommandHandlerService;
|
||||
_timelessContentProvider = timelessContentProvider;
|
||||
_inputInterface = inputInterface;
|
||||
_userCommunicationService = userCommunicationService;
|
||||
|
||||
SaveSelectedTab(t => _selectedTab = t);
|
||||
SaveCurrentSelectedItem(i => _currentSelectedItem = i);
|
||||
@@ -74,7 +74,7 @@ public class NavigationUserCommandHandlerService : UserCommandHandlerServiceBase
|
||||
private async Task GoToPath()
|
||||
{
|
||||
var pathInput = new TextInputElement("Path");
|
||||
await _inputInterface.ReadInputs(pathInput);
|
||||
await _userCommunicationService.ReadInputs(pathInput);
|
||||
|
||||
//TODO: message on empty result and on null pathInput.Value
|
||||
var resolvedPath = await _timelessContentProvider.GetItemByNativePathAsync(new NativePath(pathInput.Value));
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Reactive.Linq;
|
||||
using System.Reactive.Subjects;
|
||||
using DynamicData;
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.Core.Timeline;
|
||||
using MvvmGen;
|
||||
using MoreLinq;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using FileTime.App.Core.Models;
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.Core.Models;
|
||||
using FileTime.Core.Models.Extensions;
|
||||
using MvvmGen;
|
||||
|
||||
namespace FileTime.App.Core.ViewModels;
|
||||
|
||||
@@ -4,11 +4,10 @@ using FileTime.App.Core.Extensions;
|
||||
using FileTime.App.Core.Models;
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.App.Core.ViewModels.ItemPreview;
|
||||
using FileTime.Core.Models;
|
||||
using FileTime.Core.Models.Extensions;
|
||||
using FileTime.Core.Services;
|
||||
using InitableService;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MvvmGen;
|
||||
|
||||
namespace FileTime.App.Core.ViewModels;
|
||||
|
||||
Reference in New Issue
Block a user