Loading fix, CopyPath, Open in explorer
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System.Reactive.Linq;
|
||||
using System.Text.Json;
|
||||
using FileTime.App.Core.Models;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
|
||||
@@ -7,7 +7,6 @@ using FileTime.Core.Services;
|
||||
using FileTime.Core.Timeline;
|
||||
using FileTime.Providers.Local;
|
||||
using InitableService;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace FileTime.App.Core.Services.UserCommandHandler;
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Diagnostics;
|
||||
using FileTime.App.Core.UserCommand;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using FileTime.Core.Models;
|
||||
|
||||
namespace FileTime.App.Core.Services.UserCommandHandler;
|
||||
|
||||
public class ToolUserCommandHandlerService : UserCommandHandlerServiceBase
|
||||
{
|
||||
private readonly ISystemClipboardService _systemClipboardService;
|
||||
private IContainer? _currentLocation;
|
||||
private IItemViewModel? _currentSelectedItem;
|
||||
|
||||
public ToolUserCommandHandlerService(IAppState appState, ISystemClipboardService systemClipboardService) : base(appState)
|
||||
{
|
||||
_systemClipboardService = systemClipboardService;
|
||||
SaveCurrentLocation(l => _currentLocation = l);
|
||||
SaveCurrentSelectedItem(i => _currentSelectedItem = i);
|
||||
|
||||
AddCommandHandlers(new IUserCommandHandler[]
|
||||
{
|
||||
new TypeUserCommandHandler<OpenInDefaultFileExplorerCommand>(OpenInDefaultFileExplorer),
|
||||
new TypeUserCommandHandler<CopyNativePathCommand>(CopyNativePath),
|
||||
});
|
||||
}
|
||||
|
||||
private async Task CopyNativePath()
|
||||
{
|
||||
if (_currentSelectedItem?.BaseItem?.NativePath is null) return;
|
||||
await _systemClipboardService.CopyToClipboardAsync(_currentSelectedItem.BaseItem.NativePath.Path);
|
||||
}
|
||||
|
||||
private Task OpenInDefaultFileExplorer()
|
||||
{
|
||||
if (_currentLocation?.NativePath is null) return Task.CompletedTask;
|
||||
Process.Start("explorer.exe", "\"" + _currentLocation.NativePath.Path + "\"");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ public static class Startup
|
||||
{
|
||||
return serviceCollection
|
||||
.AddSingleton<IUserCommandHandler, NavigationUserCommandHandlerService>()
|
||||
.AddSingleton<IUserCommandHandler, ItemManipulationUserCommandHandlerService>();
|
||||
.AddSingleton<IUserCommandHandler, ItemManipulationUserCommandHandlerService>()
|
||||
.AddSingleton<IUserCommandHandler, ToolUserCommandHandlerService>();
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler
|
||||
|
||||
AddUserCommand(CloseTabCommand.Instance);
|
||||
AddUserCommand(CopyCommand.Instance);
|
||||
AddUserCommand(CopyNativePathCommand.Instance);
|
||||
AddUserCommand(CreateContainer.Instance);
|
||||
AddUserCommand(CreateElement.Instance);
|
||||
AddUserCommand(EnterRapidTravelCommand.Instance);
|
||||
@@ -28,6 +29,7 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler
|
||||
AddUserCommand(MoveCursorToLastCommand.Instance);
|
||||
AddUserCommand(MoveCursorUpCommand.Instance);
|
||||
AddUserCommand(MoveCursorUpPageCommand.Instance);
|
||||
AddUserCommand(OpenInDefaultFileExplorerCommand.Instance);
|
||||
AddUserCommand(OpenSelectedCommand.Instance);
|
||||
AddUserCommand(PasteCommand.Merge);
|
||||
AddUserCommand(PasteCommand.Overwrite);
|
||||
|
||||
Reference in New Issue
Block a user