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,18 +1,47 @@
using Avalonia.Input;
using FileTime.App.Core.Models;
using FileTime.App.Core.Services;
using GeneralInputKey;
namespace FileTime.GuiApp.App.Extensions;
public static class KeyEventArgsExtension
{
public static GeneralKeyEventArgs? ToGeneralKeyEventArgs(this KeyEventArgs args, IAppKeyService<Key> appKeyService)
public static GeneralKeyEventArgs? ToGeneralKeyEventArgs(
this KeyEventArgs args,
IAppKeyService<Key> appKeyService,
SpecialKeysStatus specialKeysStatus)
{
var maybeKey = appKeyService.MapKey(args.Key);
if (maybeKey is not {} key1) return null;
if (maybeKey is not { } key1) return null;
var keyString = args.Key.ToString();
return new GeneralKeyEventArgs(h => args.Handled = h)
{
Key = key1
Key = key1,
KeyChar = keyString.Length > 0 ? keyString[0] : '\0',
SpecialKeysStatus = specialKeysStatus
};
}
public static GeneralKeyEventArgs? ToGeneralKeyEventArgs(
this KeyEventArgs args,
IAppKeyService<Key> appKeyService,
KeyModifiers keyModifiers)
{
var maybeKey = appKeyService.MapKey(args.Key);
if (maybeKey is not { } key1) return null;
var keyString = args.Key.ToString();
return new GeneralKeyEventArgs(h => args.Handled = h)
{
Key = key1,
KeyChar = keyString.Length > 0 ? keyString[0] : '\0',
SpecialKeysStatus = new SpecialKeysStatus(
IsAltPressed: (keyModifiers & KeyModifiers.Alt) != 0,
IsShiftPressed: (keyModifiers & KeyModifiers.Shift) != 0,
IsCtrlPressed: (keyModifiers & KeyModifiers.Control) != 0
)
};
}
}