using System; using System.Collections; using System.Collections.Generic; namespace BITKit.UX.Hotkey { public interface IHotkeyProvider { string Name { get; } string Description { get; } object Data { get; } bool Enabled { get; } Action OnPerform { get; } float HoldDuration => 0; } public struct HotkeyProvider : IHotkeyProvider { public string Name { get; set; } public string Description { get; set; } public object Data { get; set; } public bool Enabled { get; set; } public Action OnPerform { get; set; } public float HoldDuration { get; set; } } public interface IHotkeyCollection { IEnumerable Hotkeys { get; } void Register(IHotkeyProvider hotkey); void UnRegister(IHotkeyProvider hotkey); } public class HotkeyCollection:IHotkeyCollection { private readonly HashSet _hotkeys = new(); public IEnumerable Hotkeys => _hotkeys; public void Register(IHotkeyProvider hotkey) { _hotkeys.Add(hotkey); } public void UnRegister(IHotkeyProvider hotkey) { _hotkeys.Remove(hotkey); } } }