This commit is contained in:
2022-06-09 17:49:34 +02:00
parent 9d48caaa58
commit 0b3fe30fec
24 changed files with 254 additions and 34 deletions

View File

@@ -5,8 +5,8 @@ namespace FileTime.App.Core.Services;
public interface IModalService public interface IModalService
{ {
IObservable<IChangeSet<IModalViewModelBase>> OpenModals { get; } IObservable<IChangeSet<IModalViewModel>> OpenModals { get; }
void OpenModal(IModalViewModelBase modalToOpen); void OpenModal(IModalViewModel modalToOpen);
void CloseModal(IModalViewModelBase modalToClose); void CloseModal(IModalViewModel modalToClose);
} }

View File

@@ -0,0 +1,19 @@
namespace FileTime.App.Core.UserCommand;
public class DeleteCommand : IIdentifiableUserCommand
{
public const string SoftDeleteCommandName = "soft_delete";
public const string HardDeleteCommandName = "hard_delete";
public static DeleteCommand SoftDelete { get; } = new DeleteCommand(SoftDeleteCommandName, false);
public static DeleteCommand HardDelete { get; } = new DeleteCommand(HardDeleteCommandName, true);
private DeleteCommand(string commandName, bool hardDelete)
{
UserCommandID = commandName;
IsHardDelete = hardDelete;
}
public string UserCommandID { get; }
public bool IsHardDelete { get; }
}

View File

@@ -1,6 +1,6 @@
namespace FileTime.App.Core.ViewModels; namespace FileTime.App.Core.ViewModels;
public interface IModalViewModelBase public interface IModalViewModel
{ {
string Name { get; } string Name { get; }
} }

View File

@@ -6,6 +6,7 @@ using FileTime.App.Core.ViewModels;
using FileTime.Core.Command; using FileTime.Core.Command;
using FileTime.Core.Command.CreateContainer; using FileTime.Core.Command.CreateContainer;
using FileTime.Core.Command.CreateElement; using FileTime.Core.Command.CreateElement;
using FileTime.Core.Extensions;
using FileTime.Core.Interactions; using FileTime.Core.Interactions;
using FileTime.Core.Models; using FileTime.Core.Models;
using FileTime.Core.Timeline; using FileTime.Core.Timeline;
@@ -23,6 +24,7 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
private readonly IClipboardService _clipboardService; private readonly IClipboardService _clipboardService;
private readonly IUserCommunicationService _userCommunicationService; private readonly IUserCommunicationService _userCommunicationService;
private readonly ILogger<ItemManipulationUserCommandHandlerService> _logger; private readonly ILogger<ItemManipulationUserCommandHandlerService> _logger;
private readonly ITimelessContentProvider _timelessContentProvider;
private readonly ICommandScheduler _commandScheduler; private readonly ICommandScheduler _commandScheduler;
private readonly IServiceProvider _serviceProvider; private readonly IServiceProvider _serviceProvider;
private readonly BindedCollection<FullName>? _markedItems; private readonly BindedCollection<FullName>? _markedItems;
@@ -42,6 +44,7 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
_clipboardService = clipboardService; _clipboardService = clipboardService;
_userCommunicationService = userCommunicationService; _userCommunicationService = userCommunicationService;
_logger = logger; _logger = logger;
_timelessContentProvider = timelessContentProvider;
_commandScheduler = commandScheduler; _commandScheduler = commandScheduler;
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
@@ -54,6 +57,7 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
AddCommandHandlers(new IUserCommandHandler[] AddCommandHandlers(new IUserCommandHandler[]
{ {
new TypeUserCommandHandler<CopyCommand>(Copy), new TypeUserCommandHandler<CopyCommand>(Copy),
new TypeUserCommandHandler<DeleteCommand>(Delete),
new TypeUserCommandHandler<MarkCommand>(MarkItem), new TypeUserCommandHandler<MarkCommand>(MarkItem),
new TypeUserCommandHandler<PasteCommand>(Paste), new TypeUserCommandHandler<PasteCommand>(Paste),
new TypeUserCommandHandler<CreateContainer>(CreateContainer), new TypeUserCommandHandler<CreateContainer>(CreateContainer),
@@ -143,7 +147,7 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
_clipboardService.Clear(); _clipboardService.Clear();
if (command is IRequireInputCommand requireInput) await requireInput.ReadInputs(); if (command is IRequireInputCommand requireInput) await requireInput.ReadInputs();
await AddCommand(command); await AddCommand(command);
} }
@@ -181,6 +185,65 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
await AddCommand(command); await AddCommand(command);
} }
private async Task Delete(DeleteCommand command)
{
IList<FullName>? itemsToDelete = null;
var shouldDelete = false;
string? questionText = null;
if ((_markedItems?.Collection?.Count ?? 0) > 0)
{
itemsToDelete = new List<FullName>(_markedItems!.Collection!);
}
else if (_currentSelectedItem?.BaseItem?.FullName is not null)
{
itemsToDelete = new List<FullName>()
{
_currentSelectedItem.BaseItem.FullName
};
}
if ((itemsToDelete?.Count ?? 0) == 0) return;
if (itemsToDelete!.Count == 1)
{
var resolvedOnlyItem = await _timelessContentProvider.GetItemByFullNameAsync(itemsToDelete[0], PointInTime.Present);
if (resolvedOnlyItem is IContainer {AllowRecursiveDeletion: true} onlyContainer
&& await onlyContainer.Items.GetItemsAsync() is { } children
&& children.Any())
{
questionText = $"The container '{onlyContainer.DisplayName}' is not empty. Proceed with delete?";
}
else
{
shouldDelete = true;
}
}
if (itemsToDelete?.Count == 0) return;
if (questionText is { })
{
var proceedDelete = await _userCommunicationService.ShowMessageBox(questionText!);
if (proceedDelete == MessageBoxResult.Cancel) return;
}
else if (!shouldDelete)
{
return;
}
var deleteCommand = new FileTime.Core.Command.Delete.DeleteCommand()
{
HardDelete = command.IsHardDelete
};
deleteCommand.ItemsToDelete.AddRange(itemsToDelete!);
await AddCommand(deleteCommand);
_selectedTab?.ClearMarkedItems();
}
private async Task AddCommand(ICommand command) private async Task AddCommand(ICommand command)
{ {
await _commandScheduler.AddCommand(command); await _commandScheduler.AddCommand(command);

View File

@@ -16,6 +16,8 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler
AddUserCommand(CopyNativePathCommand.Instance); AddUserCommand(CopyNativePathCommand.Instance);
AddUserCommand(CreateContainer.Instance); AddUserCommand(CreateContainer.Instance);
AddUserCommand(CreateElement.Instance); AddUserCommand(CreateElement.Instance);
AddUserCommand(DeleteCommand.HardDelete);
AddUserCommand(DeleteCommand.SoftDelete);
AddUserCommand(EnterRapidTravelCommand.Instance); AddUserCommand(EnterRapidTravelCommand.Instance);
AddUserCommand(ExitRapidTravelCommand.Instance); AddUserCommand(ExitRapidTravelCommand.Instance);
AddUserCommand(GoToHomeCommand.Instance); AddUserCommand(GoToHomeCommand.Instance);

View File

@@ -4,4 +4,5 @@ public interface IUserCommunicationService
{ {
Task<bool> ReadInputs(params IInputElement[] fields); Task<bool> ReadInputs(params IInputElement[] fields);
void ShowToastMessage(string text); void ShowToastMessage(string text);
Task<MessageBoxResult> ShowMessageBox(string text);
} }

View File

@@ -0,0 +1,7 @@
namespace FileTime.Core.Interactions;
public enum MessageBoxResult
{
Ok,
Cancel
}

View File

@@ -6,4 +6,5 @@ public interface IContainer : IItem
{ {
IObservable<IObservable<IChangeSet<AbsolutePath, string>>?> Items { get; } IObservable<IObservable<IChangeSet<AbsolutePath, string>>?> Items { get; }
IObservable<bool> IsLoading { get; } IObservable<bool> IsLoading { get; }
bool AllowRecursiveDeletion { get; }
} }

View File

@@ -0,0 +1,25 @@
using FileTime.Core.Models;
using FileTime.Core.Timeline;
namespace FileTime.Core.Command.Delete;
public class DeleteCommand : IExecutableCommand
{
public bool HardDelete { get; init; }
public List<FullName> ItemsToDelete { get; } = new List<FullName>();
public Task<CanCommandRun> CanRun(PointInTime currentTime)
{
throw new NotImplementedException();
}
public Task<PointInTime> SimulateCommand(PointInTime currentTime)
{
throw new NotImplementedException();
}
public Task Execute()
{
throw new NotImplementedException();
}
}

View File

@@ -41,6 +41,7 @@ public abstract class ContentProviderBase : IContentProvider
public string? Attributes => null; public string? Attributes => null;
protected BehaviorSubject<bool> IsLoading { get; } = new(false); protected BehaviorSubject<bool> IsLoading { get; } = new(false);
public bool AllowRecursiveDeletion => false;
IObservable<bool> IContainer.IsLoading => IsLoading.AsObservable(); IObservable<bool> IContainer.IsLoading => IsLoading.AsObservable();

View File

@@ -22,6 +22,7 @@ public record Container(
bool CanRename, bool CanRename,
string? Attributes, string? Attributes,
IContentProvider Provider, IContentProvider Provider,
bool AllowRecursiveDeletion,
PointInTime PointInTime, PointInTime PointInTime,
IObservable<IEnumerable<Exception>> Exceptions, IObservable<IEnumerable<Exception>> Exceptions,
ReadOnlyExtensionCollection Extensions, ReadOnlyExtensionCollection Extensions,

View File

@@ -63,7 +63,7 @@ public static class MainConfiguration
new CommandBindingConfiguration(GoToPathCommand.CommandName, new[] { Key.G, Key.P }), new CommandBindingConfiguration(GoToPathCommand.CommandName, new[] { Key.G, Key.P }),
new CommandBindingConfiguration(GoToProviderCommand.CommandName, new[] { Key.G, Key.T }), new CommandBindingConfiguration(GoToProviderCommand.CommandName, new[] { Key.G, Key.T }),
new CommandBindingConfiguration(GoToRootCommand.CommandName, new[] { Key.G, Key.R }), new CommandBindingConfiguration(GoToRootCommand.CommandName, new[] { Key.G, Key.R }),
//new CommandBindingConfiguration(ConfigCommand.HardDelete, new[] { new KeyConfig(Key.D,shift: true), new KeyConfig(Key.D, shift: true) }), new CommandBindingConfiguration(DeleteCommand.HardDeleteCommandName, new[] { new KeyConfig(Key.D,shift: true), new KeyConfig(Key.D, shift: true) }),
new CommandBindingConfiguration(MarkCommand.CommandName, Key.Space), new CommandBindingConfiguration(MarkCommand.CommandName, Key.Space),
new CommandBindingConfiguration(MoveCursorToLastCommand.CommandName, new KeyConfig(Key.G, shift: true)), new CommandBindingConfiguration(MoveCursorToLastCommand.CommandName, new KeyConfig(Key.G, shift: true)),
new CommandBindingConfiguration(MoveCursorToFirstCommand.CommandName, new[] { Key.G, Key.G }), new CommandBindingConfiguration(MoveCursorToFirstCommand.CommandName, new[] { Key.G, Key.G }),
@@ -82,7 +82,7 @@ public static class MainConfiguration
//new CommandBindingConfiguration(ConfigCommand.RunCommand, new KeyConfig(Key.D4, shift: true)), //new CommandBindingConfiguration(ConfigCommand.RunCommand, new KeyConfig(Key.D4, shift: true)),
//new CommandBindingConfiguration(ConfigCommand.ScanContainerSize, new[] { Key.C, Key.S }), //new CommandBindingConfiguration(ConfigCommand.ScanContainerSize, new[] { Key.C, Key.S }),
//new CommandBindingConfiguration(ConfigCommand.ShowAllShortcut, Key.F1), //new CommandBindingConfiguration(ConfigCommand.ShowAllShortcut, Key.F1),
//new CommandBindingConfiguration(ConfigCommand.SoftDelete, new[] { new KeyConfig(Key.D), new KeyConfig(Key.D, shift: true) }), new CommandBindingConfiguration(DeleteCommand.SoftDeleteCommandName, new[] { new KeyConfig(Key.D), new KeyConfig(Key.D, shift: true) }),
new CommandBindingConfiguration(SwitchToTabCommand.SwitchToLastTabCommandName, Key.D9), new CommandBindingConfiguration(SwitchToTabCommand.SwitchToLastTabCommandName, Key.D9),
new CommandBindingConfiguration(SwitchToTabCommand.SwitchToTab1CommandName, Key.D1), new CommandBindingConfiguration(SwitchToTabCommand.SwitchToTab1CommandName, Key.D1),
new CommandBindingConfiguration(SwitchToTabCommand.SwitchToTab2CommandName, Key.D2), new CommandBindingConfiguration(SwitchToTabCommand.SwitchToTab2CommandName, Key.D2),

View File

@@ -1,3 +1,4 @@
using FileTime.App.Core.Models;
using FileTime.Core.Interactions; using FileTime.Core.Interactions;
using FileTime.GuiApp.ViewModels; using FileTime.GuiApp.ViewModels;
@@ -6,5 +7,6 @@ namespace FileTime.GuiApp.Services;
public interface IDialogService : IUserCommunicationService public interface IDialogService : IUserCommunicationService
{ {
IObservable<ReadInputsViewModel?> ReadInput { get; } IObservable<ReadInputsViewModel?> ReadInput { get; }
IObservable<MessageBoxViewModel?> LastMessageBox { get; }
void ReadInputs(IEnumerable<IInputElement> inputs, Action inputHandler, Action? cancelHandler = null); void ReadInputs(IEnumerable<IInputElement> inputs, Action inputHandler, Action? cancelHandler = null);
} }

View File

@@ -10,7 +10,6 @@ public interface IGuiAppState : IAppState
List<KeyConfig> PreviousKeys { get; } List<KeyConfig> PreviousKeys { get; }
bool IsAllShortcutVisible { get; set; } bool IsAllShortcutVisible { get; set; }
bool NoCommandFound { get; set; } bool NoCommandFound { get; set; }
string? MessageBoxText { get; set; }
List<CommandBindingConfiguration> PossibleCommands { get; set; } List<CommandBindingConfiguration> PossibleCommands { get; set; }
BindedCollection<RootDriveInfo, string> RootDriveInfos { get; set; } BindedCollection<RootDriveInfo, string> RootDriveInfos { get; set; }
IReadOnlyList<PlaceInfo> Places { get; set; } IReadOnlyList<PlaceInfo> Places { get; set; }

View File

@@ -0,0 +1,31 @@
using FileTime.App.Core.ViewModels;
using FileTime.Core.Interactions;
using MvvmGen;
namespace FileTime.GuiApp.ViewModels;
[ViewModel]
public partial class MessageBoxViewModel : IModalViewModel
{
private readonly Action<MessageBoxViewModel, MessageBoxResult> _handler;
public string Text { get; }
public string Name => "MessageBoxViewModel";
public MessageBoxViewModel(string text, Action<MessageBoxViewModel, MessageBoxResult> handler)
{
_handler = handler;
Text = text;
}
[Command]
public void Ok()
{
_handler.Invoke(this, MessageBoxResult.Ok);
}
[Command]
public void Cancel()
{
_handler.Invoke(this, MessageBoxResult.Cancel);
}
}

View File

@@ -7,7 +7,7 @@ namespace FileTime.GuiApp.ViewModels;
[ViewModel] [ViewModel]
[Inject(typeof(Action<ReadInputsViewModel>), "_cancel")] [Inject(typeof(Action<ReadInputsViewModel>), "_cancel")]
[Inject(typeof(Action<ReadInputsViewModel>), "_process")] [Inject(typeof(Action<ReadInputsViewModel>), "_process")]
public partial class ReadInputsViewModel : IModalViewModelBase public partial class ReadInputsViewModel : IModalViewModel
{ {
public string Name => "ReadInputs"; public string Name => "ReadInputs";
public List<IInputElement> Inputs { get; set; } public List<IInputElement> Inputs { get; set; }

View File

@@ -14,8 +14,6 @@ public partial class GuiAppState : AppStateBase, IGuiAppState
[Property] private bool _noCommandFound; [Property] private bool _noCommandFound;
[Property] private string? _messageBoxText;
[Property] private List<CommandBindingConfiguration> _possibleCommands = new(); [Property] private List<CommandBindingConfiguration> _possibleCommands = new();
[Property] private BindedCollection<RootDriveInfo, string> _rootDriveInfos = new(); [Property] private BindedCollection<RootDriveInfo, string> _rootDriveInfos = new();

View File

@@ -1,5 +1,6 @@
using System.Reactive.Linq; using System.Reactive.Linq;
using Avalonia.Input; using Avalonia.Input;
using FileTime.App.Core.Models;
using FileTime.App.Core.Services; using FileTime.App.Core.Services;
using FileTime.App.Core.UserCommand; using FileTime.App.Core.UserCommand;
using FileTime.App.Core.ViewModels; using FileTime.App.Core.ViewModels;
@@ -15,6 +16,7 @@ namespace FileTime.GuiApp.Services;
public class DefaultModeKeyInputHandler : IDefaultModeKeyInputHandler public class DefaultModeKeyInputHandler : IDefaultModeKeyInputHandler
{ {
private readonly IGuiAppState _appState; private readonly IGuiAppState _appState;
private readonly IModalService _modalService;
private readonly IKeyboardConfigurationService _keyboardConfigurationService; private readonly IKeyboardConfigurationService _keyboardConfigurationService;
private readonly List<KeyConfig[]> _keysToSkip = new(); private readonly List<KeyConfig[]> _keysToSkip = new();
private ITabViewModel? _selectedTab; private ITabViewModel? _selectedTab;
@@ -22,22 +24,27 @@ public class DefaultModeKeyInputHandler : IDefaultModeKeyInputHandler
private readonly ILogger<DefaultModeKeyInputHandler> _logger; private readonly ILogger<DefaultModeKeyInputHandler> _logger;
private readonly IUserCommandHandlerService _userCommandHandlerService; private readonly IUserCommandHandlerService _userCommandHandlerService;
private readonly IIdentifiableUserCommandService _identifiableUserCommandService; private readonly IIdentifiableUserCommandService _identifiableUserCommandService;
private readonly BindedCollection<IModalViewModel> _openModals;
public DefaultModeKeyInputHandler( public DefaultModeKeyInputHandler(
IGuiAppState appState, IGuiAppState appState,
IModalService modalService,
IKeyboardConfigurationService keyboardConfigurationService, IKeyboardConfigurationService keyboardConfigurationService,
ILogger<DefaultModeKeyInputHandler> logger, ILogger<DefaultModeKeyInputHandler> logger,
IUserCommandHandlerService userCommandHandlerService, IUserCommandHandlerService userCommandHandlerService,
IIdentifiableUserCommandService identifiableUserCommandService) IIdentifiableUserCommandService identifiableUserCommandService)
{ {
_appState = appState; _appState = appState;
_identifiableUserCommandService = identifiableUserCommandService;
_keyboardConfigurationService = keyboardConfigurationService; _keyboardConfigurationService = keyboardConfigurationService;
_logger = logger; _logger = logger;
_modalService = modalService;
_userCommandHandlerService = userCommandHandlerService; _userCommandHandlerService = userCommandHandlerService;
_identifiableUserCommandService = identifiableUserCommandService;
_appState.SelectedTab.Subscribe(t => _selectedTab = t); _appState.SelectedTab.Subscribe(t => _selectedTab = t);
_appState.SelectedTab.Select(t => t == null ? Observable.Return<IContainer?>(null) : t.CurrentLocation!).Switch().Subscribe(l => _currentLocation = l); _appState.SelectedTab.Select(t => t == null ? Observable.Return<IContainer?>(null) : t.CurrentLocation!).Switch().Subscribe(l => _currentLocation = l);
_openModals = new BindedCollection<IModalViewModel>(modalService.OpenModals);
_keysToSkip.Add(new KeyConfig[] { new KeyConfig(Key.Up) }); _keysToSkip.Add(new KeyConfig[] { new KeyConfig(Key.Up) });
_keysToSkip.Add(new KeyConfig[] { new KeyConfig(Key.Down) }); _keysToSkip.Add(new KeyConfig[] { new KeyConfig(Key.Down) });
@@ -59,10 +66,11 @@ public class DefaultModeKeyInputHandler : IDefaultModeKeyInputHandler
if (key == Key.Escape) if (key == Key.Escape)
{ {
var doGeneralReset = false; bool doGeneralReset = _appState.PreviousKeys.Count > 1 || _appState.IsAllShortcutVisible;
if (_appState.PreviousKeys.Count > 1 || _appState.IsAllShortcutVisible || _appState.MessageBoxText != null)
if ((_openModals.Collection?.Count ?? 0) > 0)
{ {
doGeneralReset = true; _modalService.CloseModal(_openModals.Collection!.Last());
} }
/*else if (_currentLocation.Container.CanHandleEscape) /*else if (_currentLocation.Container.CanHandleEscape)
{ {
@@ -90,18 +98,17 @@ public class DefaultModeKeyInputHandler : IDefaultModeKeyInputHandler
{ {
setHandled(true); setHandled(true);
_appState.IsAllShortcutVisible = false; _appState.IsAllShortcutVisible = false;
_appState.MessageBoxText = null;
_appState.PreviousKeys.Clear(); _appState.PreviousKeys.Clear();
_appState.PossibleCommands = new(); _appState.PossibleCommands = new();
} }
} }
else if (key == Key.Enter /*else if (key == Key.Enter
&& _appState.MessageBoxText != null) && _appState.MessageBoxText != null)
{ {
_appState.PreviousKeys.Clear(); _appState.PreviousKeys.Clear();
//_dialogService.ProcessMessageBox(); //_dialogService.ProcessMessageBox();
setHandled(true); setHandled(true);
} }*/
else if (selectedCommandBinding != null) else if (selectedCommandBinding != null)
{ {
setHandled(true); setHandled(true);

View File

@@ -1,6 +1,8 @@
using System.Collections.ObjectModel;
using System.Reactive.Linq; using System.Reactive.Linq;
using Avalonia.Threading; using Avalonia.Threading;
using DynamicData; using DynamicData;
using FileTime.App.Core.Models;
using FileTime.App.Core.Services; using FileTime.App.Core.Services;
using FileTime.Core.Interactions; using FileTime.Core.Interactions;
using FileTime.GuiApp.ViewModels; using FileTime.GuiApp.ViewModels;
@@ -13,6 +15,7 @@ public class DialogService : IDialogService
private readonly IGuiAppState _guiAppState; private readonly IGuiAppState _guiAppState;
public IObservable<ReadInputsViewModel?> ReadInput { get; } public IObservable<ReadInputsViewModel?> ReadInput { get; }
public IObservable<MessageBoxViewModel?> LastMessageBox { get; }
public DialogService(IModalService modalService, IGuiAppState guiAppState) public DialogService(IModalService modalService, IGuiAppState guiAppState)
{ {
@@ -22,10 +25,18 @@ public class DialogService : IDialogService
.OpenModals .OpenModals
.ToCollection() .ToCollection()
.Select(modals => .Select(modals =>
(ReadInputsViewModel?)modals.FirstOrDefault(m => m is ReadInputsViewModel) (ReadInputsViewModel?) modals.FirstOrDefault(m => m is ReadInputsViewModel)
) )
.Publish(null) .Publish(null)
.RefCount(); .RefCount();
LastMessageBox =
modalService
.OpenModals
.Filter(m => m is MessageBoxViewModel)
.Transform(m => (MessageBoxViewModel) m)
.ToCollection()
.Select(m => m.LastOrDefault());
} }
public void ReadInputs(IEnumerable<IInputElement> inputs, Action inputHandler, Action? cancelHandler = null) public void ReadInputs(IEnumerable<IInputElement> inputs, Action inputHandler, Action? cancelHandler = null)
@@ -50,6 +61,18 @@ public class DialogService : IDialogService
}); });
} }
public Task<MessageBoxResult> ShowMessageBox(string text)
{
var taskCompletionSource = new TaskCompletionSource<MessageBoxResult>();
_modalService.OpenModal(new MessageBoxViewModel(text, (vm, result) =>
{
_modalService.CloseModal(vm);
taskCompletionSource.SetResult(result);
}));
return taskCompletionSource.Task;
}
private void HandleReadInputsSuccess(ReadInputsViewModel readInputsViewModel) private void HandleReadInputsSuccess(ReadInputsViewModel readInputsViewModel)
{ {
_modalService.CloseModal(readInputsViewModel); _modalService.CloseModal(readInputsViewModel);
@@ -66,7 +89,7 @@ public class DialogService : IDialogService
{ {
var taskCompletionSource = new TaskCompletionSource<bool>(); var taskCompletionSource = new TaskCompletionSource<bool>();
ReadInputs(fields, () => taskCompletionSource.SetResult(true), () => taskCompletionSource.SetResult(false)); ReadInputs(fields, () => taskCompletionSource.SetResult(true), () => taskCompletionSource.SetResult(false));
return taskCompletionSource.Task; return taskCompletionSource.Task;
} }
} }

View File

@@ -6,15 +6,15 @@ namespace FileTime.GuiApp.Services;
public class ModalService : IModalService public class ModalService : IModalService
{ {
private readonly SourceList<IModalViewModelBase> _openModals = new(); private readonly SourceList<IModalViewModel> _openModals = new();
public IObservable<IChangeSet<IModalViewModelBase>> OpenModals { get; } public IObservable<IChangeSet<IModalViewModel>> OpenModals { get; }
public ModalService() public ModalService()
{ {
OpenModals = _openModals.Connect().StartWithEmpty(); OpenModals = _openModals.Connect().StartWithEmpty();
} }
public void OpenModal(IModalViewModelBase modalToOpen) => _openModals.Add(modalToOpen); public void OpenModal(IModalViewModel modalToOpen) => _openModals.Add(modalToOpen);
public void CloseModal(IModalViewModelBase modalToClose) => _openModals.Remove(modalToClose); public void CloseModal(IModalViewModel modalToClose) => _openModals.Remove(modalToClose);
} }

View File

@@ -22,7 +22,7 @@ public class RapidTravelModeKeyInputHandler : IRapidTravelModeKeyInputHandler
private readonly IUserCommandHandlerService _userCommandHandlerService; private readonly IUserCommandHandlerService _userCommandHandlerService;
private readonly ILogger<RapidTravelModeKeyInputHandler> _logger; private readonly ILogger<RapidTravelModeKeyInputHandler> _logger;
private readonly IIdentifiableUserCommandService _identifiableUserCommandService; private readonly IIdentifiableUserCommandService _identifiableUserCommandService;
private readonly BindedCollection<IModalViewModelBase> _openModals; private readonly BindedCollection<IModalViewModel> _openModals;
private ITabViewModel? _selectedTab; private ITabViewModel? _selectedTab;
public RapidTravelModeKeyInputHandler( public RapidTravelModeKeyInputHandler(
@@ -42,7 +42,7 @@ public class RapidTravelModeKeyInputHandler : IRapidTravelModeKeyInputHandler
_appState.SelectedTab.Subscribe(t => _selectedTab = t); _appState.SelectedTab.Subscribe(t => _selectedTab = t);
_openModals = new BindedCollection<IModalViewModelBase>(modalService.OpenModals); _openModals = new BindedCollection<IModalViewModel>(modalService.OpenModals);
} }
public async Task HandleInputKey(Key key, SpecialKeysStatus specialKeysStatus, Action<bool> setHandled) public async Task HandleInputKey(Key key, SpecialKeysStatus specialKeysStatus, Action<bool> setHandled)

View File

@@ -326,7 +326,8 @@
<Grid <Grid
Grid.Column="2" Grid.Column="2"
RowDefinitions="Auto,*"> RowDefinitions="Auto,*">
<Grid IsVisible="{Binding AppState.SelectedTab^.CurrentLocation^.IsLoading^, FallbackValue=False}"> <Grid
IsVisible="{Binding AppState.SelectedTab^.CurrentLocation^.IsLoading^, FallbackValue=False}">
<Image <Image
Width="40" Width="40"
Height="40" Height="40"
@@ -443,17 +444,19 @@
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Grid>
<ItemsRepeater Items="{Binding AppState.PopupTexts}" Margin="0,0,0,20" HorizontalAlignment="Center" VerticalAlignment="Top" IsVisible="{Binding AppState.PopupTexts.Count,Converter={StaticResource NotEqualsConverter}, ConverterParameter=0}"> <ItemsRepeater Items="{Binding AppState.PopupTexts}" Margin="0,0,0,20"
HorizontalAlignment="Center" VerticalAlignment="Top"
IsVisible="{Binding AppState.PopupTexts.Count,Converter={StaticResource NotEqualsConverter}, ConverterParameter=0}">
<ItemsRepeater.Styles> <ItemsRepeater.Styles>
<Style Selector="TextBlock"> <Style Selector="TextBlock">
<Style.Animations> <Style.Animations>
<Animation Duration="0:0:1"> <Animation Duration="0:0:1">
<KeyFrame Cue="0%"> <KeyFrame Cue="0%">
<Setter Property="Opacity" Value="0.0"/> <Setter Property="Opacity" Value="0.0" />
</KeyFrame> </KeyFrame>
<KeyFrame Cue="100%"> <KeyFrame Cue="100%">
<Setter Property="Opacity" Value="1.0"/> <Setter Property="Opacity" Value="1.0" />
</KeyFrame> </KeyFrame>
</Animation> </Animation>
</Style.Animations> </Style.Animations>
@@ -461,8 +464,11 @@
</ItemsRepeater.Styles> </ItemsRepeater.Styles>
<ItemsRepeater.ItemTemplate> <ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="x:String"> <DataTemplate x:DataType="x:String">
<Border Background="{DynamicResource ContainerGradientBackgroundBrush}" Margin="5" Padding="5"> <Border Background="{DynamicResource ContainerGradientBackgroundBrush}" Margin="5"
<TextBlock Text="{Binding}" Foreground="{DynamicResource AccentComplementBrush}" HorizontalAlignment="Center"/> Padding="5">
<TextBlock Text="{Binding}"
Foreground="{DynamicResource AccentComplementBrush}"
HorizontalAlignment="Center" />
</Border> </Border>
</DataTemplate> </DataTemplate>
</ItemsRepeater.ItemTemplate> </ItemsRepeater.ItemTemplate>
@@ -599,6 +605,38 @@
</Border> </Border>
</Border> </Border>
<Border
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
IsVisible="{Binding DialogService.LastMessageBox^, Converter={x:Static ObjectConverters.IsNotNull}, FallbackValue=False}">
<Border
Background="{DynamicResource ContainerBackgroundBrush}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Padding="20">
<Grid RowDefinitions="Auto,Auto">
<TextBlock Text="{Binding DialogService.LastMessageBox^.Text}"/>
<StackPanel
Grid.Row="1"
Orientation="Horizontal"
Margin="0,10,0,0">
<Button
HorizontalContentAlignment="Center"
Width="80"
Command="{Binding DialogService.LastMessageBox^.OkCommand}"
Content="Yes" />
<Button
HorizontalContentAlignment="Center"
Width="80"
Margin="10,0,0,0"
Command="{Binding DialogService.LastMessageBox^.CancelCommand}"
Content="No" />
</StackPanel>
</Grid>
</Border>
</Border>
</Grid> </Grid>
<Grid IsVisible="{Binding Loading}"> <Grid IsVisible="{Binding Loading}">

View File

@@ -16,7 +16,7 @@ public partial class MainWindow : Window
{ {
private readonly ILogger<MainWindow>? _logger; private readonly ILogger<MainWindow>? _logger;
private readonly IModalService _modalService; private readonly IModalService _modalService;
private IReadOnlyCollection<IModalViewModelBase>? _openModals; private IReadOnlyCollection<IModalViewModel>? _openModals;
public MainWindowViewModel? ViewModel public MainWindowViewModel? ViewModel
{ {

View File

@@ -161,6 +161,7 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
false, false,
"???", "???",
this, this,
true,
pointInTime, pointInTime,
nonNullExceptions, nonNullExceptions,
new ExtensionCollection().AsReadOnly(), new ExtensionCollection().AsReadOnly(),
@@ -227,6 +228,7 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
true, true,
GetDirectoryAttributes(directoryInfo), GetDirectoryAttributes(directoryInfo),
this, this,
true,
pointInTime, pointInTime,
exceptions, exceptions,
new ExtensionCollection().AsReadOnly(), new ExtensionCollection().AsReadOnly(),