diff --git a/demo/Ursa.Demo/Models/MenuKeys.cs b/demo/Ursa.Demo/Models/MenuKeys.cs
index 5a76eb9..3717625 100644
--- a/demo/Ursa.Demo/Models/MenuKeys.cs
+++ b/demo/Ursa.Demo/Models/MenuKeys.cs
@@ -7,9 +7,11 @@ public static class MenuKeys
public const string MenuKeyButtonGroup = "ButtonGroup";
public const string MenuKeyDivider = "Divider";
public const string MenuKeyIpBox = "IPv4Box";
+ public const string MenuKeyKeyGestureInput = "KeyGestureInput";
public const string MenuKeyLoading = "Loading";
public const string MenuKeyNavigation = "Navigation";
public const string MenuKeyPagination = "Pagination";
public const string MenuKeyTagInput = "TagInput";
public const string MenuKeyTimeline = "Timeline";
+
}
\ No newline at end of file
diff --git a/demo/Ursa.Demo/Pages/KeyGestureInputDemo.axaml b/demo/Ursa.Demo/Pages/KeyGestureInputDemo.axaml
new file mode 100644
index 0000000..e84ba5e
--- /dev/null
+++ b/demo/Ursa.Demo/Pages/KeyGestureInputDemo.axaml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
diff --git a/demo/Ursa.Demo/Pages/KeyGestureInputDemo.axaml.cs b/demo/Ursa.Demo/Pages/KeyGestureInputDemo.axaml.cs
new file mode 100644
index 0000000..f213756
--- /dev/null
+++ b/demo/Ursa.Demo/Pages/KeyGestureInputDemo.axaml.cs
@@ -0,0 +1,18 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace Ursa.Demo.Pages;
+
+public partial class KeyGestureInputDemo : UserControl
+{
+ public KeyGestureInputDemo()
+ {
+ InitializeComponent();
+ }
+
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+}
\ No newline at end of file
diff --git a/demo/Ursa.Demo/Ursa.Demo.csproj b/demo/Ursa.Demo/Ursa.Demo.csproj
index 4f0188d..d11b6e7 100644
--- a/demo/Ursa.Demo/Ursa.Demo.csproj
+++ b/demo/Ursa.Demo/Ursa.Demo.csproj
@@ -7,23 +7,23 @@
-
+
-
+
-
+
-
-
-
+
+
+
-
-
+
+
diff --git a/demo/Ursa.Demo/ViewModels/KeyGestureInputDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/KeyGestureInputDemoViewModel.cs
new file mode 100644
index 0000000..4a89729
--- /dev/null
+++ b/demo/Ursa.Demo/ViewModels/KeyGestureInputDemoViewModel.cs
@@ -0,0 +1,8 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+
+namespace Ursa.Demo.ViewModels;
+
+public class KeyGestureInputDemoViewModel: ObservableObject
+{
+
+}
\ No newline at end of file
diff --git a/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs b/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs
index 6641f1f..919e6db 100644
--- a/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs
+++ b/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs
@@ -29,6 +29,7 @@ public class MainViewViewModel : ViewModelBase
MenuKeys.MenuKeyButtonGroup => new ButtonGroupDemoViewModel(),
MenuKeys.MenuKeyDivider => new DividerDemoViewModel(),
MenuKeys.MenuKeyIpBox => new IPv4BoxDemoViewModel(),
+ MenuKeys.MenuKeyKeyGestureInput => new KeyGestureInputDemoViewModel(),
MenuKeys.MenuKeyLoading => new LoadingDemoViewModel(),
MenuKeys.MenuKeyNavigation => new NavigationMenuDemoViewModel(),
MenuKeys.MenuKeyPagination => new PaginationDemoViewModel(),
diff --git a/demo/Ursa.Demo/ViewModels/MenuViewModel.cs b/demo/Ursa.Demo/ViewModels/MenuViewModel.cs
index 9351ad9..315c31c 100644
--- a/demo/Ursa.Demo/ViewModels/MenuViewModel.cs
+++ b/demo/Ursa.Demo/ViewModels/MenuViewModel.cs
@@ -16,6 +16,7 @@ public class MenuViewModel: ViewModelBase
new() { MenuHeader = "ButtonGroup", Key = MenuKeys.MenuKeyButtonGroup },
new() { MenuHeader = "Divider", Key = MenuKeys.MenuKeyDivider },
new() { MenuHeader = "IPv4Box", Key = MenuKeys.MenuKeyIpBox },
+ new() { MenuHeader = "KeyGestureInput", Key = MenuKeys.MenuKeyKeyGestureInput },
new() { MenuHeader = "Loading", Key = MenuKeys.MenuKeyLoading },
new() { MenuHeader = "Navigation", Key = MenuKeys.MenuKeyNavigation },
new() { MenuHeader = "Pagination", Key = MenuKeys.MenuKeyPagination },
diff --git a/src/Ursa.Themes.Semi/Controls/KeyGestureInput.axaml b/src/Ursa.Themes.Semi/Controls/KeyGestureInput.axaml
index 7a72b5d..56aab72 100644
--- a/src/Ursa.Themes.Semi/Controls/KeyGestureInput.axaml
+++ b/src/Ursa.Themes.Semi/Controls/KeyGestureInput.axaml
@@ -7,20 +7,40 @@
+
+
+
-
+ HorizontalAlignment="Stretch"
+ VerticalAlignment="Stretch"
+ Background="{DynamicResource KeyGestureInputBackground}"
+ BorderBrush="Transparent"
+ BorderThickness="1"
+ CornerRadius="{TemplateBinding CornerRadius}">
+
+
+
+
diff --git a/src/Ursa.Themes.Semi/Themes/Dark/KeyGestureInput.axaml b/src/Ursa.Themes.Semi/Themes/Dark/KeyGestureInput.axaml
new file mode 100644
index 0000000..ed7c331
--- /dev/null
+++ b/src/Ursa.Themes.Semi/Themes/Dark/KeyGestureInput.axaml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml b/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml
index c9f2bea..340a2ba 100644
--- a/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml
+++ b/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml
@@ -6,6 +6,7 @@
+
diff --git a/src/Ursa.Themes.Semi/Themes/Light/KeyGestureInput.axaml b/src/Ursa.Themes.Semi/Themes/Light/KeyGestureInput.axaml
new file mode 100644
index 0000000..490e1a4
--- /dev/null
+++ b/src/Ursa.Themes.Semi/Themes/Light/KeyGestureInput.axaml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/Ursa.Themes.Semi/Themes/Light/_index.axaml b/src/Ursa.Themes.Semi/Themes/Light/_index.axaml
index c9f2bea..340a2ba 100644
--- a/src/Ursa.Themes.Semi/Themes/Light/_index.axaml
+++ b/src/Ursa.Themes.Semi/Themes/Light/_index.axaml
@@ -6,6 +6,7 @@
+
diff --git a/src/Ursa.Themes.Semi/Themes/Shared/KeyGestureInput.axaml b/src/Ursa.Themes.Semi/Themes/Shared/KeyGestureInput.axaml
new file mode 100644
index 0000000..ee22a40
--- /dev/null
+++ b/src/Ursa.Themes.Semi/Themes/Shared/KeyGestureInput.axaml
@@ -0,0 +1,6 @@
+
+
+ 80
+ 32
+ 3
+
diff --git a/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml b/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml
index 777a0a4..7be0bef 100644
--- a/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml
+++ b/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml
@@ -6,6 +6,7 @@
+
diff --git a/src/Ursa/Controls/KeyGestureInput.cs b/src/Ursa/Controls/KeyGestureInput.cs
index af43eb3..38dd28c 100644
--- a/src/Ursa/Controls/KeyGestureInput.cs
+++ b/src/Ursa/Controls/KeyGestureInput.cs
@@ -3,6 +3,7 @@ using Avalonia.Controls;
using Avalonia.Controls.Converters;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
+using Avalonia.Layout;
namespace Ursa.Controls;
@@ -22,17 +23,17 @@ public class KeyGestureInput: TemplatedControl
set => SetValue(GestureProperty, value);
}
- public static readonly StyledProperty> AcceptableKeysProperty = AvaloniaProperty.Register>(
+ public static readonly StyledProperty?> AcceptableKeysProperty = AvaloniaProperty.Register?>(
nameof(AcceptableKeys));
- public IList AcceptableKeys
+ public IList? AcceptableKeys
{
get => GetValue(AcceptableKeysProperty);
set => SetValue(AcceptableKeysProperty, value);
}
public static readonly StyledProperty ConsiderKeyModifiersProperty = AvaloniaProperty.Register(
- nameof(ConsiderKeyModifiers));
+ nameof(ConsiderKeyModifiers), true);
public bool ConsiderKeyModifiers
{
@@ -40,10 +41,31 @@ public class KeyGestureInput: TemplatedControl
set => SetValue(ConsiderKeyModifiersProperty, value);
}
+ public static readonly StyledProperty HorizontalContentAlignmentProperty =
+ ContentControl.HorizontalContentAlignmentProperty.AddOwner(
+ new StyledPropertyMetadata(HorizontalAlignment.Center));
+
+ public HorizontalAlignment HorizontalContentAlignment
+ {
+ get => GetValue(HorizontalContentAlignmentProperty);
+ set => SetValue(HorizontalContentAlignmentProperty, value);
+ }
+
+ public static readonly StyledProperty VerticalContentAlignmentProperty =
+ ContentControl.VerticalContentAlignmentProperty.AddOwner(
+ new StyledPropertyMetadata(VerticalAlignment.Center));
+
+ public VerticalAlignment VerticalContentAlignment
+ {
+ get => GetValue(VerticalContentAlignmentProperty);
+ set => SetValue(VerticalContentAlignmentProperty, value);
+ }
+
+
protected override void OnKeyDown(KeyEventArgs e)
{
// base.OnKeyDown(e);
- if (!AcceptableKeys.Contains(e.Key))
+ if (AcceptableKeys is not null && !AcceptableKeys.Contains(e.Key))
{
return;
}