1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-21 13:20: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> <PackageProjectUrl>https://github.com/hawkeye-stan/msfs-popout-panel-manager</PackageProjectUrl>
<RootNamespace>MSFSPopoutPanelManager.DomainModel</RootNamespace> <RootNamespace>MSFSPopoutPanelManager.DomainModel</RootNamespace>
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
<Version>4.1.0.2</Version> <Version>4.1.0.3</Version>
<AssemblyVersion>4.1.0.2</AssemblyVersion> <AssemblyVersion>4.1.0.3</AssemblyVersion>
<FileVersion>4.1.0.2</FileVersion> <FileVersion>4.1.0.3</FileVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <RuntimeIdentifier>win-x64</RuntimeIdentifier>
<DebugType>Embedded</DebugType> <DebugType>Embedded</DebugType>
<Configurations>Debug;Release;Local</Configurations> <Configurations>Debug;Release;Local</Configurations>

View file

@ -7,7 +7,7 @@ namespace MSFSPopoutPanelManager.DomainModel.Profile
{ {
public bool IsEnabled { get; set; } public bool IsEnabled { get; set; }
public string Binding { get; set; } public string KeyboardBinding { get; set; }
[JsonIgnore] [JsonIgnore]
public bool IsDetectingKeystroke { get; set; } public bool IsDetectingKeystroke { get; set; }

View file

@ -33,7 +33,7 @@ namespace MSFSPopoutPanelManager.DomainModel.Profile
arg.PropertyName == nameof(FloatingPanel.IsEnabled)) arg.PropertyName == nameof(FloatingPanel.IsEnabled))
{ {
if (!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 namespace MSFSPopoutPanelManager.DomainModel.Setting
{ {
public class KeyboardShortcutSetting : ObservableObject public class KeyboardShortcutSetting : ObservableObject
{ {
private string _startPopOutKeyBindingLegacyConversion;
public bool IsEnabled { get; set; } = true; 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 AppOrchestrator(SharedStorage, s.GetRequiredService<PanelConfigurationOrchestrator>(), s.GetRequiredService<FlightSimOrchestrator>(), s.GetRequiredService<HelpOrchestrator>(), s.GetRequiredService<KeyboardOrchestrator>()));
services.AddSingleton(s => new ProfileOrchestrator(SharedStorage)); services.AddSingleton(s => new ProfileOrchestrator(SharedStorage));
services.AddSingleton(s => new PanelSourceOrchestrator(SharedStorage, s.GetRequiredService<FlightSimOrchestrator>())); 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 PanelConfigurationOrchestrator(SharedStorage, s.GetRequiredService<FlightSimOrchestrator>(), s.GetRequiredService<KeyboardOrchestrator>()));
services.AddSingleton(s => new FlightSimOrchestrator(SharedStorage)); services.AddSingleton(s => new FlightSimOrchestrator(SharedStorage));
services.AddSingleton(s => new KeyboardOrchestrator(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 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 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 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 AddProfileViewModel(SharedStorage, s.GetRequiredService<ProfileOrchestrator>(), s.GetRequiredService<PanelSourceOrchestrator>()));
services.AddTransient(s => new PopOutPanelListViewModel(SharedStorage)); 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 PopOutPanelSourceCardViewModel(SharedStorage, s.GetRequiredService<PanelSourceOrchestrator>(), s.GetRequiredService<PanelConfigurationOrchestrator>()));
services.AddTransient(s => new PopOutPanelSourceLegacyCardViewModel(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>())); services.AddTransient(s => new PanelConfigFieldViewModel(SharedStorage, s.GetRequiredService<PanelConfigurationOrchestrator>()));

View file

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

View file

@ -2,12 +2,8 @@
using MSFSPopoutPanelManager.DomainModel.Profile; using MSFSPopoutPanelManager.DomainModel.Profile;
using MSFSPopoutPanelManager.MainApp.AppUserControl.PopOutPanelCard; using MSFSPopoutPanelManager.MainApp.AppUserControl.PopOutPanelCard;
using MSFSPopoutPanelManager.MainApp.ViewModel; using MSFSPopoutPanelManager.MainApp.ViewModel;
using MSFSPopoutPanelManager.Orchestration;
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
@ -36,7 +32,6 @@ namespace MSFSPopoutPanelManager.MainApp.AppUserControl
InitializeComponent(); InitializeComponent();
}; };
} }
public PanelConfig DataItem public PanelConfig DataItem
{ {
get => (PanelConfig)GetValue(DataItemProperty2); get => (PanelConfig)GetValue(DataItemProperty2);
@ -70,168 +65,7 @@ namespace MSFSPopoutPanelManager.MainApp.AppUserControl
if (!string.IsNullOrEmpty(param)) if (!string.IsNullOrEmpty(param))
_viewModel.PanelAttributeUpdatedCommand.Execute(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:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:appUserControl="clr-namespace:MSFSPopoutPanelManager.MainApp.AppUserControl" xmlns:appUserControl="clr-namespace:MSFSPopoutPanelManager.MainApp.AppUserControl"
xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding" xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding"
xmlns:converter="clr-namespace:MSFSPopoutPanelManager.MainApp.Converter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:localcontrol="clr-namespace:MSFSPopoutPanelManager.MainApp.CustomControl" xmlns:localcontrol="clr-namespace:MSFSPopoutPanelManager.MainApp.CustomControl"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
@ -12,6 +13,7 @@
Width="1024" Width="1024"
mc:Ignorable="d"> mc:Ignorable="d">
<UserControl.Resources> <UserControl.Resources>
<converter:KeystrokeBindingsConverter x:Key="KeystrokeBindingsConverter" />
<Style <Style
x:Key="TextBlockHeading" x:Key="TextBlockHeading"
BasedOn="{StaticResource {x:Type TextBlock}}" BasedOn="{StaticResource {x:Type TextBlock}}"
@ -44,7 +46,7 @@
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
</UserControl.Resources> </UserControl.Resources>
<DockPanel d:DataContext="{d:DesignInstance viewmodel:ApplicationViewModel}"> <DockPanel d:DataContext="{d:DesignInstance viewmodel:PreferenceDrawerViewModel}">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"> <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<TreeView <TreeView
Width="210" Width="210"
@ -512,54 +514,51 @@
<TextBlock Style="{StaticResource TextBlockLabel}">Enable using of keyboard shortcuts to control application.</TextBlock> <TextBlock Style="{StaticResource TextBlockLabel}">Enable using of keyboard shortcuts to control application.</TextBlock>
</WrapPanel> </WrapPanel>
</WrapPanel> </WrapPanel>
<WrapPanel Orientation="Vertical" Visibility="{Binding AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}"> <WrapPanel Orientation="Vertical" Visibility="{Binding AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
<StackPanel <WrapPanel Margin="46,15,0,0" Orientation="Vertical">
Width="Auto" <TextBlock Style="{StaticResource TextBlockHeading}">Start Pop Out</TextBlock>
Margin="44,15,0,0" <Line
VerticalAlignment="Top" Stretch="Fill"
Orientation="Horizontal"> Stroke="Gray"
<WrapPanel> X2="1" />
<Label Content="Ctrl-Shift-" FontSize="14" /> <StackPanel
<ComboBox Margin="0"
Width="40" VerticalAlignment="Center"
VerticalAlignment="top" Orientation="Horizontal">
SelectedValue="{Binding AppSettingData.ApplicationSetting.KeyboardShortcutSetting.StartPopOutKeyBinding, Mode=TwoWay}" <TextBlock
SelectedValuePath="Tag"> Width="120"
<ComboBoxItem Content="A" Tag="A" /> Margin="0"
<ComboBoxItem Content="B" Tag="B" /> VerticalAlignment="Center"
<ComboBoxItem Content="C" Tag="C" /> FontSize="14"
<ComboBoxItem Content="D" Tag="D" /> Text="Keyboard Binding:" />
<ComboBoxItem Content="E" Tag="E" /> <TextBlock
<ComboBoxItem Content="F" Tag="F" /> x:Name="TextBlockStartPopOutKeyBinding"
<ComboBoxItem Content="G" Tag="G" /> Margin="0"
<ComboBoxItem Content="H" Tag="H" /> VerticalAlignment="Center"
<ComboBoxItem Content="I" Tag="I" /> FontSize="14"
<ComboBoxItem Content="J" Tag="J" /> Text="{Binding AppSettingData.ApplicationSetting.KeyboardShortcutSetting.PopOutKeyboardBinding, Converter={StaticResource KeystrokeBindingsConverter}, ConverterParameter=' + '}"
<ComboBoxItem Content="K" Tag="K" /> Visibility="{c:Binding '!IsDetectingKeystroke'}" />
<ComboBoxItem Content="L" Tag="L" /> <TextBlock
<ComboBoxItem Content="M" Tag="M" /> x:Name="TextBlockDetectingStartPopOutKeyBinding"
<ComboBoxItem Content="N" Tag="N" /> Margin="0"
<ComboBoxItem Content="O" Tag="O" /> VerticalAlignment="Center"
<ComboBoxItem Content="P" Tag="P" /> FontSize="14"
<ComboBoxItem Content="Q" Tag="Q" /> Text="Scanning..."
<ComboBoxItem Content="R" Tag="R" /> Visibility="{c:Binding 'IsDetectingKeystroke'}" />
<ComboBoxItem Content="S" Tag="S" /> <Button
<ComboBoxItem Content="T" Tag="T" /> x:Name="BtnDetectStartPopOutKeyBinding"
<ComboBoxItem Content="U" Tag="U" /> Width="80"
<ComboBoxItem Content="V" Tag="V" /> Height="25"
<ComboBoxItem Content="W" Tag="W" /> Margin="10,0,0,0"
<ComboBoxItem Content="X" Tag="X" /> VerticalAlignment="Center"
<ComboBoxItem Content="Y" Tag="Y" /> Command="{Binding DetectStartPopOutKeyBindingCommand}"
<ComboBoxItem Content="Z" Tag="Z" /> Style="{StaticResource MaterialDesignOutlinedButton}">
</ComboBox> Detect
</WrapPanel> </Button>
<TextBlock </StackPanel>
Width="600" </WrapPanel>
Margin="10,3,0,0"
Style="{StaticResource TextBlockLabel}">
Configure key binding to initiate start pop out.
</TextBlock>
</StackPanel>
</WrapPanel> </WrapPanel>
</WrapPanel> </WrapPanel>
</WrapPanel> </WrapPanel>

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 public partial class PreferenceDrawer
{ {
private readonly PreferenceDrawerViewModel _viewModel;
public PreferenceDrawer() public PreferenceDrawer()
{ {
InitializeComponent(); 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> <RootNamespace>MSFSPopoutPanelManager.MainApp</RootNamespace>
<ApplicationIcon>logo.ico</ApplicationIcon> <ApplicationIcon>logo.ico</ApplicationIcon>
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
<Version>4.1.0.2</Version> <Version>4.1.0.3</Version>
<AssemblyVersion>4.1.0.2</AssemblyVersion> <AssemblyVersion>4.1.0.3</AssemblyVersion>
<FileVersion>4.1.0.2</FileVersion> <FileVersion>4.1.0.3</FileVersion>
<DebugType>embedded</DebugType> <DebugType>embedded</DebugType>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<!-- Publishing options --> <!-- Publishing options -->

View file

@ -13,6 +13,7 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
{ {
private readonly PanelSourceOrchestrator _panelSourceOrchestrator; private readonly PanelSourceOrchestrator _panelSourceOrchestrator;
private readonly PanelConfigurationOrchestrator _panelConfigurationOrchestrator; private readonly PanelConfigurationOrchestrator _panelConfigurationOrchestrator;
private readonly KeyboardOrchestrator _keyboardOrchestrator;
public PanelConfig DataItem { get; set; } public PanelConfig DataItem { get; set; }
@ -30,10 +31,11 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
public DelegateCommand<string> PanelAttributeUpdatedCommand { get; set; } 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; _panelSourceOrchestrator = panelSourceOrchestrator;
_panelConfigurationOrchestrator = panelConfigurationOrchestrator; _panelConfigurationOrchestrator = panelConfigurationOrchestrator;
_keyboardOrchestrator = keyboardOrchestrator;
DataItem = new PanelConfig(); DataItem = new PanelConfig();
@ -113,20 +115,15 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
{ {
ActiveProfile.CurrentMoveResizePanelId = DataItem.Id; ActiveProfile.CurrentMoveResizePanelId = DataItem.Id;
if (!AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled) InputHookManager.StartKeyboardHook();
InputHookManager.StartKeyboardHook("KeyboardShortcut");
InputHookManager.OnKeyUp -= HandleKeyUpEvent; InputHookManager.OnKeyUp -= HandleKeyUpEvent;
InputHookManager.OnKeyUp += HandleKeyUpEvent; InputHookManager.OnKeyUp += HandleKeyUpEvent;
} }
else else
{ {
ActiveProfile.CurrentMoveResizePanelId = Guid.Empty; ActiveProfile.CurrentMoveResizePanelId = Guid.Empty;
if (!AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled)
InputHookManager.EndKeyboardHook("KeyboardShortcut");
InputHookManager.OnKeyUp -= HandleKeyUpEvent; 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.EndConfiguration();
_panelConfigurationOrchestrator.EndTouchHook(); _panelConfigurationOrchestrator.EndTouchHook();
InputHookManager.EndKeyboardHookForced(); InputHookManager.EndKeyboardHook();
_keyboardOrchestrator.EndGlobalKeyboardHookForced();
_flightSimOrchestrator.EndSimConnectServer(true); _flightSimOrchestrator.EndSimConnectServer(true);
} }

View file

@ -1,5 +1,4 @@
using MSFSPopoutPanelManager.WindowsAgent; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -10,7 +9,14 @@ namespace MSFSPopoutPanelManager.Orchestration
{ {
private GlobalKeyboardHook _globalKeyboardHook; 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) public KeyboardOrchestrator(SharedStorage sharedStorage) : base(sharedStorage)
{ {
} }
@ -19,48 +25,24 @@ namespace MSFSPopoutPanelManager.Orchestration
{ {
if (AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled) if (AppSettingData.ApplicationSetting.KeyboardShortcutSetting.IsEnabled)
{ {
InputHookManager.StartKeyboardHook("KeyboardShortcut"); StartGlobalKeyboardHook(KeyboardHookClientType.StartPopOutKeyboardShortcut);
InputHookManager.OnKeyUp -= HandleShortcutKeyboardHookKeyUpEvent;
InputHookManager.OnKeyUp += HandleShortcutKeyboardHookKeyUpEvent;
} }
AppSettingData.ApplicationSetting.OnIsUsedKeyboardShortcutChanged += (_, e) => AppSettingData.ApplicationSetting.OnIsUsedKeyboardShortcutChanged += (_, e) =>
{ {
if (e) if (e)
{ StartGlobalKeyboardHook(KeyboardHookClientType.StartPopOutKeyboardShortcut);
InputHookManager.StartKeyboardHook("KeyboardShortcut");
InputHookManager.OnKeyUp -= HandleShortcutKeyboardHookKeyUpEvent;
InputHookManager.OnKeyUp += HandleShortcutKeyboardHookKeyUpEvent;
}
else else
{ EndGlobalKeyboardHook(KeyboardHookClientType.StartPopOutKeyboardShortcut);
InputHookManager.EndKeyboardHook("KeyboardShortcut");
InputHookManager.OnKeyUp -= HandleShortcutKeyboardHookKeyUpEvent;
}
}; };
} }
public async void HandleShortcutKeyboardHookKeyUpEvent(object sender, KeyUpEventArgs e)
public void StartGlobalKeyboardHook(KeyboardHookClientType clientType, Guid? panelId = null)
{ {
// Start pop out if(!_keyboardHookClients.Exists(x => x == clientType))
if (e.IsHoldControl && e.IsHoldShift && e.KeyCode.ToUpper() == _keyboardHookClients.Add(clientType);
AppSettingData.ApplicationSetting.KeyboardShortcutSetting.StartPopOutKeyBinding)
{
//await _panelPopOutOrchestrator.ManualPopOut();
return;
}
}
_clientType = clientType;
private List<string> _keyPressCaptureList = new();
public event EventHandler<DetectKeystrokeEventArg> OnKeystrokeDetected;
private bool _isCapturingKeyPress;
private Guid? _panelId;
public void StartGlobalKeyboardHook(Guid? panelId = null)
{
_isCapturingKeyPress = true; _isCapturingKeyPress = true;
_panelId = panelId; _panelId = panelId;
@ -73,18 +55,24 @@ namespace MSFSPopoutPanelManager.Orchestration
_globalKeyboardHook.KeyboardPressed += HandleGlobalKeyboardHookOnKeyboardPressed; _globalKeyboardHook.KeyboardPressed += HandleGlobalKeyboardHookOnKeyboardPressed;
} }
public void EndGlobalKeyboardHook() public void EndGlobalKeyboardHook(KeyboardHookClientType clientType)
{ {
if (_globalKeyboardHook == null) _keyboardHookClients.Remove(clientType);
if (_globalKeyboardHook == null || _keyboardHookClients.Count > 0)
return; return;
Debug.WriteLine("Ends Global Keyboard Hook"); EndGlobalKeyboardHookForced();
}
public void EndGlobalKeyboardHookForced()
{
Debug.WriteLine("Ends Global Keyboard Hook (Forced)");
_keyPressCaptureList = new List<string>(); _keyPressCaptureList = new List<string>();
_globalKeyboardHook.KeyboardPressed -= HandleGlobalKeyboardHookOnKeyboardPressed; _globalKeyboardHook.KeyboardPressed -= HandleGlobalKeyboardHookOnKeyboardPressed;
_globalKeyboardHook?.Dispose(); _globalKeyboardHook?.Dispose();
_globalKeyboardHook = null; _globalKeyboardHook = null;
} }
private void HandleGlobalKeyboardHookOnKeyboardPressed(object sender, GlobalKeyboardHookEventArgs e) private void HandleGlobalKeyboardHookOnKeyboardPressed(object sender, GlobalKeyboardHookEventArgs e)
{ {
@ -99,14 +87,43 @@ namespace MSFSPopoutPanelManager.Orchestration
_isCapturingKeyPress = false; _isCapturingKeyPress = false;
var keyBinding = string.Join("|", _keyPressCaptureList.DistinctBy(x => x).OrderBy(x => x).ToArray().Select(x => x)); 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; _panelId = null;
_keyPressCaptureList.Clear(); _keyPressCaptureList.Clear();
break; 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 public class DetectKeystrokeEventArg : EventArgs
@ -115,4 +132,15 @@ namespace MSFSPopoutPanelManager.Orchestration
public string KeyBinding { get; set; } 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> <PackageProjectUrl>https://github.com/hawkeye-stan/msfs-popout-panel-manager</PackageProjectUrl>
<RootNamespace>MSFSPopoutPanelManager.Orchestration</RootNamespace> <RootNamespace>MSFSPopoutPanelManager.Orchestration</RootNamespace>
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
<Version>4.1.0.2</Version> <Version>4.1.0.3</Version>
<AssemblyVersion>4.1.0.2</AssemblyVersion> <AssemblyVersion>4.1.0.3</AssemblyVersion>
<FileVersion>4.1.0.2</FileVersion> <FileVersion>4.1.0.3</FileVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <RuntimeIdentifier>win-x64</RuntimeIdentifier>
<DebugType>Embedded</DebugType> <DebugType>Embedded</DebugType>
<Configurations>Debug;Release;Local</Configurations> <Configurations>Debug;Release;Local</Configurations>

View file

@ -32,12 +32,18 @@ namespace MSFSPopoutPanelManager.Orchestration
_keyboardOrchestrator.OnKeystrokeDetected += (_, e) => _keyboardOrchestrator.OnKeystrokeDetected += (_, e) =>
{ {
if (ActiveProfile == null)
return;
var panel = ActiveProfile.PanelConfigs.FirstOrDefault(p => p.Id == e.PanelId); var panel = ActiveProfile.PanelConfigs.FirstOrDefault(p => p.Id == e.PanelId);
if (panel != null && panel.FloatingPanel.IsDetectingKeystroke) if (panel != null && panel.FloatingPanel.IsDetectingKeystroke)
{ {
panel.FloatingPanel.Binding = e.KeyBinding; panel.FloatingPanel.KeyboardBinding = e.KeyBinding;
panel.FloatingPanel.IsDetectingKeystroke = false; panel.FloatingPanel.IsDetectingKeystroke = false;
StopDetectKeystroke();
_keyboardOrchestrator.StartGlobalKeyboardHook(KeyboardHookClientType.FloatingPanel);
} }
else else
{ {
@ -51,9 +57,9 @@ namespace MSFSPopoutPanelManager.Orchestration
return; return;
if (e) if (e)
_keyboardOrchestrator.StartGlobalKeyboardHook(); _keyboardOrchestrator.StartGlobalKeyboardHook(KeyboardHookClientType.FloatingPanel);
else else
_keyboardOrchestrator.EndGlobalKeyboardHook(); _keyboardOrchestrator.EndGlobalKeyboardHook(KeyboardHookClientType.FloatingPanel);
}; };
ProfileData.OnActiveProfileChanged += (_, _) => ProfileData.OnActiveProfileChanged += (_, _) =>
@ -62,7 +68,7 @@ namespace MSFSPopoutPanelManager.Orchestration
return; return;
if (ActiveProfile.PanelConfigs.Any(x => x.FloatingPanel.IsEnabled)) 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) 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()) if (!panels.Any())
return; return;
@ -233,12 +239,12 @@ namespace MSFSPopoutPanelManager.Orchestration
if (panel != null) if (panel != null)
panel.FloatingPanel.IsDetectingKeystroke = true; 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_HOME_COCKPIT_MODE = 8;
private const int CAMERA_VIEW_CUSTOM_CAMERA = 7; private const int CAMERA_VIEW_CUSTOM_CAMERA = 7;
private bool _isPopOutExecuting = false;
private readonly FlightSimOrchestrator _flightSimOrchestrator; private readonly FlightSimOrchestrator _flightSimOrchestrator;
private readonly PanelSourceOrchestrator _panelSourceOrchestrator; private readonly PanelSourceOrchestrator _panelSourceOrchestrator;
private readonly PanelConfigurationOrchestrator _panelConfigurationOrchestrator; 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; _flightSimOrchestrator = flightSimOrchestrator;
_panelSourceOrchestrator = panelSourceOrchestrator; _panelSourceOrchestrator = panelSourceOrchestrator;
_panelConfigurationOrchestrator = panelConfigurationOrchestrator; _panelConfigurationOrchestrator = panelConfigurationOrchestrator;
_keyboardOrchestrator = keyboardOrchestrator;
flightSimOrchestrator.OnFlightStarted += async (_, _) => flightSimOrchestrator.OnFlightStarted += async (_, _) =>
{ {
if (AppSettingData.ApplicationSetting.AutoPopOutSetting.IsEnabled) if (AppSettingData.ApplicationSetting.AutoPopOutSetting.IsEnabled)
await AutoPopOut(); await AutoPopOut();
}; };
_keyboardOrchestrator.OnKeystrokeDetected += (_, e) =>
{
if (e.KeyBinding == AppSetting.KeyboardShortcutSetting.PopOutKeyboardBinding && !ActiveProfile.IsDisabledStartPopOut)
ManualPopOut();
};
} }
private UserProfile ActiveProfile => ProfileData?.ActiveProfile; private UserProfile ActiveProfile => ProfileData?.ActiveProfile;
@ -56,6 +66,8 @@ namespace MSFSPopoutPanelManager.Orchestration
public async Task AutoPopOut() public async Task AutoPopOut()
{ {
_isPopOutExecuting = true;
await Application.Current.Dispatcher.Invoke(async () => await Application.Current.Dispatcher.Invoke(async () =>
{ {
ProfileData.AutoSwitchProfile(); 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. * 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. * 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. * Fixed few reported bugs in the application.

View file

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

View file

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

View file

@ -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. * 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. * 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. * Fixed few reported bugs in the application.

View file

@ -1,8 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Linq;
using WindowsHook; using WindowsHook;
namespace MSFSPopoutPanelManager.WindowsAgent namespace MSFSPopoutPanelManager.WindowsAgent
@ -17,8 +15,6 @@ namespace MSFSPopoutPanelManager.WindowsAgent
private static IKeyboardMouseEvents _keyboardHook; private static IKeyboardMouseEvents _keyboardHook;
public static event EventHandler<KeyUpEventArgs> OnKeyUp; public static event EventHandler<KeyUpEventArgs> OnKeyUp;
private static List<string> _keyboardHookSubscribers = new List<string>();
public static void StartMouseHook() public static void StartMouseHook()
{ {
if (_mouseHook == null) if (_mouseHook == null)
@ -55,12 +51,9 @@ namespace MSFSPopoutPanelManager.WindowsAgent
OnLeftClick?.Invoke(null, new Point(e.X, e.Y)); OnLeftClick?.Invoke(null, new Point(e.X, e.Y));
} }
public static void StartKeyboardHook(string subscriber) public static void StartKeyboardHook()
{ {
if(!_keyboardHookSubscribers.Contains(subscriber)) if (_keyboardHook == null)
_keyboardHookSubscribers.Add(subscriber);
if (_keyboardHook == null && _keyboardHookSubscribers.Count > 0)
{ {
Debug.WriteLine("Starting Keyboard Hook..."); 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)
if (_keyboardHook != null && _keyboardHookSubscribers.Count == 0)
{ {
Debug.WriteLine("Ending Keyboard Hook..."); Debug.WriteLine("Ending Keyboard Hook...");
_keyboardHook.KeyUp -= HandleKeyboardHookKeyUp; _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) private static void HandleKeyboardHookKeyUp(object sender, KeyEventArgs e)
{ {
OnKeyUp?.Invoke(null, new KeyUpEventArgs() { KeyCode = e.KeyCode.ToString(), IsHoldControl = e.Control, IsHoldShift = e.Shift }); 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: case PInvokeConstant.EVENT_OBJECT_STATECHANGE:
if (!ActiveProfile.IsLocked) if (!ActiveProfile.IsLocked)
{ {
if (panelConfig.FloatingPanel.IsEnabled && panelConfig.IsFloating) // do not update coordinate if floating window
return;
Thread.Sleep(300); Thread.Sleep(300);
UpdatePanelCoordinates(panelConfig); UpdatePanelCoordinates(panelConfig);
} }
@ -191,7 +188,10 @@ namespace MSFSPopoutPanelManager.WindowsAgent
panelConfig.PanelHandle = IntPtr.MaxValue; panelConfig.PanelHandle = IntPtr.MaxValue;
return; return;
} }
if (panelConfig.FloatingPanel.IsEnabled && panelConfig.IsFloating) // do not update coordinate if floating panel
return;
panelConfig.Left = rect.Left; panelConfig.Left = rect.Left;
panelConfig.Top = rect.Top; panelConfig.Top = rect.Top;

View file

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