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:
parent
ba776ea35d
commit
d9597cf00b
10 changed files with 121 additions and 105 deletions
|
@ -36,7 +36,6 @@ namespace MSFSPopoutPanelManager.FsConnector
|
|||
{
|
||||
_simConnect = new SimConnect("MSFS Pop Out Panel Manager", Process.GetCurrentProcess().MainWindowHandle, WM_USER_SIMCONNECT, null, 0);
|
||||
|
||||
|
||||
_simConnect.OnRecvQuit += HandleOnRecvQuit;
|
||||
_simConnect.OnRecvException += HandleOnRecvException;
|
||||
_simConnect.OnRecvSimobjectDataBytype += HandleOnRecvSimobjectDataBytype;
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace MSFSPopoutPanelManager.Model
|
|||
public AppSetting()
|
||||
{
|
||||
// Set defaults
|
||||
LastUsedProfileId = -1;
|
||||
MinimizeToTray = false;
|
||||
AlwaysOnTop = true;
|
||||
UseAutoPanning = true;
|
||||
|
@ -29,12 +30,12 @@ namespace MSFSPopoutPanelManager.Model
|
|||
IncludeBuiltInPanel = false;
|
||||
AutoPopOutPanels = false;
|
||||
AutoPopOutPanelsWaitDelay = new AutoPopOutPanelsWaitDelay();
|
||||
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
var appSetting = ReadAppSetting();
|
||||
this.LastUsedProfileId = appSetting.LastUsedProfileId;
|
||||
this.MinimizeToTray = appSetting.MinimizeToTray;
|
||||
this.AlwaysOnTop = appSetting.AlwaysOnTop;
|
||||
this.UseAutoPanning = appSetting.UseAutoPanning;
|
||||
|
@ -65,6 +66,8 @@ namespace MSFSPopoutPanelManager.Model
|
|||
}
|
||||
}
|
||||
|
||||
public int LastUsedProfileId { get; set; }
|
||||
|
||||
public bool MinimizeToTray { get; set; }
|
||||
|
||||
public bool AlwaysOnTop { get; set; }
|
||||
|
@ -106,7 +109,7 @@ namespace MSFSPopoutPanelManager.Model
|
|||
return JsonConvert.DeserializeObject<AppSetting>(reader.ReadToEnd());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch
|
||||
{
|
||||
// if file does not exist, write default data
|
||||
var appSetting = new AppSetting();
|
||||
|
@ -129,7 +132,7 @@ namespace MSFSPopoutPanelManager.Model
|
|||
serializer.Serialize(file, appSetting);
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch
|
||||
{
|
||||
Logger.LogStatus($"Unable to write app setting data file: {APP_SETTING_DATA_FILENAME}", StatusMessageType.Error);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
|
||||
|
@ -14,7 +13,7 @@ namespace MSFSPopoutPanelManager.Model
|
|||
{
|
||||
PanelSourceCoordinates = new ObservableCollection<PanelSourceCoordinate>();
|
||||
PanelConfigs = new ObservableCollection<PanelConfig>();
|
||||
BindingPlaneTitle = new ObservableCollection<string>();
|
||||
BindingAircraftLiveries = new ObservableCollection<string>();
|
||||
IsLocked = false;
|
||||
}
|
||||
|
||||
|
@ -22,10 +21,8 @@ namespace MSFSPopoutPanelManager.Model
|
|||
|
||||
public string ProfileName { get; set; }
|
||||
|
||||
public bool IsDefaultProfile { get; set; }
|
||||
|
||||
[JsonConverter(typeof(SingleValueArrayConvertor<string>))]
|
||||
public ObservableCollection<string> BindingPlaneTitle { get; set; }
|
||||
public ObservableCollection<string> BindingAircraftLiveries { get; set; }
|
||||
|
||||
public bool IsLocked { get; set; }
|
||||
|
||||
|
@ -46,10 +43,21 @@ namespace MSFSPopoutPanelManager.Model
|
|||
public bool IsActive { get; set; }
|
||||
|
||||
[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
|
||||
|
|
|
@ -29,8 +29,7 @@ namespace MSFSPopoutPanelManager.Provider
|
|||
var matchedProfile = UserProfiles.FirstOrDefault(p => p.ProfileId == copyProfileId);
|
||||
|
||||
var copiedProfile = matchedProfile.Copy<UserProfile>(); // Using Shared/ObjectExtensions.cs extension method
|
||||
copiedProfile.IsDefaultProfile = false;
|
||||
copiedProfile.BindingPlaneTitle = new ObservableCollection<string>();
|
||||
copiedProfile.BindingAircraftLiveries = new ObservableCollection<string>();
|
||||
|
||||
return AddProfile(copiedProfile, newProfileName);
|
||||
}
|
||||
|
@ -52,45 +51,16 @@ namespace MSFSPopoutPanelManager.Provider
|
|||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Logger.LogStatus($"Unable to add binding to the profile because '{planeTitle}' was already bound to profile '{bindedProfile.ProfileName}'.", StatusMessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
UserProfiles.First(p => p.ProfileId == activeProfileId).BindingPlaneTitle.Add(planeTitle);
|
||||
UserProfiles.First(p => p.ProfileId == activeProfileId).BindingAircraftLiveries.Add(planeTitle);
|
||||
WriteUserProfiles();
|
||||
|
||||
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)
|
||||
{
|
||||
UserProfiles.First(p => p.ProfileId == activeProfileId).BindingPlaneTitle.Remove(planeTitle);
|
||||
UserProfiles.First(p => p.ProfileId == activeProfileId).BindingAircraftLiveries.Remove(planeTitle);
|
||||
WriteUserProfiles();
|
||||
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()));
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch
|
||||
{
|
||||
UserProfiles = new ObservableCollection<UserProfile>(new List<UserProfile>());
|
||||
}
|
||||
|
|
|
@ -13,6 +13,19 @@
|
|||
Width="800"
|
||||
ResizeMode="NoResize"
|
||||
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>
|
||||
<DockPanel>
|
||||
<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.InactiveSelectionHighlightBrushKey }" Color="Transparent"/>
|
||||
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey }" Color="White"/>
|
||||
|
||||
</Style.Resources>
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>
|
||||
|
@ -34,23 +46,37 @@
|
|||
<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>
|
||||
</TreeView>
|
||||
<WrapPanel Orientation="Vertical" DockPanel.Dock="Right" Margin="20,5,0,0" >
|
||||
<WrapPanel Orientation="Vertical" Margin="0,10,0,0" Width="500" Visibility="{Binding Path=ApplicationSettingsVisibility, Mode=TwoWay}">
|
||||
<CheckBox Margin="0,0,0,0" 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>
|
||||
<CheckBox Margin="0,0,0,0" IsChecked="{Binding Path=AppSetting.AutoStart, Mode=TwoWay}" Content="Auto Start"></CheckBox>
|
||||
<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>
|
||||
<WrapPanel DockPanel.Dock="Right" Margin="20,15,20,0" Width="Auto" >
|
||||
<WrapPanel Orientation="Vertical" Width="Auto" Visibility="{Binding Path=ApplicationSettingsVisibility, Mode=TwoWay}">
|
||||
<CheckBox IsChecked="{Binding Path=AppSetting.AlwaysOnTop, Mode=TwoWay}" Content="Always on Top"></CheckBox>
|
||||
<TextBlock Style="{StaticResource TextBlockDescription}">
|
||||
Pin the application on top of all open windows.
|
||||
</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>
|
||||
<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>
|
||||
<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 Orientation="Vertical" Margin="0,10,0,0" Visibility="{Binding Path=PopOutSettingsVisibility, Mode=TwoWay}">
|
||||
<CheckBox IsChecked="{Binding Path=AppSetting.UseAutoPanning, Mode=TwoWay}" Content="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 Margin="24,10,0,0" Width="Auto" TextWrapping="Wrap" >Key Binding</TextBlock>
|
||||
<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>
|
||||
<WrapPanel Orientation="Horizontal" Margin="20,10,0,0">
|
||||
<WrapPanel Orientation="Vertical" Width="Auto" Visibility="{Binding Path=PopOutSettingsVisibility, Mode=TwoWay}">
|
||||
<CheckBox IsChecked="{Binding Path=AppSetting.UseAutoPanning, Mode=TwoWay}" Content="Enable Auto Panning"></CheckBox>
|
||||
<TextBlock Style="{StaticResource TextBlockDescription}">
|
||||
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 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>
|
||||
<ComboBox HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
|
@ -69,48 +95,47 @@
|
|||
<ComboBoxItem Content="9" Tag="9"></ComboBoxItem>
|
||||
</ComboBox>
|
||||
</WrapPanel>
|
||||
<CheckBox Margin="0,15,0,0" 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>
|
||||
<CheckBox IsChecked="{Binding Path=AppSetting.IncludeBuiltInPanel, Mode=TwoWay}" Content="Include Built-in Panels"></CheckBox>
|
||||
<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 Orientation="Vertical" Margin="0,10,0,0" Visibility="{Binding Path=AutoPopOutSettingsVisibility, Mode=TwoWay}">
|
||||
<CheckBox IsChecked="{Binding Path=AppSetting.AutoPopOutPanels, Mode=TwoWay}" Content="Auto Pop Out Panels"></CheckBox>
|
||||
<TextBlock Margin="24,5,0,0" Width="Auto" TextWrapping="Wrap" FontSize="14">
|
||||
<WrapPanel Orientation="Vertical" Width="Auto" Visibility="{Binding Path=AutoPopOutSettingsVisibility, Mode=TwoWay}">
|
||||
<CheckBox IsChecked="{Binding Path=AppSetting.AutoPopOutPanels, Mode=TwoWay}" Content="Enable Auto Pop Out Panels"></CheckBox>
|
||||
<TextBlock Style="{StaticResource TextBlockDescription}">
|
||||
Automatic pop out panels when an aircraft livery is binded to a profile. The following steps will be performed.
|
||||
</TextBlock>
|
||||
<TextBlock Margin="24,5,5,0" Width="Auto" TextWrapping="Wrap" FontSize="14">
|
||||
<TextBlock Style="{StaticResource TextBlockDescription}">
|
||||
1. Detect flight start signal using SimConnect.
|
||||
</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.
|
||||
</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.
|
||||
</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.
|
||||
</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" >
|
||||
<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>
|
||||
</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" >
|
||||
<mah:NumericUpDown Width="80" Minimum="1" Maximum="30" FontSize="16" Height="32" Value="{Binding Path=AppSetting.AutoPopOutPanelsWaitDelay.InitialCockpitView, Mode=TwoWay}"></mah:NumericUpDown>
|
||||
<Label Margin="10,0,0,0" >Initial Cockpit View</Label>
|
||||
<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>
|
||||
</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" >
|
||||
<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>
|
||||
</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>
|
||||
<WrapPanel Orientation="Vertical" Visibility="Visible">
|
||||
</WrapPanel>
|
||||
</WrapPanel>
|
||||
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
</mah:MetroWindow>
|
|
@ -38,7 +38,7 @@
|
|||
<Style x:Key="ProfileDeletePlaneBindingDependency" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Setter Property="IsEnabled" Value="False"/>
|
||||
<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"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
|
@ -49,16 +49,18 @@
|
|||
<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" />
|
||||
<WrapPanel Orientation="Horizontal" Margin="20,5,0,0" HorizontalAlignment="Left">
|
||||
<ComboBox HorizontalAlignment="Left"
|
||||
<ComboBox
|
||||
x:Name="cmbProfile"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Width="450"
|
||||
ItemsSource="{Binding Source={StaticResource UserProfilesViewSource}}"
|
||||
SelectedValue="{Binding Path=DataStore.ActiveUserProfileId}"
|
||||
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="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>
|
||||
<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" />
|
||||
|
|
|
@ -18,10 +18,11 @@ namespace MSFSPopoutPanelManager.WpfApp
|
|||
this.DataContext = panelSelectionViewModel;
|
||||
}
|
||||
|
||||
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
cmbProfile.SelectionChanged -= Profile_Changed;
|
||||
_panelSelectionViewModel.Initialize();
|
||||
cmbProfile.SelectionChanged += Profile_Changed;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (_panelSelectionViewModel.DataStore.ActiveUserProfile.PanelSourceCoordinates.Count > 0)
|
||||
|
|
|
@ -256,7 +256,7 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
|
|||
ShowPanelSelection(true);
|
||||
|
||||
// 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)
|
||||
return;
|
||||
|
@ -304,7 +304,7 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
|
|||
// Automatic switching of active profile when SimConnect active aircraft livery changes
|
||||
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)
|
||||
DataStore.ActiveUserProfileId = matchedProfile.ProfileId;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
|
|||
if (ActiveUserProfile == null)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
return false;
|
||||
|
||||
return !ActiveUserProfile.BindingPlaneTitle.ToList().Exists(p => p == CurrentMsfsPlaneTitle);
|
||||
return !ActiveUserProfile.BindingAircraftLiveries.ToList().Exists(p => p == CurrentMsfsPlaneTitle);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
|
|||
|
||||
public DelegateCommand AddProfileCommand => new DelegateCommand(OnAddProfile, 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 DeleteProfileBindingCommand => new DelegateCommand(OnDeleteProfileBinding, 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)
|
||||
{
|
||||
DataStore = dataStore;
|
||||
DataStore.OnActiveUserProfileChanged += (sender, e) => { IsEditingPanelCoorOverlay = false; RemoveAllPanelCoorOverlay(); };
|
||||
DataStore.OnActiveUserProfileChanged += (sender, e) => {
|
||||
IsEditingPanelCoorOverlay = false;
|
||||
RemoveAllPanelCoorOverlay();
|
||||
};
|
||||
|
||||
_userProfileManager = userProfileManager;
|
||||
_simConnectManager = simConnectManager;
|
||||
|
@ -64,9 +67,7 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
|
|||
{
|
||||
_userProfileManager.ReadUserProfiles();
|
||||
DataStore.UserProfiles = _userProfileManager.UserProfiles;
|
||||
|
||||
var defaultProfile = _userProfileManager.GetDefaultProfile();
|
||||
DataStore.ActiveUserProfileId = defaultProfile == null ? -1 : defaultProfile.ProfileId;
|
||||
DataStore.ActiveUserProfileId = DataStore.UserProfiles.ToList().Exists(p => p.ProfileId == DataStore.AppSetting.LastUsedProfileId) ? DataStore.AppSetting.LastUsedProfileId : -1;
|
||||
|
||||
IsEditingPanelCoorOverlay = false;
|
||||
|
||||
|
@ -81,6 +82,8 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
|
|||
DataStore.ActiveUserProfileId = _userProfileManager.AddUserProfile(param.ProfileName);
|
||||
else
|
||||
DataStore.ActiveUserProfileId = _userProfileManager.AddUserProfileByCopyingProfile(param.ProfileName, param.CopyProfileId);
|
||||
|
||||
DataStore.AppSetting.LastUsedProfileId = DataStore.ActiveUserProfileId;
|
||||
}
|
||||
|
||||
private void OnDeleteProfile(object commandParameter)
|
||||
|
@ -89,9 +92,9 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue