From b260b4d58a68fff71bd679d91ef644db556572e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Sun, 15 May 2022 21:55:06 +0200 Subject: [PATCH] RootDrive navigation --- .../UserCommand/OpenContainerCommand.cs | 2 +- .../NavigationUserCommandHandlerService.cs | 17 +++++++++++++---- .../ViewModels/TabViewModel.cs | 12 ++++++------ .../FileTime.GuiApp/Views/MainWindow.axaml.cs | 3 ++- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/AppCommon/FileTime.App.Core.Abstraction/UserCommand/OpenContainerCommand.cs b/src/AppCommon/FileTime.App.Core.Abstraction/UserCommand/OpenContainerCommand.cs index 86d5222..b368dac 100644 --- a/src/AppCommon/FileTime.App.Core.Abstraction/UserCommand/OpenContainerCommand.cs +++ b/src/AppCommon/FileTime.App.Core.Abstraction/UserCommand/OpenContainerCommand.cs @@ -6,7 +6,7 @@ public class OpenContainerCommand : IUserCommand { public IAbsolutePath Path { get; } - private OpenContainerCommand(IAbsolutePath path) + public OpenContainerCommand(IAbsolutePath path) { Path = path; } diff --git a/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/NavigationUserCommandHandlerService.cs b/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/NavigationUserCommandHandlerService.cs index df711bb..7516d55 100644 --- a/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/NavigationUserCommandHandlerService.cs +++ b/src/AppCommon/FileTime.App.Core/Services/UserCommandHandler/NavigationUserCommandHandlerService.cs @@ -47,12 +47,21 @@ public class NavigationUserCommandHandlerService : UserCommandHandlerServiceBase new TypeUserCommandHandler(GoUp), new TypeUserCommandHandler(MoveCursorDown), new TypeUserCommandHandler(MoveCursorUp), - new TypeUserCommandHandler(OpenContainer), + new TypeUserCommandHandler(OpenContainer), + new TypeUserCommandHandler(OpenSelected), new TypeUserCommandHandler(SwitchToTab), }); } - private Task OpenContainer() + private async Task OpenContainer(OpenContainerCommand command) + { + var resolvedPath = await command.Path.ResolveAsync(); + if (resolvedPath is not IContainer resolvedContainer) return; + + _selectedTab?.Tab?.SetCurrentLocation(resolvedContainer); + } + + private Task OpenSelected() { if (_currentSelectedItem is not IContainerViewModel containerViewModel || containerViewModel.Container is null) return Task.CompletedTask; @@ -132,9 +141,9 @@ public class NavigationUserCommandHandlerService : UserCommandHandlerServiceBase private Task CloseTab() { if (_appState.Tabs.Count < 2) return Task.CompletedTask; - + _appState.RemoveTab(_selectedTab!); - + return Task.CompletedTask; } } \ No newline at end of file diff --git a/src/AppCommon/FileTime.App.Core/ViewModels/TabViewModel.cs b/src/AppCommon/FileTime.App.Core/ViewModels/TabViewModel.cs index 2be14d2..899f165 100644 --- a/src/AppCommon/FileTime.App.Core/ViewModels/TabViewModel.cs +++ b/src/AppCommon/FileTime.App.Core/ViewModels/TabViewModel.cs @@ -67,8 +67,8 @@ public partial class TabViewModel : ITabViewModel, IDisposable CurrentLocation = tab.CurrentLocation.AsObservable(); CurrentItems = tab.CurrentItems .Select(items => items?.Transform(i => MapItemToViewModel(i, ItemViewModelType.Main))) - .ObserveOn(_rxSchedulerService.GetWorkerScheduler()) - .SubscribeOn(_rxSchedulerService.GetUIScheduler()) + /*.ObserveOn(_rxSchedulerService.GetWorkerScheduler()) + .SubscribeOn(_rxSchedulerService.GetUIScheduler())*/ .Publish(null) .RefCount(); @@ -119,8 +119,8 @@ public partial class TabViewModel : ITabViewModel, IDisposable .Where(c => c is null or not IContainerViewModel) .Select(_ => (IObservable>?) null) ) - .ObserveOn(_rxSchedulerService.GetWorkerScheduler()) - .SubscribeOn(_rxSchedulerService.GetUIScheduler()) + /*.ObserveOn(_rxSchedulerService.GetWorkerScheduler()) + .SubscribeOn(_rxSchedulerService.GetUIScheduler())*/ .Publish(null) .RefCount(); } @@ -147,8 +147,8 @@ public partial class TabViewModel : ITabViewModel, IDisposable .Where(p => p is null) .Select(_ => (IObservable>?) null) ) - .ObserveOn(_rxSchedulerService.GetWorkerScheduler()) - .SubscribeOn(_rxSchedulerService.GetUIScheduler()) + /*.ObserveOn(_rxSchedulerService.GetWorkerScheduler()) + .SubscribeOn(_rxSchedulerService.GetUIScheduler())*/ .Publish(null) .RefCount(); } diff --git a/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml.cs b/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml.cs index 475d151..d1e347d 100644 --- a/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml.cs +++ b/src/GuiApp/Avalonia/FileTime.GuiApp/Views/MainWindow.axaml.cs @@ -1,6 +1,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Input; +using FileTime.App.Core.UserCommand; using FileTime.Core.Models; using FileTime.GuiApp.Models; using FileTime.GuiApp.ViewModels; @@ -101,7 +102,7 @@ public partial class MainWindow : Window var resolvedItem = await path.ResolveAsync(); if (resolvedItem is not IContainer resolvedContainer) return; - //ViewModel.CommandHandlerService.HandleCommandAsync() + await ViewModel.UserCommandHandlerService.HandleCommandAsync(new OpenContainerCommand(new AbsolutePath(resolvedContainer))); e.Handled = true; } }