1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-22 05:40:11 +00:00

Version 3.3

This commit is contained in:
hawkeye 2022-04-18 12:24:00 -04:00
parent ba776ea35d
commit d9597cf00b
10 changed files with 121 additions and 105 deletions

View file

@ -36,7 +36,6 @@ namespace MSFSPopoutPanelManager.FsConnector
{ {
_simConnect = new SimConnect("MSFS Pop Out Panel Manager", Process.GetCurrentProcess().MainWindowHandle, WM_USER_SIMCONNECT, null, 0); _simConnect = new SimConnect("MSFS Pop Out Panel Manager", Process.GetCurrentProcess().MainWindowHandle, WM_USER_SIMCONNECT, null, 0);
_simConnect.OnRecvQuit += HandleOnRecvQuit; _simConnect.OnRecvQuit += HandleOnRecvQuit;
_simConnect.OnRecvException += HandleOnRecvException; _simConnect.OnRecvException += HandleOnRecvException;
_simConnect.OnRecvSimobjectDataBytype += HandleOnRecvSimobjectDataBytype; _simConnect.OnRecvSimobjectDataBytype += HandleOnRecvSimobjectDataBytype;

View file

@ -21,6 +21,7 @@ namespace MSFSPopoutPanelManager.Model
public AppSetting() public AppSetting()
{ {
// Set defaults // Set defaults
LastUsedProfileId = -1;
MinimizeToTray = false; MinimizeToTray = false;
AlwaysOnTop = true; AlwaysOnTop = true;
UseAutoPanning = true; UseAutoPanning = true;
@ -29,12 +30,12 @@ namespace MSFSPopoutPanelManager.Model
IncludeBuiltInPanel = false; IncludeBuiltInPanel = false;
AutoPopOutPanels = false; AutoPopOutPanels = false;
AutoPopOutPanelsWaitDelay = new AutoPopOutPanelsWaitDelay(); AutoPopOutPanelsWaitDelay = new AutoPopOutPanelsWaitDelay();
} }
public void Load() public void Load()
{ {
var appSetting = ReadAppSetting(); var appSetting = ReadAppSetting();
this.LastUsedProfileId = appSetting.LastUsedProfileId;
this.MinimizeToTray = appSetting.MinimizeToTray; this.MinimizeToTray = appSetting.MinimizeToTray;
this.AlwaysOnTop = appSetting.AlwaysOnTop; this.AlwaysOnTop = appSetting.AlwaysOnTop;
this.UseAutoPanning = appSetting.UseAutoPanning; this.UseAutoPanning = appSetting.UseAutoPanning;
@ -65,6 +66,8 @@ namespace MSFSPopoutPanelManager.Model
} }
} }
public int LastUsedProfileId { get; set; }
public bool MinimizeToTray { get; set; } public bool MinimizeToTray { get; set; }
public bool AlwaysOnTop { get; set; } public bool AlwaysOnTop { get; set; }
@ -106,7 +109,7 @@ namespace MSFSPopoutPanelManager.Model
return JsonConvert.DeserializeObject<AppSetting>(reader.ReadToEnd()); return JsonConvert.DeserializeObject<AppSetting>(reader.ReadToEnd());
} }
} }
catch (Exception ex) catch
{ {
// if file does not exist, write default data // if file does not exist, write default data
var appSetting = new AppSetting(); var appSetting = new AppSetting();
@ -129,7 +132,7 @@ namespace MSFSPopoutPanelManager.Model
serializer.Serialize(file, appSetting); serializer.Serialize(file, appSetting);
} }
} }
catch(Exception ex) catch
{ {
Logger.LogStatus($"Unable to write app setting data file: {APP_SETTING_DATA_FILENAME}", StatusMessageType.Error); Logger.LogStatus($"Unable to write app setting data file: {APP_SETTING_DATA_FILENAME}", StatusMessageType.Error);
} }

View file

@ -1,6 +1,5 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
@ -14,7 +13,7 @@ namespace MSFSPopoutPanelManager.Model
{ {
PanelSourceCoordinates = new ObservableCollection<PanelSourceCoordinate>(); PanelSourceCoordinates = new ObservableCollection<PanelSourceCoordinate>();
PanelConfigs = new ObservableCollection<PanelConfig>(); PanelConfigs = new ObservableCollection<PanelConfig>();
BindingPlaneTitle = new ObservableCollection<string>(); BindingAircraftLiveries = new ObservableCollection<string>();
IsLocked = false; IsLocked = false;
} }
@ -22,10 +21,8 @@ namespace MSFSPopoutPanelManager.Model
public string ProfileName { get; set; } public string ProfileName { get; set; }
public bool IsDefaultProfile { get; set; }
[JsonConverter(typeof(SingleValueArrayConvertor<string>))] [JsonConverter(typeof(SingleValueArrayConvertor<string>))]
public ObservableCollection<string> BindingPlaneTitle { get; set; } public ObservableCollection<string> BindingAircraftLiveries { get; set; }
public bool IsLocked { get; set; } public bool IsLocked { get; set; }
@ -46,10 +43,21 @@ namespace MSFSPopoutPanelManager.Model
public bool IsActive { get; set; } public bool IsActive { get; set; }
[JsonIgnore] [JsonIgnore]
public bool HasBindingPlaneTitle public bool HasBindingAircraftLiveries
{ {
get { return BindingPlaneTitle.Count > 0; } get { return BindingAircraftLiveries.Count > 0; }
} }
#region Legacy Properties
// Support pre-Version 3.3 tag for one time conversion
[JsonConverter(typeof(SingleValueArrayConvertor<string>))]
public ObservableCollection<string> BindingPlaneTitle
{
set { BindingAircraftLiveries = value; }
}
#endregion
} }
public class SingleValueArrayConvertor<T> : JsonConverter public class SingleValueArrayConvertor<T> : JsonConverter

View file

@ -29,8 +29,7 @@ namespace MSFSPopoutPanelManager.Provider
var matchedProfile = UserProfiles.FirstOrDefault(p => p.ProfileId == copyProfileId); var matchedProfile = UserProfiles.FirstOrDefault(p => p.ProfileId == copyProfileId);
var copiedProfile = matchedProfile.Copy<UserProfile>(); // Using Shared/ObjectExtensions.cs extension method var copiedProfile = matchedProfile.Copy<UserProfile>(); // Using Shared/ObjectExtensions.cs extension method
copiedProfile.IsDefaultProfile = false; copiedProfile.BindingAircraftLiveries = new ObservableCollection<string>();
copiedProfile.BindingPlaneTitle = new ObservableCollection<string>();
return AddProfile(copiedProfile, newProfileName); return AddProfile(copiedProfile, newProfileName);
} }
@ -52,45 +51,16 @@ namespace MSFSPopoutPanelManager.Provider
return true; return true;
} }
public bool SetDefaultUserProfile(int profileId)
{
if (UserProfiles == null)
throw new Exception("User Profiles is null.");
if (profileId == -1)
return false;
var profile = UserProfiles.First(x => x.ProfileId == profileId);
profile.IsDefaultProfile = true;
foreach (var p in UserProfiles)
{
if (p.ProfileId != profileId)
p.IsDefaultProfile = false;
}
WriteUserProfiles();
Logger.LogStatus($"Profile '{profile.ProfileName}' has been set as default.", StatusMessageType.Info);
return true;
}
public UserProfile GetDefaultProfile()
{
return UserProfiles.ToList().Find(x => x.IsDefaultProfile);
}
public void AddProfileBinding(string planeTitle, int activeProfileId) public void AddProfileBinding(string planeTitle, int activeProfileId)
{ {
var bindedProfile = UserProfiles.FirstOrDefault(p => p.BindingPlaneTitle.ToList().Exists(p => p == planeTitle)); var bindedProfile = UserProfiles.FirstOrDefault(p => p.BindingAircraftLiveries.ToList().Exists(p => p == planeTitle));
if (bindedProfile != null) if (bindedProfile != null)
{ {
Logger.LogStatus($"Unable to add binding to the profile because '{planeTitle}' was already bound to profile '{bindedProfile.ProfileName}'.", StatusMessageType.Error); Logger.LogStatus($"Unable to add binding to the profile because '{planeTitle}' was already bound to profile '{bindedProfile.ProfileName}'.", StatusMessageType.Error);
return; return;
} }
UserProfiles.First(p => p.ProfileId == activeProfileId).BindingPlaneTitle.Add(planeTitle); UserProfiles.First(p => p.ProfileId == activeProfileId).BindingAircraftLiveries.Add(planeTitle);
WriteUserProfiles(); WriteUserProfiles();
Logger.LogStatus($"Binding for the profile has been added successfully.", StatusMessageType.Info); Logger.LogStatus($"Binding for the profile has been added successfully.", StatusMessageType.Info);
@ -98,7 +68,7 @@ namespace MSFSPopoutPanelManager.Provider
public void DeleteProfileBinding(string planeTitle, int activeProfileId) public void DeleteProfileBinding(string planeTitle, int activeProfileId)
{ {
UserProfiles.First(p => p.ProfileId == activeProfileId).BindingPlaneTitle.Remove(planeTitle); UserProfiles.First(p => p.ProfileId == activeProfileId).BindingAircraftLiveries.Remove(planeTitle);
WriteUserProfiles(); WriteUserProfiles();
Logger.LogStatus($"Binding for the profile has been deleted successfully.", StatusMessageType.Info); Logger.LogStatus($"Binding for the profile has been deleted successfully.", StatusMessageType.Info);
} }
@ -112,7 +82,7 @@ namespace MSFSPopoutPanelManager.Provider
UserProfiles = new ObservableCollection<UserProfile>(JsonConvert.DeserializeObject<List<UserProfile>>(reader.ReadToEnd())); UserProfiles = new ObservableCollection<UserProfile>(JsonConvert.DeserializeObject<List<UserProfile>>(reader.ReadToEnd()));
} }
} }
catch(Exception ex) catch
{ {
UserProfiles = new ObservableCollection<UserProfile>(new List<UserProfile>()); UserProfiles = new ObservableCollection<UserProfile>(new List<UserProfile>());
} }

View file

@ -13,6 +13,19 @@
Width="800" Width="800"
ResizeMode="NoResize" ResizeMode="NoResize"
Background="Transparent"> Background="Transparent">
<Window.Resources>
<Style x:Key="TextBlockHeading" TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="Width" Value="Auto"/>
<Setter Property="Margin" Value="24,5,0,10"/>
</Style>
<Style x:Key="TextBlockDescription" TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
<Setter Property="FontSize" Value="14"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="Width" Value="Auto"/>
<Setter Property="Margin" Value="24,5,0,10"/>
</Style>
</Window.Resources>
<Grid> <Grid>
<DockPanel> <DockPanel>
<TreeView Width="250" VerticalAlignment="Stretch" DockPanel.Dock="Left"> <TreeView Width="250" VerticalAlignment="Stretch" DockPanel.Dock="Left">
@ -26,7 +39,6 @@
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="White"/> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="White"/>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey }" Color="Transparent"/> <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey }" Color="Transparent"/>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey }" Color="White"/> <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey }" Color="White"/>
</Style.Resources> </Style.Resources>
</Style> </Style>
</TreeView.ItemContainerStyle> </TreeView.ItemContainerStyle>
@ -34,23 +46,37 @@
<TreeViewItem Header="Pop Out Settings" Selected="TreeViewItem_Selected" Margin="0,0,0,10"></TreeViewItem> <TreeViewItem Header="Pop Out Settings" Selected="TreeViewItem_Selected" Margin="0,0,0,10"></TreeViewItem>
<TreeViewItem Header="Auto Pop Out Panel Settings" Selected="TreeViewItem_Selected" Margin="0,0,0,10"></TreeViewItem> <TreeViewItem Header="Auto Pop Out Panel Settings" Selected="TreeViewItem_Selected" Margin="0,0,0,10"></TreeViewItem>
</TreeView> </TreeView>
<WrapPanel Orientation="Vertical" DockPanel.Dock="Right" Margin="20,5,0,0" > <WrapPanel DockPanel.Dock="Right" Margin="20,15,20,0" Width="Auto" >
<WrapPanel Orientation="Vertical" Margin="0,10,0,0" Width="500" Visibility="{Binding Path=ApplicationSettingsVisibility, Mode=TwoWay}"> <WrapPanel Orientation="Vertical" Width="Auto" Visibility="{Binding Path=ApplicationSettingsVisibility, Mode=TwoWay}">
<CheckBox Margin="0,0,0,0" IsChecked="{Binding Path=AppSetting.AlwaysOnTop, Mode=TwoWay}" Content="Always on Top"></CheckBox> <CheckBox IsChecked="{Binding Path=AppSetting.AlwaysOnTop, Mode=TwoWay}" Content="Always on Top"></CheckBox>
<TextBlock Margin="24,5,0,10" Width="Auto" TextWrapping="Wrap" FontSize="14">Pin the application on top of all open windows.</TextBlock> <TextBlock Style="{StaticResource TextBlockDescription}">
<CheckBox Margin="0,0,0,0" IsChecked="{Binding Path=AppSetting.AutoStart, Mode=TwoWay}" Content="Auto Start"></CheckBox> Pin the application on top of all open windows.
<TextBlock Margin="24,5,0,10" Width="Auto" TextWrapping="Wrap" FontSize="14">Auto start the application when MSFS starts. This adds a XML config entry in EXE.xml file.</TextBlock> </TextBlock>
<CheckBox IsChecked="{Binding Path=AppSetting.AutoStart, Mode=TwoWay}" Content="Auto Start"></CheckBox>
<TextBlock Style="{StaticResource TextBlockDescription}">
Enable auto start the application when MSFS starts. This adds a XML config entry in EXE.xml file.
</TextBlock>
<CheckBox IsChecked="{Binding Path=AppSetting.MinimizeToTray, Mode=TwoWay}" Content="Minimize to Tray"></CheckBox> <CheckBox IsChecked="{Binding Path=AppSetting.MinimizeToTray, Mode=TwoWay}" Content="Minimize to Tray"></CheckBox>
<TextBlock Margin="24,5,0,10" Width="Auto" TextWrapping="Wrap" FontSize="14">Minimize the application to system tray.</TextBlock> <TextBlock Style="{StaticResource TextBlockDescription}">
Minimize the application to system tray.
</TextBlock>
<CheckBox IsChecked="{Binding Path=AppSetting.StartMinimized, Mode=TwoWay}" Content="Start Minimized"></CheckBox> <CheckBox IsChecked="{Binding Path=AppSetting.StartMinimized, Mode=TwoWay}" Content="Start Minimized"></CheckBox>
<TextBlock Margin="24,5,0,10" Width="Auto" TextWrapping="Wrap" FontSize="14">Start the application in minimized mode in system tray.</TextBlock> <TextBlock Style="{StaticResource TextBlockDescription}">
Start the application in minimized mode in system tray.
</TextBlock>
</WrapPanel> </WrapPanel>
<WrapPanel Orientation="Vertical" Margin="0,10,0,0" Visibility="{Binding Path=PopOutSettingsVisibility, Mode=TwoWay}"> <WrapPanel Orientation="Vertical" Width="Auto" Visibility="{Binding Path=PopOutSettingsVisibility, Mode=TwoWay}">
<CheckBox IsChecked="{Binding Path=AppSetting.UseAutoPanning, Mode=TwoWay}" Content="Auto Panning"></CheckBox> <CheckBox IsChecked="{Binding Path=AppSetting.UseAutoPanning, Mode=TwoWay}" Content="Enable Auto Panning"></CheckBox>
<TextBlock Margin="24,5,0,10" Width="Auto" TextWrapping="Wrap" FontSize="14">Enable automatic panning of cockpit view when popping out panels. Auto Panning remembers the custom cockpit camera angle you used when defining the locations of pop out panel.</TextBlock> <TextBlock Style="{StaticResource TextBlockDescription}">
<TextBlock Margin="24,10,0,0" Width="Auto" TextWrapping="Wrap" >Key Binding</TextBlock> Enable automatic panning of cockpit view when popping out panels. Auto Panning remembers the custom cockpit camera angle you used when defining the locations of pop out panel.
<TextBlock Margin="24,5,0,10" Width="Auto" TextWrapping="Wrap" FontSize="14">Configure key binding for saving and recalling of custom MSFS cockpit camera view when defining the locations of pop out panel. Default is Ctrl-Alt-0.</TextBlock> </TextBlock>
<WrapPanel Orientation="Horizontal" Margin="20,10,0,0"> <TextBlock Style="{StaticResource TextBlockHeading}">
Key Binding
</TextBlock>
<TextBlock Style="{StaticResource TextBlockDescription}">
Configure key binding for saving and recalling of custom MSFS cockpit camera view when defining the locations of pop out panel.<LineBreak/>(Default: Ctrl-Alt-0).
</TextBlock>
<WrapPanel Orientation="Horizontal" Margin="20,10,0,15">
<Label Content="Ctrl-Alt-" FontSize="14"></Label> <Label Content="Ctrl-Alt-" FontSize="14"></Label>
<ComboBox HorizontalAlignment="Left" <ComboBox HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -69,48 +95,47 @@
<ComboBoxItem Content="9" Tag="9"></ComboBoxItem> <ComboBoxItem Content="9" Tag="9"></ComboBoxItem>
</ComboBox> </ComboBox>
</WrapPanel> </WrapPanel>
<CheckBox Margin="0,15,0,0" IsChecked="{Binding Path=AppSetting.IncludeBuiltInPanel, Mode=TwoWay}" Content="Include Built-in Panels"></CheckBox> <CheckBox IsChecked="{Binding Path=AppSetting.IncludeBuiltInPanel, Mode=TwoWay}" Content="Include Built-in Panels"></CheckBox>
<TextBlock Margin="24,5,0,10" Width="Auto" TextWrapping="Wrap" FontSize="14">Enable saving and recalling of MSFS built-in panels (ie. ATC, VFR Map, Checklist, etc) as part of profile definition.</TextBlock> <TextBlock Style="{StaticResource TextBlockDescription}">Enable saving and recalling of MSFS built-in panels (ie. ATC, VFR Map, Checklist, etc) as part of profile definition.</TextBlock>
</WrapPanel> </WrapPanel>
<WrapPanel Orientation="Vertical" Margin="0,10,0,0" Visibility="{Binding Path=AutoPopOutSettingsVisibility, Mode=TwoWay}"> <WrapPanel Orientation="Vertical" Width="Auto" Visibility="{Binding Path=AutoPopOutSettingsVisibility, Mode=TwoWay}">
<CheckBox IsChecked="{Binding Path=AppSetting.AutoPopOutPanels, Mode=TwoWay}" Content="Auto Pop Out Panels"></CheckBox> <CheckBox IsChecked="{Binding Path=AppSetting.AutoPopOutPanels, Mode=TwoWay}" Content="Enable Auto Pop Out Panels"></CheckBox>
<TextBlock Margin="24,5,0,0" Width="Auto" TextWrapping="Wrap" FontSize="14"> <TextBlock Style="{StaticResource TextBlockDescription}">
Automatic pop out panels when an aircraft livery is binded to a profile. The following steps will be performed. Automatic pop out panels when an aircraft livery is binded to a profile. The following steps will be performed.
</TextBlock> </TextBlock>
<TextBlock Margin="24,5,5,0" Width="Auto" TextWrapping="Wrap" FontSize="14"> <TextBlock Style="{StaticResource TextBlockDescription}">
1. Detect flight start signal using SimConnect. 1. Detect flight start signal using SimConnect.
</TextBlock> </TextBlock>
<TextBlock Margin="24,5,5,0" Width="Auto" TextWrapping="Wrap" FontSize="14"> <TextBlock Style="{StaticResource TextBlockDescription}">
2. Wait for 'Ready to Fly' button to appear and simulate a left mouse click. 2. Wait for 'Ready to Fly' button to appear and simulate a left mouse click.
</TextBlock> </TextBlock>
<TextBlock Margin="24,5,5,0" Width="Auto" TextWrapping="Wrap" FontSize="14"> <TextBlock Style="{StaticResource TextBlockDescription}">
3. Wait for cockpit view to appear before executing pop out panel sequence. 3. Wait for cockpit view to appear before executing pop out panel sequence.
</TextBlock> </TextBlock>
<TextBlock Margin="24,5,5,0" Width="Auto" TextWrapping="Wrap" FontSize="14"> <TextBlock Style="{StaticResource TextBlockDescription}">
4. If configured for a profile on cold start, wait for instrumentation power on before executing pop out panel sequence. 4. If configured for a profile on cold start, wait for instrumentation power on before executing pop out panel sequence.
</TextBlock> </TextBlock>
<TextBlock Margin="24,20,0,10" Width="Auto" TextWrapping="Wrap" >Wait delay for each step during auto pop out process (in seconds)</TextBlock> <TextBlock Style="{StaticResource TextBlockHeading}">Wait delay for each step during auto pop out process (in seconds)</TextBlock>
<WrapPanel Orientation="Horizontal" Margin="24,0,0,0" > <WrapPanel Orientation="Horizontal" Margin="24,0,0,0" >
<mah:NumericUpDown Width="80" Minimum="1" Maximum="30" FontSize="16" Height="32" Value="{Binding Path=AppSetting.AutoPopOutPanelsWaitDelay.ReadyToFlyButton, Mode=TwoWay}"></mah:NumericUpDown> <mah:NumericUpDown Width="80" Minimum="1" Maximum="30" FontSize="16" Value="{Binding Path=AppSetting.AutoPopOutPanelsWaitDelay.ReadyToFlyButton, Mode=TwoWay}"></mah:NumericUpDown>
<Label Margin="10,0,0,0">Ready to Fly</Label> <Label Margin="10,0,0,0">Ready to Fly</Label>
</WrapPanel> </WrapPanel>
<TextBlock Margin="119,0,10,10" Width="Auto" TextWrapping="Wrap" FontSize="14">Amount of time to wait for 'Ready to Fly' button to appear.<LineBreak/>(Default: 6 seconds)</TextBlock> <TextBlock Margin="119,0,10,10" Style="{StaticResource TextBlockDescription}">Amount of time to wait for 'Ready to Fly' button to appear.<LineBreak/>(Default: 6 seconds)</TextBlock>
<WrapPanel Orientation="Horizontal" Margin="24,0,0,0" > <WrapPanel Orientation="Horizontal" Margin="24,0,0,0" >
<mah:NumericUpDown Width="80" Minimum="1" Maximum="30" FontSize="16" Height="32" Value="{Binding Path=AppSetting.AutoPopOutPanelsWaitDelay.InitialCockpitView, Mode=TwoWay}"></mah:NumericUpDown> <mah:NumericUpDown Width="80" Minimum="1" Maximum="30" FontSize="16" Value="{Binding Path=AppSetting.AutoPopOutPanelsWaitDelay.InitialCockpitView, Mode=TwoWay}"></mah:NumericUpDown>
<Label Margin="10,0,0,0">Initial Cockpit View</Label> <Label Margin="10,0,0,0">Initial Cockpit View</Label>
</WrapPanel> </WrapPanel>
<TextBlock Margin="119,0,10,10" Width="Auto" TextWrapping="Wrap" FontSize="14">Amount of time to wait for the cockpit to appear.<LineBreak/>(Default: 2 seconds)</TextBlock> <TextBlock Margin="119,0,10,10" Style="{StaticResource TextBlockDescription}">Amount of time to wait for the cockpit to appear.<LineBreak/>(Default: 2 seconds)</TextBlock>
<WrapPanel Orientation="Horizontal" Margin="24,0,0,00" > <WrapPanel Orientation="Horizontal" Margin="24,0,0,00" >
<mah:NumericUpDown Width="80" Minimum="1" Maximum="30" FontSize="16" Height="32" Value="{Binding Path=AppSetting.AutoPopOutPanelsWaitDelay.InstrumentationPowerOn, Mode=TwoWay}"></mah:NumericUpDown> <mah:NumericUpDown Width="80" Minimum="1" Maximum="30" FontSize="16" Value="{Binding Path=AppSetting.AutoPopOutPanelsWaitDelay.InstrumentationPowerOn, Mode=TwoWay}"></mah:NumericUpDown>
<Label Margin="10,0,0,0">Instrumentation Power On</Label> <Label Margin="10,0,0,0">Instrumentation Power On</Label>
</WrapPanel> </WrapPanel>
<TextBlock Margin="119,0,10,10" Width="Auto" TextWrapping="Wrap" FontSize="14">Amount of time to wait for cold start instrumentation power on to complete.<LineBreak/>(Default: 2 seconds)</TextBlock> <TextBlock Margin="119,0,10,10" Style="{StaticResource TextBlockDescription}">Amount of time to wait for cold start instrumentation power on to complete.<LineBreak/>(Default: 2 seconds)</TextBlock>
<WrapPanel Orientation="Horizontal"></WrapPanel> <WrapPanel Orientation="Horizontal"></WrapPanel>
</WrapPanel> </WrapPanel>
<WrapPanel Orientation="Vertical" Visibility="Visible"> <WrapPanel Orientation="Vertical" Visibility="Visible">
</WrapPanel> </WrapPanel>
</WrapPanel> </WrapPanel>
</DockPanel> </DockPanel>
</Grid> </Grid>
</mah:MetroWindow> </mah:MetroWindow>

View file

@ -38,7 +38,7 @@
<Style x:Key="ProfileDeletePlaneBindingDependency" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}"> <Style x:Key="ProfileDeletePlaneBindingDependency" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="IsEnabled" Value="False"/> <Setter Property="IsEnabled" Value="False"/>
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{c:Binding Path='DataStore.HasActiveUserProfileId and DataStore.ActiveUserProfile.HasBindingPlaneTitle and DataStore.IsAllowedDeleteAircraftBinding', Mode=OneWay}" Value="True"> <DataTrigger Binding="{c:Binding Path='DataStore.HasActiveUserProfileId and DataStore.ActiveUserProfile.HasBindingAircraftLiveries and DataStore.IsAllowedDeleteAircraftBinding', Mode=OneWay}" Value="True">
<Setter Property="IsEnabled" Value="True"/> <Setter Property="IsEnabled" Value="True"/>
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>
@ -49,16 +49,18 @@
<WrapPanel DockPanel.Dock="Left" Orientation="Vertical" Margin="15,10,0,0" Width="585" HorizontalAlignment="Left"> <WrapPanel DockPanel.Dock="Left" Orientation="Vertical" Margin="15,10,0,0" Width="585" HorizontalAlignment="Left">
<Label Content="1. Please select a profile you would like to use." HorizontalAlignment="Left" /> <Label Content="1. Please select a profile you would like to use." HorizontalAlignment="Left" />
<WrapPanel Orientation="Horizontal" Margin="20,5,0,0" HorizontalAlignment="Left"> <WrapPanel Orientation="Horizontal" Margin="20,5,0,0" HorizontalAlignment="Left">
<ComboBox HorizontalAlignment="Left" <ComboBox
x:Name="cmbProfile"
HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Center"
Width="450" Width="450"
ItemsSource="{Binding Source={StaticResource UserProfilesViewSource}}" ItemsSource="{Binding Source={StaticResource UserProfilesViewSource}}"
SelectedValue="{Binding Path=DataStore.ActiveUserProfileId}" SelectedValue="{Binding Path=DataStore.ActiveUserProfileId}"
DisplayMemberPath="ProfileName" DisplayMemberPath="ProfileName"
SelectedValuePath="ProfileId"/> SelectedValuePath="ProfileId"
SelectionChanged="Profile_Changed"/>
<Button Content="+" ToolTip="Add Profile" HorizontalAlignment="Left" Margin="10,0,0,0" Width="40" Click="AddProfile_Click" /> <Button Content="+" ToolTip="Add Profile" HorizontalAlignment="Left" Margin="10,0,0,0" Width="40" Click="AddProfile_Click" />
<Button Content="-" ToolTip="Delete Profile" HorizontalAlignment="Left" Margin="10,0,0,0" Width="40" Click="DeleteProfile_Click" Style="{StaticResource ProfileSelectedDependency}"/> <Button Content="-" ToolTip="Delete Profile" HorizontalAlignment="Left" Margin="10,0,0,0" Width="40" Click="DeleteProfile_Click" Style="{StaticResource ProfileSelectedDependency}"/>
<!--<Button Content="D" ToolTip="Set Default Profile" HorizontalAlignment="Left" Margin="10,0,0,0" Width="40" Command="{Binding Path=SetDefaultProfileCommand}" Style="{StaticResource ProfileSelectedDependency}"/>-->
</WrapPanel> </WrapPanel>
<Separator Margin="5,10,5,10"/> <Separator Margin="5,10,5,10"/>
<Label Content="2. Optional: Bind active aircraft livery to profile to automatically pop out panels." HorizontalAlignment="Left" Margin="0,0,0,0" /> <Label Content="2. Optional: Bind active aircraft livery to profile to automatically pop out panels." HorizontalAlignment="Left" Margin="0,0,0,0" />

View file

@ -18,10 +18,11 @@ namespace MSFSPopoutPanelManager.WpfApp
this.DataContext = panelSelectionViewModel; this.DataContext = panelSelectionViewModel;
} }
private void UserControl_Loaded(object sender, RoutedEventArgs e) private void UserControl_Loaded(object sender, RoutedEventArgs e)
{ {
cmbProfile.SelectionChanged -= Profile_Changed;
_panelSelectionViewModel.Initialize(); _panelSelectionViewModel.Initialize();
cmbProfile.SelectionChanged += Profile_Changed;
} }
private void AddProfile_Click(object sender, RoutedEventArgs e) private void AddProfile_Click(object sender, RoutedEventArgs e)
@ -50,6 +51,11 @@ namespace MSFSPopoutPanelManager.WpfApp
} }
} }
private void Profile_Changed(object sender, RoutedEventArgs e)
{
_panelSelectionViewModel.ChangeProfileCommand.Execute(null);
}
private void StartPanelSelection_Click(object sender, RoutedEventArgs e) private void StartPanelSelection_Click(object sender, RoutedEventArgs e)
{ {
if (_panelSelectionViewModel.DataStore.ActiveUserProfile.PanelSourceCoordinates.Count > 0) if (_panelSelectionViewModel.DataStore.ActiveUserProfile.PanelSourceCoordinates.Count > 0)

View file

@ -256,7 +256,7 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
ShowPanelSelection(true); ShowPanelSelection(true);
// find the profile with the matching binding plane title // find the profile with the matching binding plane title
var profile = DataStore.UserProfiles.FirstOrDefault(p => p.BindingPlaneTitle.ToList().Exists(p => p == DataStore.CurrentMsfsPlaneTitle)); var profile = DataStore.UserProfiles.FirstOrDefault(p => p.BindingAircraftLiveries.ToList().Exists(p => p == DataStore.CurrentMsfsPlaneTitle));
if (profile == null || profile.PanelSourceCoordinates.Count == 0) if (profile == null || profile.PanelSourceCoordinates.Count == 0)
return; return;
@ -304,7 +304,7 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
// Automatic switching of active profile when SimConnect active aircraft livery changes // Automatic switching of active profile when SimConnect active aircraft livery changes
if (DataStore.UserProfiles != null) if (DataStore.UserProfiles != null)
{ {
var matchedProfile = DataStore.UserProfiles.ToList().Find(p => p.BindingPlaneTitle.ToList().Exists(t => t == activeAircraftTitle)); var matchedProfile = DataStore.UserProfiles.ToList().Find(p => p.BindingAircraftLiveries.ToList().Exists(t => t == activeAircraftTitle));
if (matchedProfile != null) if (matchedProfile != null)
DataStore.ActiveUserProfileId = matchedProfile.ProfileId; DataStore.ActiveUserProfileId = matchedProfile.ProfileId;
} }

View file

@ -124,7 +124,7 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
if (ActiveUserProfile == null) if (ActiveUserProfile == null)
return false; return false;
return ActiveUserProfile.BindingPlaneTitle.ToList().Exists(p => p == CurrentMsfsPlaneTitle); return ActiveUserProfile.BindingAircraftLiveries.ToList().Exists(p => p == CurrentMsfsPlaneTitle);
} }
} }
@ -135,11 +135,11 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
if (ActiveUserProfile == null || !HasCurrentMsfsPlaneTitle) if (ActiveUserProfile == null || !HasCurrentMsfsPlaneTitle)
return false; return false;
var uProfile = UserProfiles.ToList().Find(u => u.BindingPlaneTitle.ToList().Exists(p => p == CurrentMsfsPlaneTitle)); var uProfile = UserProfiles.ToList().Find(u => u.BindingAircraftLiveries.ToList().Exists(p => p == CurrentMsfsPlaneTitle));
if (uProfile != null && uProfile.ProfileId != ActiveUserProfileId) if (uProfile != null && uProfile.ProfileId != ActiveUserProfileId)
return false; return false;
return ActiveUserProfile.BindingPlaneTitle.ToList().Exists(p => p == CurrentMsfsPlaneTitle); return ActiveUserProfile.BindingAircraftLiveries.ToList().Exists(p => p == CurrentMsfsPlaneTitle);
} }
} }
@ -150,11 +150,11 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
if (ActiveUserProfile == null || !HasCurrentMsfsPlaneTitle) if (ActiveUserProfile == null || !HasCurrentMsfsPlaneTitle)
return false; return false;
var uProfile = UserProfiles.ToList().Find(u => u.BindingPlaneTitle.ToList().Exists(p => p == CurrentMsfsPlaneTitle)); var uProfile = UserProfiles.ToList().Find(u => u.BindingAircraftLiveries.ToList().Exists(p => p == CurrentMsfsPlaneTitle));
if (uProfile != null && uProfile.ProfileId != ActiveUserProfileId) if (uProfile != null && uProfile.ProfileId != ActiveUserProfileId)
return false; return false;
return !ActiveUserProfile.BindingPlaneTitle.ToList().Exists(p => p == CurrentMsfsPlaneTitle); return !ActiveUserProfile.BindingAircraftLiveries.ToList().Exists(p => p == CurrentMsfsPlaneTitle);
} }
} }

View file

@ -31,7 +31,7 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
public DelegateCommand AddProfileCommand => new DelegateCommand(OnAddProfile, CanExecute); public DelegateCommand AddProfileCommand => new DelegateCommand(OnAddProfile, CanExecute);
public DelegateCommand DeleteProfileCommand => new DelegateCommand(OnDeleteProfile, CanExecute); public DelegateCommand DeleteProfileCommand => new DelegateCommand(OnDeleteProfile, CanExecute);
public DelegateCommand SetDefaultProfileCommand => new DelegateCommand(OnSetDefaultProfile, CanExecute); public DelegateCommand ChangeProfileCommand => new DelegateCommand(OnChangeProfile, CanExecute);
public DelegateCommand AddProfileBindingCommand => new DelegateCommand(OnAddProfileBinding, CanExecute); public DelegateCommand AddProfileBindingCommand => new DelegateCommand(OnAddProfileBinding, CanExecute);
public DelegateCommand DeleteProfileBindingCommand => new DelegateCommand(OnDeleteProfileBinding, CanExecute); public DelegateCommand DeleteProfileBindingCommand => new DelegateCommand(OnDeleteProfileBinding, CanExecute);
public DelegateCommand SetPowerOnRequiredCommand => new DelegateCommand((e) => _userProfileManager.WriteUserProfiles(), CanExecute); public DelegateCommand SetPowerOnRequiredCommand => new DelegateCommand((e) => _userProfileManager.WriteUserProfiles(), CanExecute);
@ -43,7 +43,10 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
public PanelSelectionViewModel(DataStore dataStore, UserProfileManager userProfileManager, PanelPopOutManager panelPopoutManager, SimConnectManager simConnectManager) public PanelSelectionViewModel(DataStore dataStore, UserProfileManager userProfileManager, PanelPopOutManager panelPopoutManager, SimConnectManager simConnectManager)
{ {
DataStore = dataStore; DataStore = dataStore;
DataStore.OnActiveUserProfileChanged += (sender, e) => { IsEditingPanelCoorOverlay = false; RemoveAllPanelCoorOverlay(); }; DataStore.OnActiveUserProfileChanged += (sender, e) => {
IsEditingPanelCoorOverlay = false;
RemoveAllPanelCoorOverlay();
};
_userProfileManager = userProfileManager; _userProfileManager = userProfileManager;
_simConnectManager = simConnectManager; _simConnectManager = simConnectManager;
@ -64,9 +67,7 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
{ {
_userProfileManager.ReadUserProfiles(); _userProfileManager.ReadUserProfiles();
DataStore.UserProfiles = _userProfileManager.UserProfiles; DataStore.UserProfiles = _userProfileManager.UserProfiles;
DataStore.ActiveUserProfileId = DataStore.UserProfiles.ToList().Exists(p => p.ProfileId == DataStore.AppSetting.LastUsedProfileId) ? DataStore.AppSetting.LastUsedProfileId : -1;
var defaultProfile = _userProfileManager.GetDefaultProfile();
DataStore.ActiveUserProfileId = defaultProfile == null ? -1 : defaultProfile.ProfileId;
IsEditingPanelCoorOverlay = false; IsEditingPanelCoorOverlay = false;
@ -81,6 +82,8 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
DataStore.ActiveUserProfileId = _userProfileManager.AddUserProfile(param.ProfileName); DataStore.ActiveUserProfileId = _userProfileManager.AddUserProfile(param.ProfileName);
else else
DataStore.ActiveUserProfileId = _userProfileManager.AddUserProfileByCopyingProfile(param.ProfileName, param.CopyProfileId); DataStore.ActiveUserProfileId = _userProfileManager.AddUserProfileByCopyingProfile(param.ProfileName, param.CopyProfileId);
DataStore.AppSetting.LastUsedProfileId = DataStore.ActiveUserProfileId;
} }
private void OnDeleteProfile(object commandParameter) private void OnDeleteProfile(object commandParameter)
@ -89,9 +92,9 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
DataStore.ActiveUserProfileId = -1; DataStore.ActiveUserProfileId = -1;
} }
private void OnSetDefaultProfile(object commandParameter) private void OnChangeProfile(object commandParameter)
{ {
_userProfileManager.SetDefaultUserProfile(DataStore.ActiveUserProfileId); DataStore.AppSetting.LastUsedProfileId = DataStore.ActiveUserProfileId;
} }
private void OnAddProfileBinding(object commandParameter) private void OnAddProfileBinding(object commandParameter)