1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-25 15:20:10 +00:00
msfs-popout-panel-manager/Orchestration/KeyboardOrchestrator.cs

52 lines
1.8 KiB
C#
Raw Normal View History

using MSFSPopoutPanelManager.Shared;
using MSFSPopoutPanelManager.WindowsAgent;
namespace MSFSPopoutPanelManager.Orchestration
{
public class KeyboardOrchestrator : ObservableObject
{
private AppSettingData _appSettingData;
private FlightSimData _flightSimData;
public KeyboardOrchestrator(AppSettingData appSettingData, FlightSimData flightSimData)
{
_appSettingData = appSettingData;
_flightSimData = flightSimData;
}
internal PanelPopOutOrchestrator PanelPopOutOrchestrator { get; set; }
public void Initialize()
{
if (_appSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled)
{
InputHookManager.StartKeyboardHook();
InputHookManager.OnKeyUp -= HandleKeyboardHookKeyUpEvent;
InputHookManager.OnKeyUp += HandleKeyboardHookKeyUpEvent;
}
_appSettingData.ApplicationSetting.IsUsedKeyboardShortcutChanged += (sender, e) =>
{
if (e)
{
InputHookManager.StartKeyboardHook();
InputHookManager.OnKeyUp -= HandleKeyboardHookKeyUpEvent;
InputHookManager.OnKeyUp += HandleKeyboardHookKeyUpEvent;
}
else
{
InputHookManager.EndKeyboardHook();
InputHookManager.OnKeyUp -= HandleKeyboardHookKeyUpEvent;
}
};
}
public void HandleKeyboardHookKeyUpEvent(object sender, KeyUpEventArgs e)
{
// Start pop out
if (e.IsHoldControl && e.IsHoldShift && e.KeyCode.ToUpper() == _appSettingData.ApplicationSetting.KeyboardShortcutSetting.StartPopOutKeyBinding)
PanelPopOutOrchestrator.ManualPopOut();
}
}
}