1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-10-16 06:00:45 +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()
{
PropertyChanged += FloatingPanel_PropertyChanged; ;
PropertyChanged += FloatingPanel_PropertyChanged;
}
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
{
public class SwitchWindowConfig : ObservableObject
{
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>
</WrapPanel>
<WrapPanel Name="wrapPanelSwitchWindow" Margin="0,8,0,0">
<WrapPanel Name="WrapPanelSwitchWindow" Margin="0,8,0,0">
<ToggleButton
IsChecked="{Binding ActiveProfile.ProfileSetting.SwitchWindowConfig.IsEnabled, Mode=TwoWay, NotifyOnTargetUpdated=True}"
IsHitTestVisible="{c:Binding '!ActiveProfile.IsLocked',

View file

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

View file

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

View file

@ -3,14 +3,13 @@ using MSFSPopoutPanelManager.MainApp.ViewModel;
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
namespace MSFSPopoutPanelManager.MainApp.AppWindow
{
/// <summary>
/// Interaction logic for SwitchWindow.xaml
/// </summary>
public partial class SwitchWindow : Window
{
private readonly SwitchWindowViewModel _viewModel;
@ -37,7 +36,7 @@ namespace MSFSPopoutPanelManager.MainApp.AppWindow
if (initialWidth == 0 && initialHeight == 0)
{
this.Width = 410;
this.Height = 75;
this.Height = 60;
_viewModel.PanelConfig.Width = Convert.ToInt16(this.Width);
_viewModel.PanelConfig.Height = Convert.ToInt32(this.Height);
}
@ -50,6 +49,28 @@ namespace MSFSPopoutPanelManager.MainApp.AppWindow
this.MouseLeftButtonDown += SwitchWindow_MouseLeftButtonDown;
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)

View file

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

View file

@ -23,15 +23,10 @@ namespace MSFSPopoutPanelManager.MainApp.ViewModel
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;
}
var handle = PInvoke.GetWindowHandle(commandParameter);
if(handle != IntPtr.Zero)
PInvoke.SwitchToThisWindow(handle, true);
}
}
}