diff --git a/DomainModel/Profile/FloatingPanel.cs b/DomainModel/Profile/FloatingPanel.cs index 80ec241..8c91a7a 100644 --- a/DomainModel/Profile/FloatingPanel.cs +++ b/DomainModel/Profile/FloatingPanel.cs @@ -1,15 +1,38 @@ -using MSFSPopoutPanelManager.Shared; +using System; +using MSFSPopoutPanelManager.Shared; using Newtonsoft.Json; namespace MSFSPopoutPanelManager.DomainModel.Profile { public class FloatingPanel : ObservableObject { + public FloatingPanel() + { + PropertyChanged += FloatingPanel_PropertyChanged; ; + } + + private void FloatingPanel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + var arg = e as PropertyChangedExtendedEventArgs; + + if (arg?.PropertyName != nameof(IsEnabled) || IsEnabled) + return; + + KeyboardBinding = null; + IsHiddenOnStart = false; + } + public bool IsEnabled { get; set; } public string KeyboardBinding { get; set; } + public bool IsHiddenOnStart { get; set; } + [JsonIgnore] public bool IsDetectingKeystroke { get; set; } + + + [JsonIgnore] + public bool HasKeyboardBinding => !string.IsNullOrEmpty(KeyboardBinding); } } diff --git a/DomainModel/Profile/PanelConfig.cs b/DomainModel/Profile/PanelConfig.cs index 681a7c3..26fe447 100644 --- a/DomainModel/Profile/PanelConfig.cs +++ b/DomainModel/Profile/PanelConfig.cs @@ -20,20 +20,15 @@ namespace MSFSPopoutPanelManager.DomainModel.Profile { var arg = e as PropertyChangedExtendedEventArgs; - if (arg.PropertyName == nameof(FullScreen) && FullScreen) + switch (arg?.PropertyName) { - AlwaysOnTop = false; - HideTitlebar = false; - } - else if (arg.PropertyName == nameof(TouchEnabled) && TouchEnabled) - { - AutoGameRefocus = true; - } - else if (arg.ObjectName == QualifyFullName.Of(nameof(MSFSPopoutPanelManager.DomainModel.Profile.FloatingPanel)) && - arg.PropertyName == nameof(FloatingPanel.IsEnabled)) - { - if (!FloatingPanel.IsEnabled) - FloatingPanel.KeyboardBinding = null; + case nameof(FullScreen) when FullScreen: + AlwaysOnTop = false; + HideTitlebar = false; + break; + case nameof(TouchEnabled) when TouchEnabled: + AutoGameRefocus = true; + break; } } diff --git a/DomainModel/Profile/PanelConfigItem.cs b/DomainModel/Profile/PanelConfigItem.cs index 6f5bd56..f0daa9e 100644 --- a/DomainModel/Profile/PanelConfigItem.cs +++ b/DomainModel/Profile/PanelConfigItem.cs @@ -22,7 +22,7 @@ namespace MSFSPopoutPanelManager.DomainModel.Profile TouchEnabled, AutoGameRefocus, AllowFloatPanel, - FloatPanelKeyBinding, + IsHiddenOnStart, None } } diff --git a/MainApp/AppUserControl/PopOutPanelConfigCard.xaml b/MainApp/AppUserControl/PopOutPanelConfigCard.xaml index 5992aff..66c7a3f 100644 --- a/MainApp/AppUserControl/PopOutPanelConfigCard.xaml +++ b/MainApp/AppUserControl/PopOutPanelConfigCard.xaml @@ -377,6 +377,25 @@ Style="{StaticResource MaterialDesignOutlinedButton}"> Detect + + + + Hide on Start + + diff --git a/MainApp/AppUserControl/ProfileCard.xaml b/MainApp/AppUserControl/ProfileCard.xaml index bfa61a4..954dce7 100644 --- a/MainApp/AppUserControl/ProfileCard.xaml +++ b/MainApp/AppUserControl/ProfileCard.xaml @@ -6,7 +6,6 @@ xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:domain="clr-namespace:MSFSPopoutPanelManager.DomainModel.Profile;assembly=DomainModel" - xmlns:local="clr-namespace:MSFSPopoutPanelManager.MainApp" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:system="clr-namespace:System;assembly=mscorlib" diff --git a/Orchestration/PanelPopOutOrchestrator.cs b/Orchestration/PanelPopOutOrchestrator.cs index aa3120b..dfc5b90 100644 --- a/Orchestration/PanelPopOutOrchestrator.cs +++ b/Orchestration/PanelPopOutOrchestrator.cs @@ -367,11 +367,8 @@ namespace MSFSPopoutPanelManager.Orchestration panelConfig.PanelHandle = IntPtr.Zero; } - if (ActiveProfile.PanelConfigs.Any(p => p.PanelType == PanelType.BuiltInPopout && p.IsPopOutSuccess != null && !(bool)p.IsPopOutSuccess) || - ActiveProfile.PanelConfigs.Count(p => p.PanelType == PanelType.BuiltInPopout) == 0) - return false; - else - return true; + return !ActiveProfile.PanelConfigs.Any(p => p.PanelType == PanelType.BuiltInPopout && p.IsPopOutSuccess != null && !(bool)p.IsPopOutSuccess) && + ActiveProfile.PanelConfigs.Count(p => p.PanelType == PanelType.BuiltInPopout) != 0; }); } } @@ -547,6 +544,12 @@ namespace MSFSPopoutPanelManager.Orchestration InputEmulationManager.ToggleFullScreenPanel(panel.PanelHandle); Thread.Sleep(250); } + + if (panel.FloatingPanel.IsEnabled && panel.FloatingPanel.HasKeyboardBinding && panel.FloatingPanel.IsHiddenOnStart) + { + panel.IsFloating = false; + WindowActionManager.MinimizeWindow(panel.PanelHandle); + } } private void ReturnToAfterPopOutCameraView()