mirror of
https://github.com/hawkeye-stan/msfs-popout-panel-manager.git
synced 2024-11-22 05:40:11 +00:00
37 lines
1.5 KiB
C#
37 lines
1.5 KiB
C#
using MSFSPopoutPanelManager.Orchestration;
|
|
using Prism.Commands;
|
|
using System.Windows.Input;
|
|
|
|
namespace MSFSPopoutPanelManager.MainApp.ViewModel
|
|
{
|
|
public class PreferenceDrawerViewModel : BaseViewModel
|
|
{
|
|
private readonly KeyboardOrchestrator _keyboardOrchestrator;
|
|
|
|
public ICommand DetectStartPopOutKeyBindingCommand { get; }
|
|
|
|
public bool IsDetectingKeystroke { get; set; }
|
|
|
|
public PreferenceDrawerViewModel(SharedStorage sharedStorage, KeyboardOrchestrator keyboardOrchestrator) : base(sharedStorage)
|
|
{
|
|
_keyboardOrchestrator = keyboardOrchestrator;
|
|
|
|
DetectStartPopOutKeyBindingCommand = new DelegateCommand(OnDetectStartPopOutKeyBinding);
|
|
}
|
|
|
|
private void KeyboardOrchestrator_OnKeystrokeDetected(object sender, DetectKeystrokeEventArg e)
|
|
{
|
|
IsDetectingKeystroke = false;
|
|
AppSettingData.ApplicationSetting.KeyboardShortcutSetting.PopOutKeyboardBinding = e.KeyBinding;
|
|
_keyboardOrchestrator.OnKeystrokeDetected -= KeyboardOrchestrator_OnKeystrokeDetected;
|
|
_keyboardOrchestrator.EndGlobalKeyboardHook(KeyboardHookClientType.PreferenceConfigurationDetection);
|
|
}
|
|
|
|
private void OnDetectStartPopOutKeyBinding()
|
|
{
|
|
IsDetectingKeystroke = true;
|
|
_keyboardOrchestrator.OnKeystrokeDetected += KeyboardOrchestrator_OnKeystrokeDetected;
|
|
_keyboardOrchestrator.StartGlobalKeyboardHook(KeyboardHookClientType.PreferenceConfigurationDetection);
|
|
}
|
|
}
|
|
}
|