diff --git a/DomainModel/DomainModel.csproj b/DomainModel/DomainModel.csproj
index c03a46f..0fb178f 100644
--- a/DomainModel/DomainModel.csproj
+++ b/DomainModel/DomainModel.csproj
@@ -11,9 +11,9 @@
https://github.com/hawkeye-stan/msfs-popout-panel-manager
MSFSPopoutPanelManager.DomainModel
x64
- 4.1.0.2
- 4.1.0.2
- 4.1.0.2
+ 4.1.0.3
+ 4.1.0.3
+ 4.1.0.3
win-x64
Embedded
Debug;Release;Local
diff --git a/DomainModel/Profile/FloatingPanel.cs b/DomainModel/Profile/FloatingPanel.cs
index 13c57b5..80ec241 100644
--- a/DomainModel/Profile/FloatingPanel.cs
+++ b/DomainModel/Profile/FloatingPanel.cs
@@ -7,7 +7,7 @@ namespace MSFSPopoutPanelManager.DomainModel.Profile
{
public bool IsEnabled { get; set; }
- public string Binding { get; set; }
+ public string KeyboardBinding { get; set; }
[JsonIgnore]
public bool IsDetectingKeystroke { get; set; }
diff --git a/DomainModel/Profile/PanelConfig.cs b/DomainModel/Profile/PanelConfig.cs
index 7a315e6..681a7c3 100644
--- a/DomainModel/Profile/PanelConfig.cs
+++ b/DomainModel/Profile/PanelConfig.cs
@@ -33,7 +33,7 @@ namespace MSFSPopoutPanelManager.DomainModel.Profile
arg.PropertyName == nameof(FloatingPanel.IsEnabled))
{
if (!FloatingPanel.IsEnabled)
- FloatingPanel.Binding = null;
+ FloatingPanel.KeyboardBinding = null;
}
}
diff --git a/DomainModel/Setting/KeyboardShortcutSetting.cs b/DomainModel/Setting/KeyboardShortcutSetting.cs
index af74335..60e6e14 100644
--- a/DomainModel/Setting/KeyboardShortcutSetting.cs
+++ b/DomainModel/Setting/KeyboardShortcutSetting.cs
@@ -1,11 +1,37 @@
-using MSFSPopoutPanelManager.Shared;
+using System.Collections.Generic;
+using System.Linq;
+using MSFSPopoutPanelManager.Shared;
+using Newtonsoft.Json;
namespace MSFSPopoutPanelManager.DomainModel.Setting
{
public class KeyboardShortcutSetting : ObservableObject
{
+ private string _startPopOutKeyBindingLegacyConversion;
+
public bool IsEnabled { get; set; } = true;
- public string StartPopOutKeyBinding { get; set; } = "O";
+ public string StartPopOutKeyBinding
+ {
+ get => _startPopOutKeyBindingLegacyConversion;
+ set
+ {
+ // Convert legacy start pop out keyboard binding to new keyboard bindings (v4.0.3 and earlier)
+
+ if (string.IsNullOrEmpty(value))
+ return;
+
+ var keys = new List() { "LeftCtrl", "LeftShift", value.ToUpper() };
+ keys = keys.OrderBy(x => x).ToList();
+ PopOutKeyboardBinding = string.Join("|", keys);
+
+ _startPopOutKeyBindingLegacyConversion = null;
+ }
+ }
+
+ public string PopOutKeyboardBinding { get; set; }
+
+ [JsonIgnore]
+ public bool IsDetectingKeystroke { get; set; }
}
}
diff --git a/MainApp/App.xaml.cs b/MainApp/App.xaml.cs
index 576e45b..532f358 100644
--- a/MainApp/App.xaml.cs
+++ b/MainApp/App.xaml.cs
@@ -54,7 +54,7 @@ namespace MSFSPopoutPanelManager.MainApp
services.AddSingleton(s => new AppOrchestrator(SharedStorage, s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService()));
services.AddSingleton(s => new ProfileOrchestrator(SharedStorage));
services.AddSingleton(s => new PanelSourceOrchestrator(SharedStorage, s.GetRequiredService()));
- services.AddSingleton(s => new PanelPopOutOrchestrator(SharedStorage, s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService()));
+ services.AddSingleton(s => new PanelPopOutOrchestrator(SharedStorage, s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService()));
services.AddSingleton(s => new PanelConfigurationOrchestrator(SharedStorage, s.GetRequiredService(), s.GetRequiredService()));
services.AddSingleton(s => new FlightSimOrchestrator(SharedStorage));
services.AddSingleton(s => new KeyboardOrchestrator(SharedStorage));
@@ -66,10 +66,11 @@ namespace MSFSPopoutPanelManager.MainApp
services.AddSingleton(s => new ProfileCardListViewModel(SharedStorage, s.GetRequiredService(), s.GetRequiredService()));
services.AddSingleton(s => new ProfileCardViewModel(SharedStorage, s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService()));
services.AddSingleton(s => new TrayIconViewModel(SharedStorage, s.GetRequiredService(), s.GetRequiredService()));
+ services.AddSingleton(s => new PreferenceDrawerViewModel(SharedStorage, s.GetRequiredService()));
services.AddTransient(s => new AddProfileViewModel(SharedStorage, s.GetRequiredService(), s.GetRequiredService()));
services.AddTransient(s => new PopOutPanelListViewModel(SharedStorage));
- services.AddTransient(s => new PopOutPanelConfigCardViewModel(SharedStorage, s.GetRequiredService(), s.GetRequiredService()));
+ services.AddTransient(s => new PopOutPanelConfigCardViewModel(SharedStorage, s.GetRequiredService(), s.GetRequiredService(), s.GetRequiredService()));
services.AddTransient(s => new PopOutPanelSourceCardViewModel(SharedStorage, s.GetRequiredService(), s.GetRequiredService()));
services.AddTransient(s => new PopOutPanelSourceLegacyCardViewModel(SharedStorage, s.GetRequiredService(), s.GetRequiredService()));
services.AddTransient(s => new PanelConfigFieldViewModel(SharedStorage, s.GetRequiredService()));
diff --git a/MainApp/AppUserControl/PopOutPanelConfigCard.xaml b/MainApp/AppUserControl/PopOutPanelConfigCard.xaml
index f797150..5992aff 100644
--- a/MainApp/AppUserControl/PopOutPanelConfigCard.xaml
+++ b/MainApp/AppUserControl/PopOutPanelConfigCard.xaml
@@ -327,7 +327,7 @@
- Floating Window
+ Floating Panel Toggle
-
+ Text="Keyboard Binding:" />
-
diff --git a/MainApp/AppUserControl/PopOutPanelConfigCard.xaml.cs b/MainApp/AppUserControl/PopOutPanelConfigCard.xaml.cs
index b7552d1..3e63b01 100644
--- a/MainApp/AppUserControl/PopOutPanelConfigCard.xaml.cs
+++ b/MainApp/AppUserControl/PopOutPanelConfigCard.xaml.cs
@@ -2,12 +2,8 @@
using MSFSPopoutPanelManager.DomainModel.Profile;
using MSFSPopoutPanelManager.MainApp.AppUserControl.PopOutPanelCard;
using MSFSPopoutPanelManager.MainApp.ViewModel;
-using MSFSPopoutPanelManager.Orchestration;
using System;
-using System.Collections.Generic;
using System.ComponentModel;
-using System.Diagnostics;
-using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
@@ -36,7 +32,6 @@ namespace MSFSPopoutPanelManager.MainApp.AppUserControl
InitializeComponent();
};
}
-
public PanelConfig DataItem
{
get => (PanelConfig)GetValue(DataItemProperty2);
@@ -70,168 +65,7 @@ namespace MSFSPopoutPanelManager.MainApp.AppUserControl
if (!string.IsNullOrEmpty(param))
_viewModel.PanelAttributeUpdatedCommand.Execute(param);
-
- //if (sender is ToggleButton { Name: "TglBtnAllowFloatPanel" })
- // ComboBoxFloatPanelKeyBinding.SelectedIndex = 0;
}
-
- //private void ComboBoxFloatPanelKeyBinding_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
- //{
- // var comboBox = (ComboBox)sender;
-
- // if (comboBox.SelectedIndex is 0 or -1)
- // {
- // _viewModel.DataItem.FloatingPanel.Binding = null;
- // return;
- // }
-
- // var selectedValue = comboBox.SelectedValue.ToString();
-
- // if (_viewModel.ActiveProfile.PanelConfigs.Any(x => x.FloatingPanel.Binding == selectedValue && x.Id != _viewModel.DataItem.Id))
- // comboBox.SelectedIndex = 0;
-
-
- // _viewModel.DataItem.FloatingPanel.Binding = selectedValue;
- //}
-
- //private readonly List _floatKeyBindings = new()
- //{
- // "",
- // "Ctrl-1",
- // "Ctrl-2",
- // "Ctrl-3",
- // "Ctrl-4",
- // "Ctrl-5",
- // "Ctrl-6",
- // "Ctrl-7",
- // "Ctrl-8",
- // "Ctrl-9",
- // "Ctrl-0"
- //};
-
- //private void ComboBoxFloatPanelKeyBinding_OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- //{
- // BindFloatPanelKeyBinding();
- //}
-
- //private void ComboBoxFloatPanelKeyBinding_OnLoaded(object sender, RoutedEventArgs e)
- //{
- // BindFloatPanelKeyBinding();
- //}
-
- //private void BindFloatPanelKeyBinding()
- //{
- // var items = new List();
- // items.AddRange(_floatKeyBindings);
-
- // foreach (var panelConfig in _viewModel.ActiveProfile.PanelConfigs)
- // {
- // if (panelConfig.FloatingPanel.Binding != null && panelConfig.Id != _viewModel.DataItem.Id)
- // items.Remove(panelConfig.FloatingPanel.Binding);
- // }
-
- // ComboBoxFloatPanelKeyBinding.ItemsSource = items;
-
- // var index = items.ToList().FindIndex(x => string.Equals(x, _viewModel.DataItem.FloatingPanel.Binding, StringComparison.CurrentCultureIgnoreCase));
-
- // if (index == -1)
- // return;
-
- // this.ComboBoxFloatPanelKeyBinding.SelectedIndex = index;
- //}
-
- private void BtnDetectFloatPanelKeyBinding_OnClick(object sender, RoutedEventArgs e)
- {
- this.KeyDown -= OnDetectKeyDown;
- this.KeyDown += OnDetectKeyDown;
- this.KeyUp -= OnDetectKeyUp;
- this.KeyUp += OnDetectKeyUp;
-
- _viewModel.DataItem.FloatingPanel.IsDetectingKeystroke = true;
- }
-
- private bool _isDetectingKeys;
-
- private void OnDetectKeyDown(object sender, KeyEventArgs e)
- {
- //if (!_isDetectingKeys)
- //{
- // _isDetectingKeys = true;
- // _viewModel.DataItem.FloatingPanel.Binding.Clear();
- //}
-
- //_viewModel.DataItem.FloatingPanel.Binding.Add(e.Key == Key.System ? e.SystemKey.ToString() : e.Key.ToString());
- }
-
- private void OnDetectKeyUp(object sender, KeyEventArgs e)
- {
- //_isDetectingKeys = false;
- //Debug.WriteLine(string.Join(" + ", _viewModel.DataItem.FloatingPanel.Binding.ToArray()));
-
- //this.KeyDown -= OnDetectKeyDown;
- //this.KeyUp -= OnDetectKeyUp;
-
- //_viewModel.DataItem.FloatingPanel.IsDetectingKeystroke = false;
- }
-
-
- //private List _capturesList = new();
- //private bool _isCapturing;
-
- //private GlobalKeyboardHook _globalKeyboardHook;
-
- //private void BtnTest_OnClick(object sender, RoutedEventArgs e)
- //{
- // if (_globalKeyboardHook != null)
- // {
- // _globalKeyboardHook.KeyboardPressed -= GlobalKeyboardHookOnKeyboardPressed;
- // _globalKeyboardHook?.Dispose();
- // _globalKeyboardHook = null;
- // }
- // else
- // {
- // _globalKeyboardHook = new GlobalKeyboardHook();
- // _globalKeyboardHook.KeyboardPressed += GlobalKeyboardHookOnKeyboardPressed;
- // }
- //}
-
- //private void GlobalKeyboardHookOnKeyboardPressed(object sender, GlobalKeyboardHookEventArgs e)
- //{
- // if (e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyUp)
- // {
- // _isCapturing = false;
- // }
-
- // if (e.KeyboardState is GlobalKeyboardHook.KeyboardState.KeyDown or GlobalKeyboardHook.KeyboardState.SysKeyDown && !_isCapturing)
- // {
- // _capturesList.Add(new KeyPressState { Key = e.KeyboardData.Key.ToString()});
- // return;
- // }
-
- // if (e.KeyboardState is GlobalKeyboardHook.KeyboardState.KeyUp or GlobalKeyboardHook.KeyboardState.SysKeyUp && !_isCapturing)
- // {
- // var matched = _capturesList.FirstOrDefault(x => x.Key == e.KeyboardData.Key.ToString());
-
- // if (matched == null)
- // {
- // // Error since there is keydown but no keyup
- // _isCapturing = true;
- // _capturesList.Clear();
- // }
- // else
- // {
- // matched.IsPressed = true;
-
- // // Check if all keydown matches keyup
- // if (_capturesList.All(x => x.IsPressed))
- // {
- // Debug.WriteLine(string.Join(" + ", _capturesList.ToArray().Select(x => x.Key)));
- // _capturesList.Clear();
- // }
- // }
- // }
- //}
}
-
}
diff --git a/MainApp/AppUserControl/PreferenceDrawer.xaml b/MainApp/AppUserControl/PreferenceDrawer.xaml
index dfe6883..b9dd135 100644
--- a/MainApp/AppUserControl/PreferenceDrawer.xaml
+++ b/MainApp/AppUserControl/PreferenceDrawer.xaml
@@ -4,6 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:appUserControl="clr-namespace:MSFSPopoutPanelManager.MainApp.AppUserControl"
xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding"
+ xmlns:converter="clr-namespace:MSFSPopoutPanelManager.MainApp.Converter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:localcontrol="clr-namespace:MSFSPopoutPanelManager.MainApp.CustomControl"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
@@ -12,6 +13,7 @@
Width="1024"
mc:Ignorable="d">
+
-
+
Enable using of keyboard shortcuts to control application.
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Configure key binding to initiate start pop out.
-
-
+
+ Start Pop Out
+
+
+
+
+
+
+
+
diff --git a/MainApp/AppUserControl/PreferenceDrawer.xaml.cs b/MainApp/AppUserControl/PreferenceDrawer.xaml.cs
index 500ab1d..49f33f5 100644
--- a/MainApp/AppUserControl/PreferenceDrawer.xaml.cs
+++ b/MainApp/AppUserControl/PreferenceDrawer.xaml.cs
@@ -1,10 +1,28 @@
-namespace MSFSPopoutPanelManager.MainApp.AppUserControl
+using Microsoft.Extensions.DependencyInjection;
+using MSFSPopoutPanelManager.MainApp.ViewModel;
+using System.ComponentModel;
+using System.Windows;
+
+namespace MSFSPopoutPanelManager.MainApp.AppUserControl
{
public partial class PreferenceDrawer
{
+ private readonly PreferenceDrawerViewModel _viewModel;
+
public PreferenceDrawer()
{
- InitializeComponent();
+ if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
+ {
+ InitializeComponent();
+ return;
+ }
+
+ _viewModel = App.AppHost.Services.GetRequiredService();
+ Loaded += (_, _) =>
+ {
+ DataContext = _viewModel;
+ InitializeComponent();
+ };
}
}
}
\ No newline at end of file
diff --git a/MainApp/MainApp.csproj b/MainApp/MainApp.csproj
index a8128d2..418db31 100644
--- a/MainApp/MainApp.csproj
+++ b/MainApp/MainApp.csproj
@@ -14,9 +14,9 @@
MSFSPopoutPanelManager.MainApp
logo.ico
x64
- 4.1.0.2
- 4.1.0.2
- 4.1.0.2
+ 4.1.0.3
+ 4.1.0.3
+ 4.1.0.3
embedded
en
diff --git a/MainApp/ViewModel/PopOutPanelConfigCardViewModel.cs b/MainApp/ViewModel/PopOutPanelConfigCardViewModel.cs
index 4861f57..bd567b5 100644
--- a/MainApp/ViewModel/PopOutPanelConfigCardViewModel.cs
+++ b/MainApp/ViewModel/PopOutPanelConfigCardViewModel.cs
@@ -13,6 +13,7 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
{
private readonly PanelSourceOrchestrator _panelSourceOrchestrator;
private readonly PanelConfigurationOrchestrator _panelConfigurationOrchestrator;
+ private readonly KeyboardOrchestrator _keyboardOrchestrator;
public PanelConfig DataItem { get; set; }
@@ -30,10 +31,11 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
public DelegateCommand PanelAttributeUpdatedCommand { get; set; }
- public PopOutPanelConfigCardViewModel(SharedStorage sharedStorage, PanelSourceOrchestrator panelSourceOrchestrator, PanelConfigurationOrchestrator panelConfigurationOrchestrator) : base(sharedStorage)
+ public PopOutPanelConfigCardViewModel(SharedStorage sharedStorage, PanelSourceOrchestrator panelSourceOrchestrator, PanelConfigurationOrchestrator panelConfigurationOrchestrator, KeyboardOrchestrator keyboardOrchestrator) : base(sharedStorage)
{
_panelSourceOrchestrator = panelSourceOrchestrator;
_panelConfigurationOrchestrator = panelConfigurationOrchestrator;
+ _keyboardOrchestrator = keyboardOrchestrator;
DataItem = new PanelConfig();
@@ -113,20 +115,15 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
{
ActiveProfile.CurrentMoveResizePanelId = DataItem.Id;
- if (!AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled)
- InputHookManager.StartKeyboardHook("KeyboardShortcut");
-
+ InputHookManager.StartKeyboardHook();
InputHookManager.OnKeyUp -= HandleKeyUpEvent;
InputHookManager.OnKeyUp += HandleKeyUpEvent;
}
else
{
ActiveProfile.CurrentMoveResizePanelId = Guid.Empty;
-
- if (!AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled)
- InputHookManager.EndKeyboardHook("KeyboardShortcut");
-
InputHookManager.OnKeyUp -= HandleKeyUpEvent;
+ InputHookManager.EndKeyboardHook();
}
}
diff --git a/MainApp/ViewModel/PreferenceDrawerViewModel.cs b/MainApp/ViewModel/PreferenceDrawerViewModel.cs
new file mode 100644
index 0000000..fbf0d28
--- /dev/null
+++ b/MainApp/ViewModel/PreferenceDrawerViewModel.cs
@@ -0,0 +1,37 @@
+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);
+ }
+ }
+}
diff --git a/Orchestration/AppOrchestrator.cs b/Orchestration/AppOrchestrator.cs
index dd07f72..671b411 100644
--- a/Orchestration/AppOrchestrator.cs
+++ b/Orchestration/AppOrchestrator.cs
@@ -58,7 +58,8 @@ namespace MSFSPopoutPanelManager.Orchestration
_panelConfigurationOrchestrator.EndConfiguration();
_panelConfigurationOrchestrator.EndTouchHook();
- InputHookManager.EndKeyboardHookForced();
+ InputHookManager.EndKeyboardHook();
+ _keyboardOrchestrator.EndGlobalKeyboardHookForced();
_flightSimOrchestrator.EndSimConnectServer(true);
}
diff --git a/Orchestration/KeyboardOrchestrator.cs b/Orchestration/KeyboardOrchestrator.cs
index 495e7a4..e90bb51 100644
--- a/Orchestration/KeyboardOrchestrator.cs
+++ b/Orchestration/KeyboardOrchestrator.cs
@@ -1,5 +1,4 @@
-using MSFSPopoutPanelManager.WindowsAgent;
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@@ -10,7 +9,14 @@ namespace MSFSPopoutPanelManager.Orchestration
{
private GlobalKeyboardHook _globalKeyboardHook;
-
+ private readonly List _keyboardHookClients = new();
+ private List _keyPressCaptureList = new();
+ private bool _isCapturingKeyPress;
+ private KeyboardHookClientType _clientType;
+ private Guid? _panelId;
+
+ public event EventHandler OnKeystrokeDetected;
+
public KeyboardOrchestrator(SharedStorage sharedStorage) : base(sharedStorage)
{
}
@@ -19,48 +25,24 @@ namespace MSFSPopoutPanelManager.Orchestration
{
if (AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled)
{
- InputHookManager.StartKeyboardHook("KeyboardShortcut");
- InputHookManager.OnKeyUp -= HandleShortcutKeyboardHookKeyUpEvent;
- InputHookManager.OnKeyUp += HandleShortcutKeyboardHookKeyUpEvent;
+ StartGlobalKeyboardHook(KeyboardHookClientType.StartPopOutKeyboardShortcut);
}
AppSettingData.ApplicationSetting.OnIsUsedKeyboardShortcutChanged += (_, e) =>
{
if (e)
- {
- InputHookManager.StartKeyboardHook("KeyboardShortcut");
- InputHookManager.OnKeyUp -= HandleShortcutKeyboardHookKeyUpEvent;
- InputHookManager.OnKeyUp += HandleShortcutKeyboardHookKeyUpEvent;
- }
+ StartGlobalKeyboardHook(KeyboardHookClientType.StartPopOutKeyboardShortcut);
else
- {
- InputHookManager.EndKeyboardHook("KeyboardShortcut");
- InputHookManager.OnKeyUp -= HandleShortcutKeyboardHookKeyUpEvent;
- }
+ EndGlobalKeyboardHook(KeyboardHookClientType.StartPopOutKeyboardShortcut);
};
-
-
-
}
- public async void HandleShortcutKeyboardHookKeyUpEvent(object sender, KeyUpEventArgs e)
+
+ public void StartGlobalKeyboardHook(KeyboardHookClientType clientType, Guid? panelId = null)
{
- // Start pop out
- if (e.IsHoldControl && e.IsHoldShift && e.KeyCode.ToUpper() ==
- AppSettingData.ApplicationSetting.KeyboardShortcutSetting.StartPopOutKeyBinding)
- {
- //await _panelPopOutOrchestrator.ManualPopOut();
- return;
- }
- }
+ if(!_keyboardHookClients.Exists(x => x == clientType))
+ _keyboardHookClients.Add(clientType);
-
- private List _keyPressCaptureList = new();
- public event EventHandler OnKeystrokeDetected;
- private bool _isCapturingKeyPress;
- private Guid? _panelId;
-
- public void StartGlobalKeyboardHook(Guid? panelId = null)
- {
+ _clientType = clientType;
_isCapturingKeyPress = true;
_panelId = panelId;
@@ -73,18 +55,24 @@ namespace MSFSPopoutPanelManager.Orchestration
_globalKeyboardHook.KeyboardPressed += HandleGlobalKeyboardHookOnKeyboardPressed;
}
- public void EndGlobalKeyboardHook()
+ public void EndGlobalKeyboardHook(KeyboardHookClientType clientType)
{
- if (_globalKeyboardHook == null)
+ _keyboardHookClients.Remove(clientType);
+
+ if (_globalKeyboardHook == null || _keyboardHookClients.Count > 0)
return;
- Debug.WriteLine("Ends Global Keyboard Hook");
+ EndGlobalKeyboardHookForced();
+ }
+
+ public void EndGlobalKeyboardHookForced()
+ {
+ Debug.WriteLine("Ends Global Keyboard Hook (Forced)");
_keyPressCaptureList = new List();
_globalKeyboardHook.KeyboardPressed -= HandleGlobalKeyboardHookOnKeyboardPressed;
_globalKeyboardHook?.Dispose();
_globalKeyboardHook = null;
}
-
private void HandleGlobalKeyboardHookOnKeyboardPressed(object sender, GlobalKeyboardHookEventArgs e)
{
@@ -99,14 +87,43 @@ namespace MSFSPopoutPanelManager.Orchestration
_isCapturingKeyPress = false;
var keyBinding = string.Join("|", _keyPressCaptureList.DistinctBy(x => x).OrderBy(x => x).ToArray().Select(x => x));
- OnKeystrokeDetected?.Invoke(this, new DetectKeystrokeEventArg {PanelId = _panelId, KeyBinding = keyBinding});
+ if(CheckForRegisteredKeystrokeEvent(keyBinding))
+ OnKeystrokeDetected?.Invoke(this, new DetectKeystrokeEventArg {PanelId = _panelId, KeyBinding = keyBinding});
+
+ _clientType = KeyboardHookClientType.Unknown;
_panelId = null;
_keyPressCaptureList.Clear();
break;
}
}
}
+
+ private bool CheckForRegisteredKeystrokeEvent(string keyBinding)
+ {
+ if (_clientType is KeyboardHookClientType.FloatingPanelDetection or KeyboardHookClientType.PreferenceConfigurationDetection)
+ return true;
+
+ if (!FlightSimData.IsFlightStarted)
+ return false;
+
+ // Check if keystrokes are registered keyboard events
+ bool isRegistered = AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled;
+
+ if (ProfileData.ActiveProfile != null)
+ {
+ foreach (var panelConfig in ProfileData.ActiveProfile.PanelConfigs)
+ {
+ if (panelConfig.FloatingPanel.IsEnabled &&
+ panelConfig.PanelHandle != IntPtr.MaxValue &&
+ panelConfig.PanelHandle != IntPtr.Zero &&
+ panelConfig.FloatingPanel.KeyboardBinding == keyBinding)
+ isRegistered = true;
+ }
+ }
+
+ return isRegistered;
+ }
}
public class DetectKeystrokeEventArg : EventArgs
@@ -115,4 +132,15 @@ namespace MSFSPopoutPanelManager.Orchestration
public string KeyBinding { get; set; }
}
+
+ public enum KeyboardHookClientType
+ {
+ Unknown,
+ PreferenceConfigurationDetection,
+ StartPopOutKeyboardShortcut,
+ PanelPositionConfiguration,
+ FloatingPanelDetection,
+ FloatingPanel,
+
+ }
}
diff --git a/Orchestration/Orchestration.csproj b/Orchestration/Orchestration.csproj
index 39dedcb..9be1104 100644
--- a/Orchestration/Orchestration.csproj
+++ b/Orchestration/Orchestration.csproj
@@ -11,9 +11,9 @@
https://github.com/hawkeye-stan/msfs-popout-panel-manager
MSFSPopoutPanelManager.Orchestration
x64
- 4.1.0.2
- 4.1.0.2
- 4.1.0.2
+ 4.1.0.3
+ 4.1.0.3
+ 4.1.0.3
win-x64
Embedded
Debug;Release;Local
diff --git a/Orchestration/PanelConfigurationOrchestrator.cs b/Orchestration/PanelConfigurationOrchestrator.cs
index 52b6e21..5752913 100644
--- a/Orchestration/PanelConfigurationOrchestrator.cs
+++ b/Orchestration/PanelConfigurationOrchestrator.cs
@@ -32,12 +32,18 @@ namespace MSFSPopoutPanelManager.Orchestration
_keyboardOrchestrator.OnKeystrokeDetected += (_, e) =>
{
+ if (ActiveProfile == null)
+ return;
+
var panel = ActiveProfile.PanelConfigs.FirstOrDefault(p => p.Id == e.PanelId);
if (panel != null && panel.FloatingPanel.IsDetectingKeystroke)
{
- panel.FloatingPanel.Binding = e.KeyBinding;
+ panel.FloatingPanel.KeyboardBinding = e.KeyBinding;
panel.FloatingPanel.IsDetectingKeystroke = false;
+
+ StopDetectKeystroke();
+ _keyboardOrchestrator.StartGlobalKeyboardHook(KeyboardHookClientType.FloatingPanel);
}
else
{
@@ -51,9 +57,9 @@ namespace MSFSPopoutPanelManager.Orchestration
return;
if (e)
- _keyboardOrchestrator.StartGlobalKeyboardHook();
+ _keyboardOrchestrator.StartGlobalKeyboardHook(KeyboardHookClientType.FloatingPanel);
else
- _keyboardOrchestrator.EndGlobalKeyboardHook();
+ _keyboardOrchestrator.EndGlobalKeyboardHook(KeyboardHookClientType.FloatingPanel);
};
ProfileData.OnActiveProfileChanged += (_, _) =>
@@ -62,7 +68,7 @@ namespace MSFSPopoutPanelManager.Orchestration
return;
if (ActiveProfile.PanelConfigs.Any(x => x.FloatingPanel.IsEnabled))
- _keyboardOrchestrator.StartGlobalKeyboardHook();
+ _keyboardOrchestrator.StartGlobalKeyboardHook(KeyboardHookClientType.FloatingPanel);
};
}
@@ -195,7 +201,7 @@ namespace MSFSPopoutPanelManager.Orchestration
public void ToggleFloatPanel(string keyBinding)
{
- var panels = ActiveProfile.PanelConfigs.ToList().FindAll(x => string.Equals(x.FloatingPanel.Binding, keyBinding, StringComparison.Ordinal));
+ var panels = ActiveProfile.PanelConfigs.ToList().FindAll(x => string.Equals(x.FloatingPanel.KeyboardBinding, keyBinding, StringComparison.Ordinal));
if (!panels.Any())
return;
@@ -233,12 +239,12 @@ namespace MSFSPopoutPanelManager.Orchestration
if (panel != null)
panel.FloatingPanel.IsDetectingKeystroke = true;
- _keyboardOrchestrator.StartGlobalKeyboardHook(panelId);
+ _keyboardOrchestrator.StartGlobalKeyboardHook(KeyboardHookClientType.FloatingPanelDetection, panelId);
}
- public void StopDetectKeystroke(Guid panelId)
+ public void StopDetectKeystroke()
{
- _keyboardOrchestrator.EndGlobalKeyboardHook();
+ _keyboardOrchestrator.EndGlobalKeyboardHook(KeyboardHookClientType.FloatingPanelDetection);
}
}
}
diff --git a/Orchestration/PanelPopOutOrchestrator.cs b/Orchestration/PanelPopOutOrchestrator.cs
index bc63dd9..8ad22ac 100644
--- a/Orchestration/PanelPopOutOrchestrator.cs
+++ b/Orchestration/PanelPopOutOrchestrator.cs
@@ -17,21 +17,31 @@ namespace MSFSPopoutPanelManager.Orchestration
private const int CAMERA_VIEW_HOME_COCKPIT_MODE = 8;
private const int CAMERA_VIEW_CUSTOM_CAMERA = 7;
+ private bool _isPopOutExecuting = false;
+
private readonly FlightSimOrchestrator _flightSimOrchestrator;
private readonly PanelSourceOrchestrator _panelSourceOrchestrator;
private readonly PanelConfigurationOrchestrator _panelConfigurationOrchestrator;
+ private readonly KeyboardOrchestrator _keyboardOrchestrator;
- public PanelPopOutOrchestrator(SharedStorage sharedStorage, FlightSimOrchestrator flightSimOrchestrator, PanelSourceOrchestrator panelSourceOrchestrator, PanelConfigurationOrchestrator panelConfigurationOrchestrator) : base(sharedStorage)
+ public PanelPopOutOrchestrator(SharedStorage sharedStorage, FlightSimOrchestrator flightSimOrchestrator, PanelSourceOrchestrator panelSourceOrchestrator, PanelConfigurationOrchestrator panelConfigurationOrchestrator, KeyboardOrchestrator keyboardOrchestrator) : base(sharedStorage)
{
_flightSimOrchestrator = flightSimOrchestrator;
_panelSourceOrchestrator = panelSourceOrchestrator;
_panelConfigurationOrchestrator = panelConfigurationOrchestrator;
+ _keyboardOrchestrator = keyboardOrchestrator;
flightSimOrchestrator.OnFlightStarted += async (_, _) =>
{
if (AppSettingData.ApplicationSetting.AutoPopOutSetting.IsEnabled)
await AutoPopOut();
};
+
+ _keyboardOrchestrator.OnKeystrokeDetected += (_, e) =>
+ {
+ if (e.KeyBinding == AppSetting.KeyboardShortcutSetting.PopOutKeyboardBinding && !ActiveProfile.IsDisabledStartPopOut)
+ ManualPopOut();
+ };
}
private UserProfile ActiveProfile => ProfileData?.ActiveProfile;
@@ -56,6 +66,8 @@ namespace MSFSPopoutPanelManager.Orchestration
public async Task AutoPopOut()
{
+ _isPopOutExecuting = true;
+
await Application.Current.Dispatcher.Invoke(async () =>
{
ProfileData.AutoSwitchProfile();
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index fc91458..101aecc 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -10,6 +10,10 @@ Video showing how to update existing aircraft profile to use the new panel selec
* Added new feature to allow pop up panel as floating window. You can assign hotkeys (Ctrl-0 to Ctrl-9) to have the pop out to toggle either showing on screen or minimize.
+Video showing how to manage floating panel: https://vimeo.com/918153200
+
* Added a new button to easily close all Pop Out Panel Manager's managed pop outs.
+
+* Updated keyboard shortcut feature in preference setting to allow usage of custom keyboard shortcut instead of predefined set of keyboard shortcuts.
* Fixed few reported bugs in the application.
\ No newline at end of file
diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj
index f1c4306..9ca880d 100644
--- a/Shared/Shared.csproj
+++ b/Shared/Shared.csproj
@@ -11,9 +11,9 @@
https://github.com/hawkeye-stan/msfs-popout-panel-manager
MSFSPopoutPanelManager.Shared
x64
- 4.1.0.2
- 4.1.0.2
- 4.1.0.2
+ 4.1.0.3
+ 4.1.0.3
+ 4.1.0.3
win-x64
Embedded
Debug;Release;Local
diff --git a/SimconnectAgent/SimconnectAgent.csproj b/SimconnectAgent/SimconnectAgent.csproj
index 4317c62..1ec3e75 100644
--- a/SimconnectAgent/SimconnectAgent.csproj
+++ b/SimconnectAgent/SimconnectAgent.csproj
@@ -11,9 +11,9 @@
https://github.com/hawkeye-stan/msfs-popout-panel-manager
MSFSPopoutPanelManager.SimConnectAgent
x64
- 4.1.0.2
- 4.1.0.2
- 4.1.0.2
+ 4.1.0.3
+ 4.1.0.3
+ 4.1.0.3
win-x64
Embedded
Debug;Release;Local
diff --git a/VERSION.md b/VERSION.md
index 961fd18..154c1e7 100644
--- a/VERSION.md
+++ b/VERSION.md
@@ -13,7 +13,11 @@ Video showing how to update existing aircraft profile to use the new panel selec
* Added new feature to allow pop up panel as floating window. You can assign hotkeys (Ctrl-0 to Ctrl-9) to have the pop out to toggle either showing on screen or minimize.
+Video showing how to manage floating panel: https://vimeo.com/918153200
+
* Added a new button to easily close all Pop Out Panel Manager's managed pop outs.
+
+* Updated keyboard shortcut feature in preference setting to allow usage of custom keyboard shortcut instead of predefined set of keyboard shortcuts.
* Fixed few reported bugs in the application.
diff --git a/WindowsAgent/InputHookManager.cs b/WindowsAgent/InputHookManager.cs
index 19a1c92..7885b6a 100644
--- a/WindowsAgent/InputHookManager.cs
+++ b/WindowsAgent/InputHookManager.cs
@@ -1,8 +1,6 @@
using System;
-using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
-using System.Linq;
using WindowsHook;
namespace MSFSPopoutPanelManager.WindowsAgent
@@ -17,8 +15,6 @@ namespace MSFSPopoutPanelManager.WindowsAgent
private static IKeyboardMouseEvents _keyboardHook;
public static event EventHandler OnKeyUp;
- private static List _keyboardHookSubscribers = new List();
-
public static void StartMouseHook()
{
if (_mouseHook == null)
@@ -55,12 +51,9 @@ namespace MSFSPopoutPanelManager.WindowsAgent
OnLeftClick?.Invoke(null, new Point(e.X, e.Y));
}
- public static void StartKeyboardHook(string subscriber)
+ public static void StartKeyboardHook()
{
- if(!_keyboardHookSubscribers.Contains(subscriber))
- _keyboardHookSubscribers.Add(subscriber);
-
- if (_keyboardHook == null && _keyboardHookSubscribers.Count > 0)
+ if (_keyboardHook == null)
{
Debug.WriteLine("Starting Keyboard Hook...");
@@ -69,11 +62,9 @@ namespace MSFSPopoutPanelManager.WindowsAgent
}
}
- public static void EndKeyboardHook(string subscriber)
+ public static void EndKeyboardHook()
{
- _keyboardHookSubscribers.Remove(subscriber);
-
- if (_keyboardHook != null && _keyboardHookSubscribers.Count == 0)
+ if (_keyboardHook != null)
{
Debug.WriteLine("Ending Keyboard Hook...");
_keyboardHook.KeyUp -= HandleKeyboardHookKeyUp;
@@ -88,25 +79,6 @@ namespace MSFSPopoutPanelManager.WindowsAgent
}
}
- public static void EndKeyboardHookForced()
- {
- _keyboardHookSubscribers.Clear();
-
- if (_keyboardHook != null)
- {
- Debug.WriteLine("Ending Keyboard Hook (forced)...");
- _keyboardHook.KeyUp -= HandleKeyboardHookKeyUp;
- _keyboardHook.Dispose();
- _keyboardHook = null;
- }
-
- if (OnKeyUp != null)
- {
- foreach (Delegate d in OnKeyUp.GetInvocationList())
- OnKeyUp -= (EventHandler)d;
- }
- }
-
private static void HandleKeyboardHookKeyUp(object sender, KeyEventArgs e)
{
OnKeyUp?.Invoke(null, new KeyUpEventArgs() { KeyCode = e.KeyCode.ToString(), IsHoldControl = e.Control, IsHoldShift = e.Shift });
diff --git a/WindowsAgent/WindowEventManager.cs b/WindowsAgent/WindowEventManager.cs
index b6fec17..c1f60bc 100644
--- a/WindowsAgent/WindowEventManager.cs
+++ b/WindowsAgent/WindowEventManager.cs
@@ -110,9 +110,6 @@ namespace MSFSPopoutPanelManager.WindowsAgent
case PInvokeConstant.EVENT_OBJECT_STATECHANGE:
if (!ActiveProfile.IsLocked)
{
- if (panelConfig.FloatingPanel.IsEnabled && panelConfig.IsFloating) // do not update coordinate if floating window
- return;
-
Thread.Sleep(300);
UpdatePanelCoordinates(panelConfig);
}
@@ -191,7 +188,10 @@ namespace MSFSPopoutPanelManager.WindowsAgent
panelConfig.PanelHandle = IntPtr.MaxValue;
return;
}
-
+
+ if (panelConfig.FloatingPanel.IsEnabled && panelConfig.IsFloating) // do not update coordinate if floating panel
+ return;
+
panelConfig.Left = rect.Left;
panelConfig.Top = rect.Top;
diff --git a/WindowsAgent/WindowsAgent.csproj b/WindowsAgent/WindowsAgent.csproj
index ea2cf47..7d9da87 100644
--- a/WindowsAgent/WindowsAgent.csproj
+++ b/WindowsAgent/WindowsAgent.csproj
@@ -11,9 +11,9 @@
https://github.com/hawkeye-stan/msfs-popout-panel-manager
MSFSPopoutPanelManager.WindowsAgent
x64
- 4.1.0.2
- 4.1.0.2
- 4.1.0.2
+ 4.1.0.3
+ 4.1.0.3
+ 4.1.0.3
win-x64
Embedded
Debug;Release;Local