Skip to content

Commit

Permalink
improve ActionName property handling
Browse files Browse the repository at this point in the history
  • Loading branch information
radj307 committed Jun 7, 2022
1 parent c4e2542 commit 58d4ae3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions VolumeControl.Hotkeys/BindableWindowsHotkey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using VolumeControl.Hotkeys.Interfaces;
using VolumeControl.Log;

namespace VolumeControl.Hotkeys
{
Expand Down Expand Up @@ -58,13 +59,16 @@ public bool Registered
/// Gets or sets the name of the action associated with this hotkey.
/// </summary>
/// <remarks>This property automatically handles changing the <see cref="Pressed"/> event.</remarks>
public string ActionName
public string? ActionName
{
get => Action?.Name ?? string.Empty;
get => Action?.Name;
set
{
NotifyPropertyChanging();
Action = _manager.Actions[value];
if (value == null)
Action = null;
else
Action = _manager.Actions[value];
NotifyPropertyChanged();
}
}
Expand All @@ -81,6 +85,7 @@ public IActionBinding? Action
if (_action != null)
Pressed -= _action.HandleKeyEvent;
_action = value;
FLog.Log.Debug($"Hotkey '{ID}' action was changed to '{ActionName}'");
if (_action != null)
Pressed += _action.HandleKeyEvent;
NotifyPropertyChanging();
Expand Down

0 comments on commit 58d4ae3

Please sign in to comment.