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

Update code

This commit is contained in:
hawkeye 2024-09-17 17:33:23 -04:00
parent a7c995922b
commit 6cb154abe9
8 changed files with 47 additions and 42 deletions

View file

@ -8,7 +8,7 @@ namespace MSFSPopoutPanelManager.DomainModel.Profile
{ {
public FloatingPanel() public FloatingPanel()
{ {
PropertyChanged += FloatingPanel_PropertyChanged; ; PropertyChanged += FloatingPanel_PropertyChanged;
} }
private void FloatingPanel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) private void FloatingPanel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)

View file

@ -1,9 +1,19 @@
using MSFSPopoutPanelManager.Shared; using System.Collections.Generic;
using MSFSPopoutPanelManager.Shared;
namespace MSFSPopoutPanelManager.DomainModel.Profile namespace MSFSPopoutPanelManager.DomainModel.Profile
{ {
public class SwitchWindowConfig : ObservableObject public class SwitchWindowConfig : ObservableObject
{ {
public bool IsEnabled { get; set; } = false; public bool IsEnabled { get; set; } = false;
public List<SwitchWindowPanel> Panels { get; set; }
}
public class SwitchWindowPanel
{
public string DisplayName { get; set; }
public string PanelCaption { get; set; }
} }
} }

View file

@ -267,7 +267,7 @@
<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"> <WrapPanel Name="WrapPanelSwitchWindow" Margin="0,8,0,0">
<ToggleButton <ToggleButton
IsChecked="{Binding ActiveProfile.ProfileSetting.SwitchWindowConfig.IsEnabled, Mode=TwoWay, NotifyOnTargetUpdated=True}" IsChecked="{Binding ActiveProfile.ProfileSetting.SwitchWindowConfig.IsEnabled, Mode=TwoWay, NotifyOnTargetUpdated=True}"
IsHitTestVisible="{c:Binding '!ActiveProfile.IsLocked', IsHitTestVisible="{c:Binding '!ActiveProfile.IsLocked',

View file

@ -24,10 +24,10 @@ namespace MSFSPopoutPanelManager.MainApp.AppUserControl
_viewModel = App.AppHost.Services.GetRequiredService<ProfileCardViewModel>(); _viewModel = App.AppHost.Services.GetRequiredService<ProfileCardViewModel>();
Loaded += (_, _) => { DataContext = _viewModel; }; Loaded += (_, _) => { DataContext = _viewModel; };
#if LOCAL #if LOCAL || DEBUG
this.wrapPanelSwitchWindow.Visibility = Visibility.Visible; this.WrapPanelSwitchWindow.Visibility = Visibility.Visible;
#else #else
this.wrapPanelSwitchWindow.Visibility = Visibility.Collapsed; this.WrapPanelSwitchWindow.Visibility = Visibility.Collapsed;
#endif #endif
} }

View file

@ -26,27 +26,7 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="30" /> <ColumnDefinition Width="30" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<WrapPanel Grid.Column="0" VerticalAlignment="Center"> <WrapPanel Grid.Column="0" VerticalAlignment="Center" Name="WrapPanelCustomButtons">
<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>
<WrapPanel <WrapPanel
Grid.Column="1" Grid.Column="1"

View file

@ -3,14 +3,13 @@ using MSFSPopoutPanelManager.MainApp.ViewModel;
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Interop; using System.Windows.Interop;
using System.Windows.Media;
namespace MSFSPopoutPanelManager.MainApp.AppWindow namespace MSFSPopoutPanelManager.MainApp.AppWindow
{ {
/// <summary>
/// Interaction logic for SwitchWindow.xaml
/// </summary>
public partial class SwitchWindow : Window public partial class SwitchWindow : Window
{ {
private readonly SwitchWindowViewModel _viewModel; private readonly SwitchWindowViewModel _viewModel;
@ -37,7 +36,7 @@ namespace MSFSPopoutPanelManager.MainApp.AppWindow
if (initialWidth == 0 && initialHeight == 0) if (initialWidth == 0 && initialHeight == 0)
{ {
this.Width = 410; this.Width = 410;
this.Height = 75; this.Height = 60;
_viewModel.PanelConfig.Width = Convert.ToInt16(this.Width); _viewModel.PanelConfig.Width = Convert.ToInt16(this.Width);
_viewModel.PanelConfig.Height = Convert.ToInt32(this.Height); _viewModel.PanelConfig.Height = Convert.ToInt32(this.Height);
} }
@ -50,6 +49,28 @@ namespace MSFSPopoutPanelManager.MainApp.AppWindow
this.MouseLeftButtonDown += SwitchWindow_MouseLeftButtonDown; this.MouseLeftButtonDown += SwitchWindow_MouseLeftButtonDown;
this.Topmost = true; this.Topmost = true;
if (_viewModel.ProfileData.ActiveProfile.ProfileSetting.SwitchWindowConfig.Panels != null)
{
var style = Application.Current.TryFindResource("MaterialDesignOutlinedButton") as Style;
WrapPanelCustomButtons.Children.Clear();
foreach (var panel in _viewModel.ProfileData.ActiveProfile.ProfileSetting.SwitchWindowConfig.Panels)
{
WrapPanelCustomButtons.Children.Add(new Button()
{
Height = 45,
Margin = new Thickness(5, 5, 5, 5),
Content = panel.DisplayName,
Foreground = new SolidColorBrush(Colors.White),
FontSize = 28,
Style = style,
Command = _viewModel.ButtonCommand,
CommandParameter = panel.PanelCaption
});
}
}
} }
private void SwitchWindow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) private void SwitchWindow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)

View file

@ -248,7 +248,6 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
if (ActiveProfile == null) if (ActiveProfile == null)
return; return;
if (ActiveProfile.ProfileSetting.SwitchWindowConfig.IsEnabled) if (ActiveProfile.ProfileSetting.SwitchWindowConfig.IsEnabled)
{ {
if (ActiveProfile.PanelConfigs.Any(p => p.PanelType == PanelType.SwitchWindow)) if (ActiveProfile.PanelConfigs.Any(p => p.PanelType == PanelType.SwitchWindow))
@ -268,8 +267,8 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
else else
{ {
ActiveProfile.PanelConfigs.RemoveAll(p => p.PanelType == PanelType.SwitchWindow); ActiveProfile.PanelConfigs.RemoveAll(p => p.PanelType == PanelType.SwitchWindow);
ActiveProfile.ProfileSetting.SwitchWindowConfig.Panels = null;
} }
} }
private void OnRefocusDisplayUpdated() private void OnRefocusDisplayUpdated()

View file

@ -23,15 +23,10 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
private void OnButtonActivated(string commandParameter) private void OnButtonActivated(string commandParameter)
{ {
switch (commandParameter) var handle = PInvoke.GetWindowHandle(commandParameter);
{
case "VerticalPanel": if(handle != IntPtr.Zero)
PInvoke.SwitchToThisWindow(PInvoke.GetWindowHandle("737 Instruments Vertical"), true); PInvoke.SwitchToThisWindow(handle, true);
break;
case "OverheadPanel":
PInvoke.SwitchToThisWindow(PInvoke.GetWindowHandle("737 Instruments Overhead"), true);
break;
}
} }
} }
} }