Profile editor - Added back hotkeys for the tools

Profile editor - Fixed hotkeys not always working
This commit is contained in:
Robert committed 2023-10-07 20:12:35 +02:00
1 parent f985682e78
commit 543b62a715
16 files changed
+106 -38

No files matched your search

@@ -1,4 +1,5 @@
using Artemis.Core.Services;
using System;
using Artemis.Core.Services;
using Artemis.Storage.Entities.Profile;
namespace Artemis.Core;
@@ -16,6 +17,14 @@ public class Hotkey : CorePropertyChanged, IStorageModel
Entity = new ProfileConfigurationHotkeyEntity();
}
/// <inheritdoc />
public Hotkey(KeyboardKey? key, KeyboardModifierKey? modifiers)
{
Key = key;
Modifiers = modifiers;
Entity = new ProfileConfigurationHotkeyEntity();
}
/// <summary>
/// Creates a new instance of <see cref="Hotkey" /> based on the provided entity
/// </summary>
@@ -46,7 +55,7 @@ public class Hotkey : CorePropertyChanged, IStorageModel
/// <returns><see langword="true" /> if the event args match the hotkey; otherwise <see langword="false" /></returns>
public bool MatchesEventArgs(ArtemisKeyboardKeyEventArgs eventArgs)
{
return eventArgs.Key == Key && eventArgs.Modifiers == Modifiers;
return eventArgs.Key == Key && (eventArgs.Modifiers == Modifiers || (eventArgs.Modifiers == KeyboardModifierKey.None && Modifiers == null));
}
#region Implementation of IStorageModel
@@ -34,4 +34,13 @@ public class ArtemisKeyboardKeyEventArgs : EventArgs
/// Gets the modifiers that are pressed
/// </summary>
public KeyboardModifierKey Modifiers { get; }
/// <summary>
/// Creates a hotkey matching the event.
/// </summary>
/// <returns>The resulting hotkey.</returns>
public Hotkey ToHotkey()
{
return new Hotkey {Key = Key, Modifiers = Modifiers};
}
}