TextBox, PropertyChangeHandler

This commit is contained in:
2023-08-11 21:51:44 +02:00
parent e989a65e81
commit 1fde0df2d6
81 changed files with 1539 additions and 390 deletions

View File

@@ -1,3 +1,4 @@
using DeclarativeProperty;
using FileTime.App.CommandPalette.Models;
using FileTime.App.CommandPalette.ViewModels;
@@ -5,7 +6,7 @@ namespace FileTime.App.CommandPalette.Services;
public interface ICommandPaletteService
{
IObservable<bool> ShowWindow { get; }
IDeclarativeProperty<bool> ShowWindow { get; }
void OpenCommandPalette();
void CloseCommandPalette();
IReadOnlyList<ICommandPaletteEntry> GetCommands();

View File

@@ -1,12 +1,14 @@
using FileTime.App.Core.Models;
using DeclarativeProperty;
using FileTime.App.Core.Models;
using FileTime.App.Core.ViewModels;
using FileTime.App.FuzzyPanel;
using GeneralInputKey;
namespace FileTime.App.CommandPalette.ViewModels;
public interface ICommandPaletteViewModel : IFuzzyPanelViewModel<ICommandPaletteEntryViewModel>, IModalViewModel
{
IObservable<bool> ShowWindow { get; }
IDeclarativeProperty<bool> ShowWindow { get; }
void Close();
Task<bool> HandleKeyUp(GeneralKeyEventArgs keyEventArgs);
}

View File

@@ -1,5 +1,4 @@
using System.Reactive.Linq;
using System.Reactive.Subjects;
using DeclarativeProperty;
using FileTime.App.CommandPalette.Models;
using FileTime.App.CommandPalette.ViewModels;
using FileTime.App.Core.Services;
@@ -11,8 +10,8 @@ public partial class CommandPaletteService : ICommandPaletteService
{
private readonly IModalService _modalService;
private readonly IIdentifiableUserCommandService _identifiableUserCommandService;
private readonly BehaviorSubject<bool> _showWindow = new(false);
IObservable<bool> ICommandPaletteService.ShowWindow => _showWindow.AsObservable();
private readonly DeclarativeProperty<bool> _showWindow = new(false);
IDeclarativeProperty<bool> ICommandPaletteService.ShowWindow => _showWindow;
[Notify] ICommandPaletteViewModel? _currentModal;
public CommandPaletteService(
@@ -24,13 +23,13 @@ public partial class CommandPaletteService : ICommandPaletteService
}
public void OpenCommandPalette()
{
_showWindow.OnNext(true);
_showWindow.SetValueSafe(true);
CurrentModal = _modalService.OpenModal<ICommandPaletteViewModel>();
}
public void CloseCommandPalette()
{
_showWindow.OnNext(false);
_showWindow.SetValueSafe(false);
if (_currentModal is not null)
{
_modalService.CloseModal(_currentModal);

View File

@@ -1,10 +1,9 @@
using System.Text;
using FileTime.App.CommandPalette.Services;
using FileTime.App.Core.Configuration;
using FileTime.App.CommandPalette.Services;
using FileTime.App.Core.Models;
using FileTime.App.Core.Services;
using FileTime.App.Core.ViewModels;
using FileTime.App.FuzzyPanel;
using GeneralInputKey;
using Microsoft.Extensions.Logging;
namespace FileTime.App.CommandPalette.ViewModels;

View File

@@ -1,4 +1,5 @@
using FileTime.App.Core.Models;
using GeneralInputKey;
namespace FileTime.App.Core.Configuration;

View File

@@ -1,4 +1,5 @@
using FileTime.App.Core.Models;
using GeneralInputKey;
namespace FileTime.App.Core.Configuration;

View File

@@ -22,6 +22,7 @@
<ItemGroup>
<ProjectReference Include="..\..\Core\FileTime.Core.Abstraction\FileTime.Core.Abstraction.csproj" />
<ProjectReference Include="..\..\Library\GeneralInputKey\GeneralInputKey.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,26 +0,0 @@
namespace FileTime.App.Core.Models;
public class GeneralKeyEventArgs
{
private readonly Action<bool>? _handledChanged;
private bool _handled;
public required Keys Key { get; init; }
public bool Handled
{
get => _handled;
set
{
if (_handled != value)
{
_handled = value;
_handledChanged?.Invoke(value);
}
}
}
public GeneralKeyEventArgs(Action<bool>? handledChanged = null)
{
_handledChanged = handledChanged;
}
}

View File

@@ -1,80 +0,0 @@
using System.ComponentModel;
namespace FileTime.App.Core.Models;
public enum Keys
{
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
Q,
R,
S,
T,
U,
V,
W,
X,
Y,
Z,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
Up,
Down,
Left,
Right,
Enter,
Escape,
Backspace,
Space,
PageUp,
PageDown,
Comma,
Question,
Tab,
LWin,
RWin,
[Description("0")]
Num0,
[Description("1")]
Num1,
[Description("2")]
Num2,
[Description("3")]
Num3,
[Description("4")]
Num4,
[Description("5")]
Num5,
[Description("6")]
Num6,
[Description("7")]
Num7,
[Description("8")]
Num8,
[Description("9")]
Num9,
}

View File

@@ -1,3 +0,0 @@
namespace FileTime.App.Core.Models;
public record struct SpecialKeysStatus(bool IsAltPressed, bool IsShiftPressed, bool IsCtrlPressed);

View File

@@ -1,4 +1,5 @@
using FileTime.App.Core.Models;
using GeneralInputKey;
namespace FileTime.App.Core.Services;

View File

@@ -1,8 +1,9 @@
using FileTime.App.Core.Models;
using GeneralInputKey;
namespace FileTime.App.Core.Services;
public interface IKeyInputHandler
{
Task HandleInputKey(GeneralKeyEventArgs e, SpecialKeysStatus specialKeysStatus);
Task HandleInputKey(GeneralKeyEventArgs e);
}

View File

@@ -1,6 +1,7 @@
using FileTime.App.Core.Models;
using FileTime.App.Core.UserCommand;
using FileTime.Providers.LocalAdmin;
using GeneralInputKey;
namespace FileTime.App.Core.Configuration;

View File

@@ -7,6 +7,7 @@ using FileTime.App.Core.ViewModels;
using FileTime.Core.Extensions;
using FileTime.Core.Models;
using FileTime.Core.Models.Extensions;
using GeneralInputKey;
using Microsoft.Extensions.Logging;
namespace FileTime.App.Core.Services;
@@ -57,9 +58,14 @@ public class DefaultModeKeyInputHandler : IDefaultModeKeyInputHandler
_keysToSkip.Add(new[] {new KeyConfig(Keys.RWin)});
}
public async Task HandleInputKey(GeneralKeyEventArgs args, SpecialKeysStatus specialKeysStatus)
public async Task HandleInputKey(GeneralKeyEventArgs args)
{
var keyWithModifiers = new KeyConfig(args.Key, shift: specialKeysStatus.IsShiftPressed, alt: specialKeysStatus.IsAltPressed, ctrl: specialKeysStatus.IsCtrlPressed);
var keyWithModifiers = new KeyConfig(
args.Key,
shift: args.SpecialKeysStatus.IsShiftPressed,
alt: args.SpecialKeysStatus.IsAltPressed,
ctrl: args.SpecialKeysStatus.IsCtrlPressed);
_appState.PreviousKeys.Add(keyWithModifiers);
var selectedCommandBinding = _keyboardConfigurationService.UniversalCommandBindings.FirstOrDefault(c => c.Keys.AreKeysEqual(_appState.PreviousKeys));

View File

@@ -5,6 +5,7 @@ using FileTime.App.Core.UserCommand;
using FileTime.App.Core.ViewModels;
using FileTime.Core.Extensions;
using FileTime.Core.Models;
using GeneralInputKey;
using Humanizer;
using Microsoft.Extensions.Logging;
@@ -54,7 +55,7 @@ public class RapidTravelModeKeyInputHandler : IRapidTravelModeKeyInputHandler
});
}
public async Task HandleInputKey(GeneralKeyEventArgs args, SpecialKeysStatus specialKeysStatus)
public async Task HandleInputKey(GeneralKeyEventArgs args)
{
var keyString = args.Key.Humanize();

View File

@@ -140,10 +140,9 @@ public class NavigationUserCommandHandlerService : UserCommandHandlerServiceBase
return Task.CompletedTask;
}
private Task GoByFrequency()
private async Task GoByFrequency()
{
_frequencyNavigationService.OpenNavigationWindow();
return Task.CompletedTask;
await _frequencyNavigationService.OpenNavigationWindow();
}
private async Task GoToPath()

View File

@@ -1,12 +1,13 @@
using DeclarativeProperty;
using FileTime.App.FrequencyNavigation.ViewModels;
namespace FileTime.App.FrequencyNavigation.Services;
public interface IFrequencyNavigationService
{
IObservable<bool> ShowWindow { get; }
IDeclarativeProperty<bool> ShowWindow { get; }
IFrequencyNavigationViewModel? CurrentModal { get; }
void OpenNavigationWindow();
Task OpenNavigationWindow();
void CloseNavigationWindow();
IList<string> GetMatchingContainers(string searchText);
}

View File

@@ -1,12 +1,14 @@
using DeclarativeProperty;
using FileTime.App.Core.Models;
using FileTime.App.Core.ViewModels;
using FileTime.App.FuzzyPanel;
using GeneralInputKey;
namespace FileTime.App.FrequencyNavigation.ViewModels;
public interface IFrequencyNavigationViewModel : IFuzzyPanelViewModel<string>, IModalViewModel
{
IObservable<bool> ShowWindow { get; }
IDeclarativeProperty<bool> ShowWindow { get; }
void Close();
Task<bool> HandleKeyUp(GeneralKeyEventArgs keyEventArgs);
}

View File

@@ -1,6 +1,7 @@
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Text.Json;
using DeclarativeProperty;
using FileTime.App.Core.Models;
using FileTime.App.Core.Services;
using FileTime.App.FrequencyNavigation.Models;
@@ -22,10 +23,10 @@ public partial class FrequencyNavigationService : IFrequencyNavigationService, I
private readonly IModalService _modalService;
private readonly SemaphoreSlim _saveLock = new(1, 1);
private Dictionary<string, ContainerFrequencyData> _containerScores = new();
private readonly BehaviorSubject<bool> _showWindow = new(false);
private readonly DeclarativeProperty<bool> _showWindow = new(false);
private readonly string _dbPath;
[Notify] IFrequencyNavigationViewModel? _currentModal;
IObservable<bool> IFrequencyNavigationService.ShowWindow => _showWindow.AsObservable();
IDeclarativeProperty<bool> IFrequencyNavigationService.ShowWindow => _showWindow;
public FrequencyNavigationService(
ITabEvents tabEvents,
@@ -51,15 +52,15 @@ public partial class FrequencyNavigationService : IFrequencyNavigationService, I
}
}
public void OpenNavigationWindow()
public async Task OpenNavigationWindow()
{
_showWindow.OnNext(true);
await _showWindow.SetValue(true);
CurrentModal = _modalService.OpenModal<IFrequencyNavigationViewModel>();
}
public void CloseNavigationWindow()
{
_showWindow.OnNext(false);
_showWindow.SetValueSafe(false);
if (_currentModal is not null)
{
_modalService.CloseModal(_currentModal);

View File

@@ -6,6 +6,7 @@ using FileTime.App.FrequencyNavigation.Services;
using FileTime.App.FuzzyPanel;
using FileTime.Core.Models;
using FileTime.Core.Timeline;
using GeneralInputKey;
namespace FileTime.App.FrequencyNavigation.ViewModels;

View File

@@ -1,4 +1,5 @@
using FileTime.App.Core.Models;
using GeneralInputKey;
namespace FileTime.App.FuzzyPanel;

View File

@@ -1,5 +1,7 @@
using System.ComponentModel;
using DeclarativeProperty;
using FileTime.App.Core.Models;
using GeneralInputKey;
using PropertyChanged.SourceGenerator;
namespace FileTime.App.FuzzyPanel;
@@ -9,7 +11,7 @@ public abstract partial class FuzzyPanelViewModel<TItem> : IFuzzyPanelViewModel<
private readonly Func<TItem, TItem, bool> _itemEquality;
private string _searchText = String.Empty;
[Notify(set: Setter.Protected)] private IObservable<bool> _showWindow;
[Notify(set: Setter.Protected)] private IDeclarativeProperty<bool> _showWindow;
[Notify(set: Setter.Protected)] private List<TItem> _filteredMatches;
[Notify(set: Setter.Protected)] private TItem? _selectedItem;