1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-23 06:10:11 +00:00

Version 4.1.0 beta 3

This commit is contained in:
hawkeye 2024-03-03 00:02:21 -05:00
parent daa1ec5978
commit 57baed9291
24 changed files with 278 additions and 349 deletions

View file

@ -11,9 +11,9 @@
<PackageProjectUrl>https://github.com/hawkeye-stan/msfs-popout-panel-manager</PackageProjectUrl>
<RootNamespace>MSFSPopoutPanelManager.DomainModel</RootNamespace>
<Platforms>x64</Platforms>
<Version>4.1.0.2</Version>
<AssemblyVersion>4.1.0.2</AssemblyVersion>
<FileVersion>4.1.0.2</FileVersion>
<Version>4.1.0.3</Version>
<AssemblyVersion>4.1.0.3</AssemblyVersion>
<FileVersion>4.1.0.3</FileVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<DebugType>Embedded</DebugType>
<Configurations>Debug;Release;Local</Configurations>

View file

@ -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; }

View file

@ -33,7 +33,7 @@ namespace MSFSPopoutPanelManager.DomainModel.Profile
arg.PropertyName == nameof(FloatingPanel.IsEnabled))
{
if (!FloatingPanel.IsEnabled)
FloatingPanel.Binding = null;
FloatingPanel.KeyboardBinding = null;
}
}

View file

@ -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<string>() { "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; }
}
}

View file

@ -54,7 +54,7 @@ namespace MSFSPopoutPanelManager.MainApp
services.AddSingleton(s => new AppOrchestrator(SharedStorage, s.GetRequiredService<PanelConfigurationOrchestrator>(), s.GetRequiredService<FlightSimOrchestrator>(), s.GetRequiredService<HelpOrchestrator>(), s.GetRequiredService<KeyboardOrchestrator>()));
services.AddSingleton(s => new ProfileOrchestrator(SharedStorage));
services.AddSingleton(s => new PanelSourceOrchestrator(SharedStorage, s.GetRequiredService<FlightSimOrchestrator>()));
services.AddSingleton(s => new PanelPopOutOrchestrator(SharedStorage, s.GetRequiredService<FlightSimOrchestrator>(), s.GetRequiredService<PanelSourceOrchestrator>(), s.GetRequiredService<PanelConfigurationOrchestrator>()));
services.AddSingleton(s => new PanelPopOutOrchestrator(SharedStorage, s.GetRequiredService<FlightSimOrchestrator>(), s.GetRequiredService<PanelSourceOrchestrator>(), s.GetRequiredService<PanelConfigurationOrchestrator>(), s.GetRequiredService<KeyboardOrchestrator>()));
services.AddSingleton(s => new PanelConfigurationOrchestrator(SharedStorage, s.GetRequiredService<FlightSimOrchestrator>(), s.GetRequiredService<KeyboardOrchestrator>()));
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<ProfileOrchestrator>(), s.GetRequiredService<PanelSourceOrchestrator>()));
services.AddSingleton(s => new ProfileCardViewModel(SharedStorage, s.GetRequiredService<ProfileOrchestrator>(), s.GetRequiredService<PanelSourceOrchestrator>(), s.GetRequiredService<PanelConfigurationOrchestrator>(), s.GetRequiredService<PanelPopOutOrchestrator>()));
services.AddSingleton(s => new TrayIconViewModel(SharedStorage, s.GetRequiredService<AppOrchestrator>(), s.GetRequiredService<PanelPopOutOrchestrator>()));
services.AddSingleton(s => new PreferenceDrawerViewModel(SharedStorage, s.GetRequiredService<KeyboardOrchestrator>()));
services.AddTransient(s => new AddProfileViewModel(SharedStorage, s.GetRequiredService<ProfileOrchestrator>(), s.GetRequiredService<PanelSourceOrchestrator>()));
services.AddTransient(s => new PopOutPanelListViewModel(SharedStorage));
services.AddTransient(s => new PopOutPanelConfigCardViewModel(SharedStorage, s.GetRequiredService<PanelSourceOrchestrator>(), s.GetRequiredService<PanelConfigurationOrchestrator>()));
services.AddTransient(s => new PopOutPanelConfigCardViewModel(SharedStorage, s.GetRequiredService<PanelSourceOrchestrator>(), s.GetRequiredService<PanelConfigurationOrchestrator>(), s.GetRequiredService<KeyboardOrchestrator>()));
services.AddTransient(s => new PopOutPanelSourceCardViewModel(SharedStorage, s.GetRequiredService<PanelSourceOrchestrator>(), s.GetRequiredService<PanelConfigurationOrchestrator>()));
services.AddTransient(s => new PopOutPanelSourceLegacyCardViewModel(SharedStorage, s.GetRequiredService<PanelSourceOrchestrator>(), s.GetRequiredService<PanelConfigurationOrchestrator>()));
services.AddTransient(s => new PanelConfigFieldViewModel(SharedStorage, s.GetRequiredService<PanelConfigurationOrchestrator>()));

View file

@ -327,7 +327,7 @@
<WrapPanel Margin="0,10,0,0" VerticalAlignment="Center">
<Border
BorderBrush="Gray"
BorderThickness="1"
BorderThickness="{c:Binding 'DataItem.FloatingPanel.IsEnabled ? 1 : 0'}"
CornerRadius="4">
<WrapPanel Margin="4">
<ToggleButton
@ -342,31 +342,30 @@
VerticalAlignment="Center"
Style="{StaticResource TextBlockLabel}"
ToolTip="Set the pop out panel that can float above other windows">
Floating Window
Floating Panel Toggle
</TextBlock>
<WrapPanel
Margin="10,0,0,0"
VerticalAlignment="Center"
Visibility="{c:Binding DataItem.FloatingPanel.IsEnabled}">
<TextBlock
Margin="5,4,10,4"
VerticalAlignment="Center"
Style="{StaticResource TextBlockLabel}"
Text="Key Binding:" />
Text="Keyboard Binding:" />
<TextBlock
x:Name="TextBlockFloatPanelKeyBinding"
Margin="5,4,10,4"
VerticalAlignment="Center"
Style="{StaticResource TextBlockLabel}"
Text="{Binding DataItem.FloatingPanel.Binding, Converter={StaticResource KeystrokeBindingsConverter}, ConverterParameter=' + '}"
Text="{Binding DataItem.FloatingPanel.KeyboardBinding, Converter={StaticResource KeystrokeBindingsConverter}, ConverterParameter=' + '}"
Visibility="{c:Binding '!DataItem.FloatingPanel.IsDetectingKeystroke'}" />
<TextBlock
x:Name="TextBlockDetectingFloatPanelKeyBinding"
Margin="5,4,10,4"
VerticalAlignment="Center"
Style="{StaticResource TextBlockLabel}"
Text="Detecting..."
Text="Scanning..."
Visibility="{c:Binding 'DataItem.FloatingPanel.IsDetectingKeystroke'}" />
<Button
x:Name="BtnDetectFloatPanelKeyBinding"
@ -378,15 +377,6 @@
Style="{StaticResource MaterialDesignOutlinedButton}">
Detect
</Button>
<!--<Button
x:Name="BtnTest"
Width="80"
Height="25"
Margin="10,0,0,0"
VerticalAlignment="Center"
Style="{StaticResource MaterialDesignOutlinedButton}">
Test
</Button>-->
</WrapPanel>
</WrapPanel>
</Border>

View file

@ -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<string> _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<string>();
// 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<KeyPressState> _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();
// }
// }
// }
//}
}
}

View file

@ -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">
<UserControl.Resources>
<converter:KeystrokeBindingsConverter x:Key="KeystrokeBindingsConverter" />
<Style
x:Key="TextBlockHeading"
BasedOn="{StaticResource {x:Type TextBlock}}"
@ -44,7 +46,7 @@
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
</UserControl.Resources>
<DockPanel d:DataContext="{d:DesignInstance viewmodel:ApplicationViewModel}">
<DockPanel d:DataContext="{d:DesignInstance viewmodel:PreferenceDrawerViewModel}">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<TreeView
Width="210"
@ -512,57 +514,54 @@
<TextBlock Style="{StaticResource TextBlockLabel}">Enable using of keyboard shortcuts to control application.</TextBlock>
</WrapPanel>
</WrapPanel>
<WrapPanel Orientation="Vertical" Visibility="{Binding AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
<WrapPanel Margin="46,15,0,0" Orientation="Vertical">
<TextBlock Style="{StaticResource TextBlockHeading}">Start Pop Out</TextBlock>
<Line
Stretch="Fill"
Stroke="Gray"
X2="1" />
<StackPanel
Width="Auto"
Margin="44,15,0,0"
VerticalAlignment="Top"
Margin="0"
VerticalAlignment="Center"
Orientation="Horizontal">
<WrapPanel>
<Label Content="Ctrl-Shift-" FontSize="14" />
<ComboBox
Width="40"
VerticalAlignment="top"
SelectedValue="{Binding AppSettingData.ApplicationSetting.KeyboardShortcutSetting.StartPopOutKeyBinding, Mode=TwoWay}"
SelectedValuePath="Tag">
<ComboBoxItem Content="A" Tag="A" />
<ComboBoxItem Content="B" Tag="B" />
<ComboBoxItem Content="C" Tag="C" />
<ComboBoxItem Content="D" Tag="D" />
<ComboBoxItem Content="E" Tag="E" />
<ComboBoxItem Content="F" Tag="F" />
<ComboBoxItem Content="G" Tag="G" />
<ComboBoxItem Content="H" Tag="H" />
<ComboBoxItem Content="I" Tag="I" />
<ComboBoxItem Content="J" Tag="J" />
<ComboBoxItem Content="K" Tag="K" />
<ComboBoxItem Content="L" Tag="L" />
<ComboBoxItem Content="M" Tag="M" />
<ComboBoxItem Content="N" Tag="N" />
<ComboBoxItem Content="O" Tag="O" />
<ComboBoxItem Content="P" Tag="P" />
<ComboBoxItem Content="Q" Tag="Q" />
<ComboBoxItem Content="R" Tag="R" />
<ComboBoxItem Content="S" Tag="S" />
<ComboBoxItem Content="T" Tag="T" />
<ComboBoxItem Content="U" Tag="U" />
<ComboBoxItem Content="V" Tag="V" />
<ComboBoxItem Content="W" Tag="W" />
<ComboBoxItem Content="X" Tag="X" />
<ComboBoxItem Content="Y" Tag="Y" />
<ComboBoxItem Content="Z" Tag="Z" />
</ComboBox>
</WrapPanel>
<TextBlock
Width="600"
Margin="10,3,0,0"
Style="{StaticResource TextBlockLabel}">
Configure key binding to initiate start pop out.
</TextBlock>
Width="120"
Margin="0"
VerticalAlignment="Center"
FontSize="14"
Text="Keyboard Binding:" />
<TextBlock
x:Name="TextBlockStartPopOutKeyBinding"
Margin="0"
VerticalAlignment="Center"
FontSize="14"
Text="{Binding AppSettingData.ApplicationSetting.KeyboardShortcutSetting.PopOutKeyboardBinding, Converter={StaticResource KeystrokeBindingsConverter}, ConverterParameter=' + '}"
Visibility="{c:Binding '!IsDetectingKeystroke'}" />
<TextBlock
x:Name="TextBlockDetectingStartPopOutKeyBinding"
Margin="0"
VerticalAlignment="Center"
FontSize="14"
Text="Scanning..."
Visibility="{c:Binding 'IsDetectingKeystroke'}" />
<Button
x:Name="BtnDetectStartPopOutKeyBinding"
Width="80"
Height="25"
Margin="10,0,0,0"
VerticalAlignment="Center"
Command="{Binding DetectStartPopOutKeyBindingCommand}"
Style="{StaticResource MaterialDesignOutlinedButton}">
Detect
</Button>
</StackPanel>
</WrapPanel>
</WrapPanel>
</WrapPanel>
</WrapPanel>
<!-- Touch Settings -->
<WrapPanel Orientation="Vertical" Visibility="{Binding ElementName=CategoryTouchSettings, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">

View file

@ -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()
{
if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
{
InitializeComponent();
return;
}
_viewModel = App.AppHost.Services.GetRequiredService<PreferenceDrawerViewModel>();
Loaded += (_, _) =>
{
DataContext = _viewModel;
InitializeComponent();
};
}
}
}

View file

@ -14,9 +14,9 @@
<RootNamespace>MSFSPopoutPanelManager.MainApp</RootNamespace>
<ApplicationIcon>logo.ico</ApplicationIcon>
<Platforms>x64</Platforms>
<Version>4.1.0.2</Version>
<AssemblyVersion>4.1.0.2</AssemblyVersion>
<FileVersion>4.1.0.2</FileVersion>
<Version>4.1.0.3</Version>
<AssemblyVersion>4.1.0.3</AssemblyVersion>
<FileVersion>4.1.0.3</FileVersion>
<DebugType>embedded</DebugType>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<!-- Publishing options -->

View file

@ -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<string> 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();
}
}

View file

@ -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);
}
}
}

View file

@ -58,7 +58,8 @@ namespace MSFSPopoutPanelManager.Orchestration
_panelConfigurationOrchestrator.EndConfiguration();
_panelConfigurationOrchestrator.EndTouchHook();
InputHookManager.EndKeyboardHookForced();
InputHookManager.EndKeyboardHook();
_keyboardOrchestrator.EndGlobalKeyboardHookForced();
_flightSimOrchestrator.EndSimConnectServer(true);
}

View file

@ -1,5 +1,4 @@
using MSFSPopoutPanelManager.WindowsAgent;
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@ -10,6 +9,13 @@ namespace MSFSPopoutPanelManager.Orchestration
{
private GlobalKeyboardHook _globalKeyboardHook;
private readonly List<KeyboardHookClientType> _keyboardHookClients = new();
private List<string> _keyPressCaptureList = new();
private bool _isCapturingKeyPress;
private KeyboardHookClientType _clientType;
private Guid? _panelId;
public event EventHandler<DetectKeystrokeEventArg> 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)
{
// Start pop out
if (e.IsHoldControl && e.IsHoldShift && e.KeyCode.ToUpper() ==
AppSettingData.ApplicationSetting.KeyboardShortcutSetting.StartPopOutKeyBinding)
{
//await _panelPopOutOrchestrator.ManualPopOut();
return;
}
}
private List<string> _keyPressCaptureList = new();
public event EventHandler<DetectKeystrokeEventArg> OnKeystrokeDetected;
private bool _isCapturingKeyPress;
private Guid? _panelId;
public void StartGlobalKeyboardHook(Guid? panelId = null)
public void StartGlobalKeyboardHook(KeyboardHookClientType clientType, Guid? panelId = null)
{
if(!_keyboardHookClients.Exists(x => x == clientType))
_keyboardHookClients.Add(clientType);
_clientType = clientType;
_isCapturingKeyPress = true;
_panelId = panelId;
@ -73,19 +55,25 @@ 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<string>();
_globalKeyboardHook.KeyboardPressed -= HandleGlobalKeyboardHookOnKeyboardPressed;
_globalKeyboardHook?.Dispose();
_globalKeyboardHook = null;
}
private void HandleGlobalKeyboardHookOnKeyboardPressed(object sender, GlobalKeyboardHookEventArgs e)
{
switch (e.KeyboardState)
@ -99,14 +87,43 @@ namespace MSFSPopoutPanelManager.Orchestration
_isCapturingKeyPress = false;
var keyBinding = string.Join("|", _keyPressCaptureList.DistinctBy(x => x).OrderBy(x => x).ToArray().Select(x => x));
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,
}
}

View file

@ -11,9 +11,9 @@
<PackageProjectUrl>https://github.com/hawkeye-stan/msfs-popout-panel-manager</PackageProjectUrl>
<RootNamespace>MSFSPopoutPanelManager.Orchestration</RootNamespace>
<Platforms>x64</Platforms>
<Version>4.1.0.2</Version>
<AssemblyVersion>4.1.0.2</AssemblyVersion>
<FileVersion>4.1.0.2</FileVersion>
<Version>4.1.0.3</Version>
<AssemblyVersion>4.1.0.3</AssemblyVersion>
<FileVersion>4.1.0.3</FileVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<DebugType>Embedded</DebugType>
<Configurations>Debug;Release;Local</Configurations>

View file

@ -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);
}
}
}

View file

@ -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();

View file

@ -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.

View file

@ -11,9 +11,9 @@
<PackageProjectUrl>https://github.com/hawkeye-stan/msfs-popout-panel-manager</PackageProjectUrl>
<RootNamespace>MSFSPopoutPanelManager.Shared</RootNamespace>
<Platforms>x64</Platforms>
<Version>4.1.0.2</Version>
<AssemblyVersion>4.1.0.2</AssemblyVersion>
<FileVersion>4.1.0.2</FileVersion>
<Version>4.1.0.3</Version>
<AssemblyVersion>4.1.0.3</AssemblyVersion>
<FileVersion>4.1.0.3</FileVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<DebugType>Embedded</DebugType>
<Configurations>Debug;Release;Local</Configurations>

View file

@ -11,9 +11,9 @@
<PackageProjectUrl>https://github.com/hawkeye-stan/msfs-popout-panel-manager</PackageProjectUrl>
<RootNamespace>MSFSPopoutPanelManager.SimConnectAgent</RootNamespace>
<Platforms>x64</Platforms>
<Version>4.1.0.2</Version>
<AssemblyVersion>4.1.0.2</AssemblyVersion>
<FileVersion>4.1.0.2</FileVersion>
<Version>4.1.0.3</Version>
<AssemblyVersion>4.1.0.3</AssemblyVersion>
<FileVersion>4.1.0.3</FileVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<DebugType>Embedded</DebugType>
<Configurations>Debug;Release;Local</Configurations>

View file

@ -13,8 +13,12 @@ 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.
## Version 4.0.3

View file

@ -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<KeyUpEventArgs> OnKeyUp;
private static List<string> _keyboardHookSubscribers = new List<string>();
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<KeyUpEventArgs>)d;
}
}
private static void HandleKeyboardHookKeyUp(object sender, KeyEventArgs e)
{
OnKeyUp?.Invoke(null, new KeyUpEventArgs() { KeyCode = e.KeyCode.ToString(), IsHoldControl = e.Control, IsHoldShift = e.Shift });

View file

@ -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);
}
@ -192,6 +189,9 @@ namespace MSFSPopoutPanelManager.WindowsAgent
return;
}
if (panelConfig.FloatingPanel.IsEnabled && panelConfig.IsFloating) // do not update coordinate if floating panel
return;
panelConfig.Left = rect.Left;
panelConfig.Top = rect.Top;

View file

@ -11,9 +11,9 @@
<PackageProjectUrl>https://github.com/hawkeye-stan/msfs-popout-panel-manager</PackageProjectUrl>
<RootNamespace>MSFSPopoutPanelManager.WindowsAgent</RootNamespace>
<Platforms>x64</Platforms>
<Version>4.1.0.2</Version>
<AssemblyVersion>4.1.0.2</AssemblyVersion>
<FileVersion>4.1.0.2</FileVersion>
<Version>4.1.0.3</Version>
<AssemblyVersion>4.1.0.3</AssemblyVersion>
<FileVersion>4.1.0.3</FileVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<DebugType>Embedded</DebugType>
<Configurations>Debug;Release;Local</Configurations>