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

Update switch window

This commit is contained in:
hawkeye 2024-09-17 10:42:07 -04:00
parent 06f0636c83
commit a7c995922b
24 changed files with 330 additions and 31 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.1.0</Version> <Version>4.1.2.0</Version>
<AssemblyVersion>4.1.1.0</AssemblyVersion> <AssemblyVersion>4.1.2.0</AssemblyVersion>
<FileVersion>4.1.1.0</FileVersion> <FileVersion>4.1.2.0</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

@ -94,11 +94,11 @@ namespace MSFSPopoutPanelManager.DomainModel.Profile
[JsonIgnore] [JsonIgnore]
public bool IsDeletablePanel => PanelType != PanelType.HudBarWindow && PanelType != PanelType.RefocusDisplay && public bool IsDeletablePanel => PanelType != PanelType.HudBarWindow && PanelType != PanelType.RefocusDisplay &&
PanelType != PanelType.NumPadWindow; PanelType != PanelType.NumPadWindow && PanelType != PanelType.SwitchWindow;
[JsonIgnore] [JsonIgnore]
public bool IsTouchEnablePanel => PanelType != PanelType.HudBarWindow && PanelType != PanelType.RefocusDisplay && public bool IsTouchEnablePanel => PanelType != PanelType.HudBarWindow && PanelType != PanelType.RefocusDisplay &&
PanelType != PanelType.NumPadWindow; PanelType != PanelType.NumPadWindow && PanelType != PanelType.SwitchWindow;
[JsonIgnore] [JsonIgnore]
public bool IsCustomPopOut => PanelType == PanelType.CustomPopout; public bool IsCustomPopOut => PanelType == PanelType.CustomPopout;
@ -116,6 +116,9 @@ namespace MSFSPopoutPanelManager.DomainModel.Profile
[JsonIgnore] [JsonIgnore]
public bool IsNumPadWindow => PanelType == PanelType.NumPadWindow; public bool IsNumPadWindow => PanelType == PanelType.NumPadWindow;
[JsonIgnore]
public bool IsSwitchWindow => PanelType == PanelType.SwitchWindow;
[JsonIgnore] [JsonIgnore]
public string PanelSourceCoordinateText public string PanelSourceCoordinateText
{ {

View file

@ -12,6 +12,7 @@
StatusMessageWindow = 7, StatusMessageWindow = 7,
RefocusDisplay = 8, RefocusDisplay = 8,
NumPadWindow = 9, NumPadWindow = 9,
SwitchWindow = 20,
Unknown = 100 Unknown = 100
} }
} }

View file

@ -18,5 +18,7 @@ namespace MSFSPopoutPanelManager.DomainModel.Profile
public RefocusOnDisplay RefocusOnDisplay { get; set; } = new(); public RefocusOnDisplay RefocusOnDisplay { get; set; } = new();
public NumPadConfig NumPadConfig { get; set; } = new(); public NumPadConfig NumPadConfig { get; set; } = new();
public SwitchWindowConfig SwitchWindowConfig { get; set; } = new();
} }
} }

View file

@ -0,0 +1,9 @@
using MSFSPopoutPanelManager.Shared;
namespace MSFSPopoutPanelManager.DomainModel.Profile
{
public class SwitchWindowConfig : ObservableObject
{
public bool IsEnabled { get; set; } = false;
}
}

View file

@ -82,6 +82,7 @@ namespace MSFSPopoutPanelManager.MainApp
services.AddTransient(s => new MessageWindowViewModel(SharedStorage, s.GetRequiredService<PanelSourceOrchestrator>(), s.GetRequiredService<PanelPopOutOrchestrator>())); services.AddTransient(s => new MessageWindowViewModel(SharedStorage, s.GetRequiredService<PanelSourceOrchestrator>(), s.GetRequiredService<PanelPopOutOrchestrator>()));
services.AddTransient(s => new HudBarViewModel(SharedStorage, s.GetRequiredService<FlightSimOrchestrator>())); services.AddTransient(s => new HudBarViewModel(SharedStorage, s.GetRequiredService<FlightSimOrchestrator>()));
services.AddTransient(_ => new NumPadViewModel(SharedStorage)); services.AddTransient(_ => new NumPadViewModel(SharedStorage));
services.AddTransient(_ => new SwitchWindowViewModel(SharedStorage));
}).Build(); }).Build();

View file

@ -224,7 +224,7 @@
x:Name="StackPanelAdjustment" x:Name="StackPanelAdjustment"
Width="440" Width="440"
Orientation="Horizontal" Orientation="Horizontal"
Visibility="{c:Binding 'DataItem.IsBuiltInPopOut or DataItem.IsHudBarWindow or DataItem.IsNumPadWindow or (DataItem.IsCustomPopOut and DataItem.PanelSource.X != null)'}"> Visibility="{c:Binding 'DataItem.IsBuiltInPopOut or DataItem.IsHudBarWindow or DataItem.IsNumPadWindow or DataItem.IsSwitchWindow or (DataItem.IsCustomPopOut and DataItem.PanelSource.X != null)'}">
<popOutPanelCard:PanelConfigField <popOutPanelCard:PanelConfigField
Margin="20,0,0,0" Margin="20,0,0,0"
BindingPath="Top" BindingPath="Top"

View file

@ -256,6 +256,7 @@
<TextBlock Style="{StaticResource TxtBlockDisableWhenLocked}" ToolTip="Add in-game menu bar panels such as VFR Map, Checklist, ATC, etc. to profile to enable panel size and location management and touch support">Include in-game menu bar panels for pop out management and touch screen support</TextBlock> <TextBlock Style="{StaticResource TxtBlockDisableWhenLocked}" ToolTip="Add in-game menu bar panels such as VFR Map, Checklist, ATC, etc. to profile to enable panel size and location management and touch support">Include in-game menu bar panels for pop out management and touch screen support</TextBlock>
</WrapPanel> </WrapPanel>
<WrapPanel Margin="0,8,0,0"> <WrapPanel Margin="0,8,0,0">
<ToggleButton <ToggleButton
IsChecked="{Binding ActiveProfile.ProfileSetting.NumPadConfig.IsEnabled, Mode=TwoWay, NotifyOnTargetUpdated=True}" IsChecked="{Binding ActiveProfile.ProfileSetting.NumPadConfig.IsEnabled, Mode=TwoWay, NotifyOnTargetUpdated=True}"
@ -266,6 +267,16 @@
<TextBlock Style="{StaticResource TxtBlockDisableWhenLocked}" ToolTip="Add a virtual keyboard NumPad to the game that has MSFS focused before sending key command">Add a virtual keyboard NumPad</TextBlock> <TextBlock Style="{StaticResource TxtBlockDisableWhenLocked}" ToolTip="Add a virtual keyboard NumPad to the game that has MSFS focused before sending key command">Add a virtual keyboard NumPad</TextBlock>
</WrapPanel> </WrapPanel>
<WrapPanel Name="wrapPanelSwitchWindow" Margin="0,8,0,0">
<ToggleButton
IsChecked="{Binding ActiveProfile.ProfileSetting.SwitchWindowConfig.IsEnabled, Mode=TwoWay, NotifyOnTargetUpdated=True}"
IsHitTestVisible="{c:Binding '!ActiveProfile.IsLocked',
Mode=OneWay}"
Style="{StaticResource ToggleButton}"
TargetUpdated="AddSwitchWindow_TargetUpdated" />
<TextBlock Style="{StaticResource TxtBlockDisableWhenLocked}" ToolTip="Add a switch window command bar to the game">Add a switch window command bar</TextBlock>
</WrapPanel>
<StackPanel Margin="0,8,0,0" Orientation="Horizontal"> <StackPanel Margin="0,8,0,0" Orientation="Horizontal">
<WrapPanel> <WrapPanel>
<ToggleButton <ToggleButton

View file

@ -23,6 +23,12 @@ namespace MSFSPopoutPanelManager.MainApp.AppUserControl
_viewModel = App.AppHost.Services.GetRequiredService<ProfileCardViewModel>(); _viewModel = App.AppHost.Services.GetRequiredService<ProfileCardViewModel>();
Loaded += (_, _) => { DataContext = _viewModel; }; Loaded += (_, _) => { DataContext = _viewModel; };
#if LOCAL
this.wrapPanelSwitchWindow.Visibility = Visibility.Visible;
#else
this.wrapPanelSwitchWindow.Visibility = Visibility.Collapsed;
#endif
} }
private void ToggleButtonEditProfileTitle_Click(object sender, RoutedEventArgs e) private void ToggleButtonEditProfileTitle_Click(object sender, RoutedEventArgs e)
@ -46,22 +52,27 @@ namespace MSFSPopoutPanelManager.MainApp.AppUserControl
private void IncludeInGamePanel_TargetUpdated(object sender, DataTransferEventArgs e) private void IncludeInGamePanel_TargetUpdated(object sender, DataTransferEventArgs e)
{ {
_viewModel.IncludeInGamePanelUpdatedCommand.Execute(null); _viewModel.IncludeInGamePanelUpdatedCommand?.Execute(null);
} }
private void AddHudBar_TargetUpdated(object sender, DataTransferEventArgs e) private void AddHudBar_TargetUpdated(object sender, DataTransferEventArgs e)
{ {
_viewModel.AddHudBarUpdatedCommand.Execute(null); _viewModel.AddHudBarUpdatedCommand?.Execute(null);
} }
private void AddRefocusDisplay_TargetUpdated(object sender, DataTransferEventArgs e) private void AddRefocusDisplay_TargetUpdated(object sender, DataTransferEventArgs e)
{ {
_viewModel.RefocusDisplayUpdatedCommand.Execute(null); _viewModel.RefocusDisplayUpdatedCommand?.Execute(null);
} }
private void AddNumPad_TargetUpdated(object sender, DataTransferEventArgs e) private void AddNumPad_TargetUpdated(object sender, DataTransferEventArgs e)
{ {
_viewModel.AddNumPadUpdatedCommand.Execute(null); _viewModel.AddNumPadUpdatedCommand?.Execute(null);
}
private void AddSwitchWindow_TargetUpdated(object sender, DataTransferEventArgs e)
{
_viewModel.AddSwitchWindowUpdatedCommand?.Execute(null);
} }
} }

View file

@ -0,0 +1,69 @@
<Window
x:Class="MSFSPopoutPanelManager.MainApp.AppWindow.SwitchWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
xmlns:viewmodel="clr-namespace:MSFSPopoutPanelManager.MainApp.ViewModel"
Title="Switch Window"
Height="60"
MinHeight="60"
ResizeMode="NoResize"
WindowStyle="None"
mc:Ignorable="d">
<Window.Resources>
<system:Double x:Key="IconSize">28</system:Double>
</Window.Resources>
<materialDesign:ColorZone
Height="60"
BorderBrush="White"
BorderThickness="1"
Mode="Dark">
<Grid Margin="10,0" d:DataContext="{d:DesignInstance viewmodel:SwitchWindowViewModel}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<WrapPanel Grid.Column="0" VerticalAlignment="Center">
<Button
Width="Auto"
Height="Auto"
Margin="5,0"
Command="{Binding ButtonCommand}"
CommandParameter="VerticalPanel"
Content="Main"
FontSize="28"
Foreground="White"
Style="{StaticResource MaterialDesignOutlinedButton}" />
<Button
Width="Auto"
Height="Auto"
Margin="5,0"
Command="{Binding ButtonCommand}"
CommandParameter="OverheadPanel"
Content="Overhead"
FontSize="28"
Foreground="White"
Style="{StaticResource MaterialDesignOutlinedButton}" />
</WrapPanel>
<WrapPanel
Grid.Column="1"
Margin="0,0,0,0"
VerticalAlignment="Center">
<Button
x:Name="BtnClose"
Width="{StaticResource IconSize}"
Height="{StaticResource IconSize}"
Margin="0,0,0,0"
Click="BtnClose_Click"
Foreground="White"
Style="{StaticResource MaterialDesignIconButton}"
ToolTip="Close application">
<materialDesign:PackIcon Kind="Close" />
</Button>
</WrapPanel>
</Grid>
</materialDesign:ColorZone>
</Window>

View file

@ -0,0 +1,65 @@
using Microsoft.Extensions.DependencyInjection;
using MSFSPopoutPanelManager.MainApp.ViewModel;
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
namespace MSFSPopoutPanelManager.MainApp.AppWindow
{
/// <summary>
/// Interaction logic for SwitchWindow.xaml
/// </summary>
public partial class SwitchWindow : Window
{
private readonly SwitchWindowViewModel _viewModel;
public SwitchWindow(Guid panelId, int initialWidth, int initialHeight)
{
InitializeComponent();
if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
return;
_viewModel = App.AppHost.Services.GetRequiredService<SwitchWindowViewModel>();
_viewModel.PanelId = panelId;
Loaded += (_, _) =>
{
DataContext = _viewModel;
var window = Window.GetWindow(this);
if (window == null)
throw new ApplicationException("Unable to instantiate switchWindow window");
_viewModel.PanelConfig.PanelHandle = new WindowInteropHelper(window).Handle;
if (initialWidth == 0 && initialHeight == 0)
{
this.Width = 410;
this.Height = 75;
_viewModel.PanelConfig.Width = Convert.ToInt16(this.Width);
_viewModel.PanelConfig.Height = Convert.ToInt32(this.Height);
}
else
{
this.Width = initialWidth;
this.Height = initialHeight;
}
};
this.MouseLeftButtonDown += SwitchWindow_MouseLeftButtonDown;
this.Topmost = true;
}
private void SwitchWindow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
private void BtnClose_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

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.1.0</Version> <Version>4.1.2.0</Version>
<AssemblyVersion>4.1.1.0</AssemblyVersion> <AssemblyVersion>4.1.2.0</AssemblyVersion>
<FileVersion>4.1.1.0</FileVersion> <FileVersion>4.1.2.0</FileVersion>
<DebugType>embedded</DebugType> <DebugType>embedded</DebugType>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<!-- Publishing options --> <!-- Publishing options -->

View file

@ -25,7 +25,7 @@
Kind="ChevronDown" Kind="ChevronDown"
Opacity="0.5" Opacity="0.5"
RenderTransformOrigin="0.5 0.5" RenderTransformOrigin="0.5 0.5"
Visibility="{c:Binding '!DataItem.IsHudBarWindow and !DataItem.IsRefocusDisplay and !DataItem.IsNumPadWindow and !ActiveProfile.IsEditingPanelSource'}"> Visibility="{c:Binding '!DataItem.IsHudBarWindow and !DataItem.IsRefocusDisplay and !DataItem.IsNumPadWindow and !DataItem.IsSwitchWindow and !ActiveProfile.IsEditingPanelSource'}">
<wpf:PackIcon.RenderTransform> <wpf:PackIcon.RenderTransform>
<RotateTransform x:Name="ExpandPathRotateTransform" /> <RotateTransform x:Name="ExpandPathRotateTransform" />
</wpf:PackIcon.RenderTransform> </wpf:PackIcon.RenderTransform>

View file

@ -36,6 +36,9 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
panelPopOutOrchestrator.OnNumPadOpened -= HandleOnNumPadOpened; panelPopOutOrchestrator.OnNumPadOpened -= HandleOnNumPadOpened;
panelPopOutOrchestrator.OnNumPadOpened += HandleOnNumPadOpened; panelPopOutOrchestrator.OnNumPadOpened += HandleOnNumPadOpened;
panelPopOutOrchestrator.OnSwitchWindowOpened -= HandleOnSwitchWindowOpened;
panelPopOutOrchestrator.OnSwitchWindowOpened += HandleOnSwitchWindowOpened;
} }
private void HandleShowOverlay(object sender, PanelConfig panelConfig) private void HandleShowOverlay(object sender, PanelConfig panelConfig)
@ -99,6 +102,22 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
}); });
} }
private void HandleOnSwitchWindowOpened(object sender, PanelConfig panelConfig)
{
Application.Current.Dispatcher.Invoke(async () =>
{
var switchWindow = new SwitchWindow(panelConfig.Id, panelConfig.Width, panelConfig.Height);
switchWindow.Show();
await Task.Run(() =>
{
Thread.Sleep(1000);
WindowActionManager.MoveWindow(panelConfig.PanelHandle, panelConfig.Left, panelConfig.Top, panelConfig.Width, panelConfig.Height);
WindowActionManager.MoveWindow(panelConfig.PanelHandle, panelConfig.Left, panelConfig.Top, panelConfig.Width, panelConfig.Height);
});
});
}
private void HandleOnPopOutStarted(object sender, EventArgs e) private void HandleOnPopOutStarted(object sender, EventArgs e)
{ {
if (!AppSettingData.ApplicationSetting.PopOutSetting.MinimizeDuringPopOut) if (!AppSettingData.ApplicationSetting.PopOutSetting.MinimizeDuringPopOut)

View file

@ -41,6 +41,8 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
public ICommand AddNumPadUpdatedCommand { get; } public ICommand AddNumPadUpdatedCommand { get; }
public ICommand AddSwitchWindowUpdatedCommand { get; }
public ICommand RefocusDisplayRefreshedCommand { get; } public ICommand RefocusDisplayRefreshedCommand { get; }
public DelegateCommand<string> RefocusDisplaySelectionUpdatedCommand { get; } public DelegateCommand<string> RefocusDisplaySelectionUpdatedCommand { get; }
@ -100,7 +102,9 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
AddHudBarUpdatedCommand = new DelegateCommand(OnAddHudBarUpdated); AddHudBarUpdatedCommand = new DelegateCommand(OnAddHudBarUpdated);
AddNumPadUpdatedCommand = new DelegateCommand(OnAddNumPadUpdated); AddNumPadUpdatedCommand = new DelegateCommand(OnAddNumPadUpdated);
#if LOCAL
AddSwitchWindowUpdatedCommand = new DelegateCommand(OnAddSwitchWindowUpdated);
#endif
RefocusDisplayUpdatedCommand = new DelegateCommand(OnRefocusDisplayUpdated); RefocusDisplayUpdatedCommand = new DelegateCommand(OnRefocusDisplayUpdated);
RefocusDisplayRefreshedCommand = new DelegateCommand(OnRefocusDisplayRefreshed); RefocusDisplayRefreshedCommand = new DelegateCommand(OnRefocusDisplayRefreshed);
@ -239,6 +243,35 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
} }
} }
private void OnAddSwitchWindowUpdated()
{
if (ActiveProfile == null)
return;
if (ActiveProfile.ProfileSetting.SwitchWindowConfig.IsEnabled)
{
if (ActiveProfile.PanelConfigs.Any(p => p.PanelType == PanelType.SwitchWindow))
return;
ActiveProfile.PanelConfigs.Add(new PanelConfig
{
PanelName = "Switch Window",
PanelType = PanelType.SwitchWindow,
Left = 0,
Top = 0,
Width = 0,
Height = 0,
AutoGameRefocus = false
});
}
else
{
ActiveProfile.PanelConfigs.RemoveAll(p => p.PanelType == PanelType.SwitchWindow);
}
}
private void OnRefocusDisplayUpdated() private void OnRefocusDisplayUpdated()
{ {
if (ActiveProfile == null) if (ActiveProfile == null)

View file

@ -0,0 +1,37 @@
using System;
using System.Linq;
using MSFSPopoutPanelManager.DomainModel.Profile;
using MSFSPopoutPanelManager.Orchestration;
using MSFSPopoutPanelManager.WindowsAgent;
using Prism.Commands;
namespace MSFSPopoutPanelManager.MainApp.ViewModel
{
public class SwitchWindowViewModel : BaseViewModel
{
public DelegateCommand<string> ButtonCommand { get; private set; }
public Guid PanelId { get; set; }
public PanelConfig PanelConfig => ActiveProfile.PanelConfigs.FirstOrDefault(p => p.Id == PanelId);
public SwitchWindowViewModel(SharedStorage sharedStorage) : base(sharedStorage)
{
ButtonCommand = new DelegateCommand<string>(OnButtonActivated);
}
private void OnButtonActivated(string commandParameter)
{
switch (commandParameter)
{
case "VerticalPanel":
PInvoke.SwitchToThisWindow(PInvoke.GetWindowHandle("737 Instruments Vertical"), true);
break;
case "OverheadPanel":
PInvoke.SwitchToThisWindow(PInvoke.GetWindowHandle("737 Instruments Overhead"), true);
break;
}
}
}
}

View file

@ -133,7 +133,7 @@ namespace MSFSPopoutPanelManager.Orchestration
if (!FlightSimData.IsFlightStarted || !FlightSimData.IsInCockpit) if (!FlightSimData.IsFlightStarted || !FlightSimData.IsInCockpit)
return; return;
if (DateTime.Now - _lastLodUpdateTime <= TimeSpan.FromSeconds(1)) if (DateTime.Now - _lastLodUpdateTime <= TimeSpan.FromSeconds(3))
return; return;
var deltaFps = DynamicLodSimData.Fps - DynamicLodSetting.TargetedFps; var deltaFps = DynamicLodSimData.Fps - DynamicLodSetting.TargetedFps;
@ -239,7 +239,7 @@ namespace MSFSPopoutPanelManager.Orchestration
private void SetTlod(int deltaFps) private void SetTlod(int deltaFps)
{ {
var tlodStep = Math.Max(5, Math.Abs(deltaFps / 2)); var tlodStep = Math.Max(10, Math.Abs(deltaFps / 2));
var newTlod = DynamicLodSimData.Tlod + Math.Sign(deltaFps) * tlodStep; var newTlod = DynamicLodSimData.Tlod + Math.Sign(deltaFps) * tlodStep;
if (DynamicLodSetting.TlodMinOnGround && DynamicLodSimData.AltAboveGround <= DynamicLodSetting.AltTlodBase) if (DynamicLodSetting.TlodMinOnGround && DynamicLodSimData.AltAboveGround <= DynamicLodSetting.AltTlodBase)

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.1.0</Version> <Version>4.1.2.0</Version>
<AssemblyVersion>4.1.1.0</AssemblyVersion> <AssemblyVersion>4.1.2.0</AssemblyVersion>
<FileVersion>4.1.1.0</FileVersion> <FileVersion>4.1.2.0</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

@ -50,6 +50,7 @@ namespace MSFSPopoutPanelManager.Orchestration
public event EventHandler OnPopOutCompleted; public event EventHandler OnPopOutCompleted;
public event EventHandler<PanelConfig> OnHudBarOpened; public event EventHandler<PanelConfig> OnHudBarOpened;
public event EventHandler<PanelConfig> OnNumPadOpened; public event EventHandler<PanelConfig> OnNumPadOpened;
public event EventHandler<PanelConfig> OnSwitchWindowOpened;
public async Task ManualPopOut() public async Task ManualPopOut()
{ {
@ -123,6 +124,8 @@ namespace MSFSPopoutPanelManager.Orchestration
StepAddNumPad(); StepAddNumPad();
StepAddSwitchWindow();
SetupRefocusDisplay(); SetupRefocusDisplay();
StepApplyPanelConfig(); StepApplyPanelConfig();
@ -390,6 +393,18 @@ namespace MSFSPopoutPanelManager.Orchestration
}); });
} }
private void StepAddSwitchWindow()
{
if (!ActiveProfile.ProfileSetting.SwitchWindowConfig.IsEnabled)
return;
WorkflowStepWithMessage.Execute("Opening Switch Window", () =>
{
var panelConfig = ActiveProfile.PanelConfigs.FirstOrDefault(p => p.PanelType == PanelType.SwitchWindow);
OnSwitchWindowOpened?.Invoke(this, panelConfig);
});
}
public void SetupRefocusDisplay() public void SetupRefocusDisplay()
{ {
if (!ActiveProfile.ProfileSetting.RefocusOnDisplay.IsEnabled) if (!ActiveProfile.ProfileSetting.RefocusOnDisplay.IsEnabled)

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.1.0</Version> <Version>4.1.2.0</Version>
<AssemblyVersion>4.1.1.0</AssemblyVersion> <AssemblyVersion>4.1.2.0</AssemblyVersion>
<FileVersion>4.1.1.0</FileVersion> <FileVersion>4.1.2.0</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.1.0</Version> <Version>4.1.2.0</Version>
<AssemblyVersion>4.1.1.0</AssemblyVersion> <AssemblyVersion>4.1.2.0</AssemblyVersion>
<FileVersion>4.1.1.0</FileVersion> <FileVersion>4.1.2.0</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

@ -143,6 +143,9 @@ namespace MSFSPopoutPanelManager.WindowsAgent
[DllImport("user32.dll", SetLastError = true)] [DllImport("user32.dll", SetLastError = true)]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll", SetLastError = true)]
public static extern void SwitchToThisWindow(IntPtr hWnd, bool turnOn);
[DllImport("user32.dll", SetLastError = true)] [DllImport("user32.dll", SetLastError = true)]
public static extern int UnhookWinEvent(IntPtr hWinEventHook); public static extern int UnhookWinEvent(IntPtr hWinEventHook);
@ -193,6 +196,23 @@ namespace MSFSPopoutPanelManager.WindowsAgent
return new Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top); return new Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top);
} }
public static IntPtr GetWindowHandle(string windowCaption)
{
IntPtr windowHandle = IntPtr.Zero;
EnumWindows((hwnd, _) =>
{
var caption = GetWindowText(hwnd);
if (caption == windowCaption)
windowHandle = hwnd;
return true;
}, 0);
return windowHandle;
}
} }
public struct RECT public struct RECT

View file

@ -182,6 +182,9 @@ namespace MSFSPopoutPanelManager.WindowsAgent
if (caption.IndexOf("Virtual NumPad", StringComparison.Ordinal) > -1) if (caption.IndexOf("Virtual NumPad", StringComparison.Ordinal) > -1)
return PanelType.NumPadWindow; return PanelType.NumPadWindow;
if (caption.IndexOf("Switch Window", StringComparison.Ordinal) > -1)
return PanelType.SwitchWindow;
return PanelType.PopOutManager; return PanelType.PopOutManager;
} }
@ -194,7 +197,7 @@ namespace MSFSPopoutPanelManager.WindowsAgent
{ {
var panelType = GetWindowPanelType(hwnd); var panelType = GetWindowPanelType(hwnd);
if (panelType == PanelType.CustomPopout || panelType == PanelType.HudBarWindow || panelType == PanelType.NumPadWindow) if (panelType == PanelType.CustomPopout || panelType == PanelType.HudBarWindow || panelType == PanelType.NumPadWindow || panelType == PanelType.SwitchWindow)
CloseWindow(hwnd); CloseWindow(hwnd);
return true; return true;

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.1.0</Version> <Version>4.1.2.0</Version>
<AssemblyVersion>4.1.1.0</AssemblyVersion> <AssemblyVersion>4.1.2.0</AssemblyVersion>
<FileVersion>4.1.1.0</FileVersion> <FileVersion>4.1.2.0</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>