using System; using System.Collections.Generic; using System.Threading.Tasks; using System.Windows.Input; namespace ThreadPilot.Services { /// /// Service for managing global keyboard shortcuts /// public interface IKeyboardShortcutService { /// /// Event raised when a registered shortcut is activated /// event EventHandler? ShortcutActivated; /// /// Register a global keyboard shortcut /// Task RegisterShortcutAsync(string actionName, Key key, ModifierKeys modifiers); /// /// Unregister a keyboard shortcut /// Task UnregisterShortcutAsync(string actionName); /// /// Update an existing shortcut with new key combination /// Task UpdateShortcutAsync(string actionName, Key key, ModifierKeys modifiers); /// /// Get all registered shortcuts /// Task> GetRegisteredShortcutsAsync(); /// /// Check if a key combination is already registered /// Task IsShortcutRegisteredAsync(Key key, ModifierKeys modifiers); /// /// Load shortcuts from settings /// Task LoadShortcutsFromSettingsAsync(); /// /// Save shortcuts to settings /// Task SaveShortcutsToSettingsAsync(); /// /// Clear all registered shortcuts /// Task ClearAllShortcutsAsync(); /// /// Get the default shortcuts for the application /// Dictionary GetDefaultShortcuts(); } /// /// Represents a keyboard shortcut /// public class KeyboardShortcut { public string ActionName { get; set; } = string.Empty; public Key Key { get; set; } public ModifierKeys Modifiers { get; set; } public string Description { get; set; } = string.Empty; public bool IsEnabled { get; set; } = true; public bool IsGlobal { get; set; } = true; public override string ToString() { var parts = new List(); if (Modifiers.HasFlag(ModifierKeys.Control)) parts.Add("Ctrl"); if (Modifiers.HasFlag(ModifierKeys.Alt)) parts.Add("Alt"); if (Modifiers.HasFlag(ModifierKeys.Shift)) parts.Add("Shift"); if (Modifiers.HasFlag(ModifierKeys.Windows)) parts.Add("Win"); parts.Add(Key.ToString()); return string.Join(" + ", parts); } } /// /// Event args for shortcut activation /// public class ShortcutActivatedEventArgs : EventArgs { public string ActionName { get; } public KeyboardShortcut Shortcut { get; } public DateTime ActivationTime { get; } public ShortcutActivatedEventArgs(string actionName, KeyboardShortcut shortcut) { ActionName = actionName; Shortcut = shortcut; ActivationTime = DateTime.UtcNow; } } /// /// Predefined shortcut actions /// public static class ShortcutActions { public const string QuickApply = "QuickApply"; public const string ToggleMonitoring = "ToggleMonitoring"; public const string ShowMainWindow = "ShowMainWindow"; public const string HideToTray = "HideToTray"; public const string PowerPlanBalanced = "PowerPlanBalanced"; public const string PowerPlanHighPerformance = "PowerPlanHighPerformance"; public const string PowerPlanPowerSaver = "PowerPlanPowerSaver"; public const string GameBoostToggle = "GameBoostToggle"; public const string RefreshProcessList = "RefreshProcessList"; public const string OpenSettings = "OpenSettings"; public const string OpenTweaks = "OpenTweaks"; public const string ExitApplication = "ExitApplication"; } }