Rename Commands enum to Command
This commit is contained in:
@@ -8,7 +8,7 @@ namespace FileTime.App.Core.Services.CommandHandler;
|
||||
|
||||
public abstract class CommandHandlerBase : ICommandHandler
|
||||
{
|
||||
private readonly Dictionary<Commands, Func<Task>> _commandHandlers = new();
|
||||
private readonly Dictionary<Command.Command, Func<Task>> _commandHandlers = new();
|
||||
private readonly IAppState? _appState;
|
||||
|
||||
protected CommandHandlerBase(IAppState? appState = null)
|
||||
@@ -16,12 +16,12 @@ public abstract class CommandHandlerBase : ICommandHandler
|
||||
_appState = appState;
|
||||
}
|
||||
|
||||
public bool CanHandleCommand(Commands command) => _commandHandlers.ContainsKey(command);
|
||||
public bool CanHandleCommand(Command.Command command) => _commandHandlers.ContainsKey(command);
|
||||
|
||||
public async Task HandleCommandAsync(Commands command) => await _commandHandlers[command].Invoke();
|
||||
public async Task HandleCommandAsync(Command.Command command) => await _commandHandlers[command].Invoke();
|
||||
|
||||
protected void AddCommandHandler(Commands command, Func<Task> handler) => _commandHandlers.Add(command, handler);
|
||||
protected void AddCommandHandlers(IEnumerable<(Commands command, Func<Task> handler)> commandHandlers)
|
||||
protected void AddCommandHandler(Command.Command command, Func<Task> handler) => _commandHandlers.Add(command, handler);
|
||||
protected void AddCommandHandlers(IEnumerable<(Command.Command command, Func<Task> handler)> commandHandlers)
|
||||
{
|
||||
foreach (var (command, handler) in commandHandlers)
|
||||
{
|
||||
@@ -29,7 +29,7 @@ public abstract class CommandHandlerBase : ICommandHandler
|
||||
}
|
||||
}
|
||||
|
||||
protected void RemoveCommandHandler(Commands command) => _commandHandlers.Remove(command);
|
||||
protected void RemoveCommandHandler(Command.Command command) => _commandHandlers.Remove(command);
|
||||
|
||||
protected IDisposable SaveSelectedTab(Action<ITabViewModel?> handler) => RunWithAppState(appState => appState.SelectedTab.Subscribe(handler));
|
||||
protected IDisposable SaveCurrentSelectedItem(Action<IItemViewModel?> handler)
|
||||
|
||||
@@ -29,13 +29,13 @@ public class ItemManipulationCommandHandler : CommandHandlerBase
|
||||
|
||||
_markedItems = new BindedCollection<IAbsolutePath>(appState.SelectedTab.Select(t => t?.MarkedItems));
|
||||
|
||||
AddCommandHandlers(new (Commands, Func<Task>)[]
|
||||
AddCommandHandlers(new (Command.Command, Func<Task>)[]
|
||||
{
|
||||
(Commands.Copy, Copy),
|
||||
(Commands.Mark, MarkItem),
|
||||
(Commands.PasteMerge, PasteMerge),
|
||||
(Commands.PasteOverwrite, PasteOverwrite),
|
||||
(Commands.PasteSkip, PasteSkip),
|
||||
(Command.Command.Copy, Copy),
|
||||
(Command.Command.Mark, MarkItem),
|
||||
(Command.Command.PasteMerge, PasteMerge),
|
||||
(Command.Command.PasteOverwrite, PasteOverwrite),
|
||||
(Command.Command.PasteSkip, PasteSkip),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ItemManipulationCommandHandler : CommandHandlerBase
|
||||
if (_selectedTab == null || _currentSelectedItem?.BaseItem?.FullName == null) return;
|
||||
|
||||
_selectedTab.ToggleMarkedItem(new AbsolutePath(_currentSelectedItem.BaseItem));
|
||||
await _commandHandlerService.HandleCommandAsync(Commands.MoveCursorDown);
|
||||
await _commandHandlerService.HandleCommandAsync(Command.Command.MoveCursorDown);
|
||||
}
|
||||
|
||||
private Task Copy()
|
||||
|
||||
@@ -24,13 +24,13 @@ public class NavigationCommandHandler : CommandHandlerBase
|
||||
SaveCurrentLocation(l => _currentLocation = l);
|
||||
SaveCurrentItems(i => _currentItems = i);
|
||||
|
||||
AddCommandHandlers(new (Commands, Func<Task>)[]
|
||||
AddCommandHandlers(new (Command.Command, Func<Task>)[]
|
||||
{
|
||||
(Commands.EnterRapidTravel, EnterRapidTravel),
|
||||
(Commands.GoUp, GoUp),
|
||||
(Commands.MoveCursorDown, MoveCursorDown),
|
||||
(Commands.MoveCursorUp, MoveCursorUp),
|
||||
(Commands.Open, OpenContainer),
|
||||
(Command.Command.EnterRapidTravel, EnterRapidTravel),
|
||||
(Command.Command.GoUp, GoUp),
|
||||
(Command.Command.MoveCursorDown, MoveCursorDown),
|
||||
(Command.Command.MoveCursorUp, MoveCursorUp),
|
||||
(Command.Command.Open, OpenContainer),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class CommandHandlerService : ICommandHandlerService
|
||||
//(Commands.ToggleHidden, ToggleHidden),
|
||||
}
|
||||
|
||||
public async Task HandleCommandAsync(Commands command)
|
||||
public async Task HandleCommandAsync(Command.Command command)
|
||||
{
|
||||
var handler = _commandHandlers.Value.FirstOrDefault(h => h.CanHandleCommand(command));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user