diff --git a/FsConnector/SimConnector.cs b/FsConnector/SimConnector.cs index ec63d47..49376d1 100644 --- a/FsConnector/SimConnector.cs +++ b/FsConnector/SimConnector.cs @@ -34,8 +34,7 @@ namespace MSFSPopoutPanelManager.FsConnector { if (_simConnect == null) { - _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.OnRecvException += HandleOnRecvException; diff --git a/Model/AppSetting.cs b/Model/AppSetting.cs index 10e34c4..1737c86 100644 --- a/Model/AppSetting.cs +++ b/Model/AppSetting.cs @@ -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(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); } diff --git a/Model/UserProfile.cs b/Model/UserProfile.cs index c3fb032..c9b48bc 100644 --- a/Model/UserProfile.cs +++ b/Model/UserProfile.cs @@ -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(); PanelConfigs = new ObservableCollection(); - BindingPlaneTitle = new ObservableCollection(); + BindingAircraftLiveries = new ObservableCollection(); IsLocked = false; } @@ -22,10 +21,8 @@ namespace MSFSPopoutPanelManager.Model public string ProfileName { get; set; } - public bool IsDefaultProfile { get; set; } - [JsonConverter(typeof(SingleValueArrayConvertor))] - public ObservableCollection BindingPlaneTitle { get; set; } + public ObservableCollection 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))] + public ObservableCollection BindingPlaneTitle + { + set { BindingAircraftLiveries = value; } + } + + #endregion } public class SingleValueArrayConvertor : JsonConverter diff --git a/Provider/UserProfileManager.cs b/Provider/UserProfileManager.cs index a6bd801..b89e1e9 100644 --- a/Provider/UserProfileManager.cs +++ b/Provider/UserProfileManager.cs @@ -29,8 +29,7 @@ namespace MSFSPopoutPanelManager.Provider var matchedProfile = UserProfiles.FirstOrDefault(p => p.ProfileId == copyProfileId); var copiedProfile = matchedProfile.Copy(); // Using Shared/ObjectExtensions.cs extension method - copiedProfile.IsDefaultProfile = false; - copiedProfile.BindingPlaneTitle = new ObservableCollection(); + copiedProfile.BindingAircraftLiveries = new ObservableCollection(); 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(JsonConvert.DeserializeObject>(reader.ReadToEnd())); } } - catch(Exception ex) + catch { UserProfiles = new ObservableCollection(new List()); } diff --git a/WpfApp/PreferencesDialog.xaml b/WpfApp/PreferencesDialog.xaml index 261dcfb..5b1ff96 100644 --- a/WpfApp/PreferencesDialog.xaml +++ b/WpfApp/PreferencesDialog.xaml @@ -13,6 +13,19 @@ Width="800" ResizeMode="NoResize" Background="Transparent"> + + + + @@ -26,7 +39,6 @@ - @@ -34,23 +46,37 @@ - - - - Pin the application on top of all open windows. - - Auto start the application when MSFS starts. This adds a XML config entry in EXE.xml file. + + + + + Pin the application on top of all open windows. + + + + Enable auto start the application when MSFS starts. This adds a XML config entry in EXE.xml file. + - Minimize the application to system tray. + + Minimize the application to system tray. + - Start the application in minimized mode in system tray. + + Start the application in minimized mode in system tray. + - - - 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. - Key Binding - 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. - + + + + 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. + + + Key Binding + + + Configure key binding for saving and recalling of custom MSFS cockpit camera view when defining the locations of pop out panel.(Default: Ctrl-Alt-0). + + - - Enable saving and recalling of MSFS built-in panels (ie. ATC, VFR Map, Checklist, etc) as part of profile definition. + + Enable saving and recalling of MSFS built-in panels (ie. ATC, VFR Map, Checklist, etc) as part of profile definition. - - - + + + Automatic pop out panels when an aircraft livery is binded to a profile. The following steps will be performed. - + 1. Detect flight start signal using SimConnect. - + 2. Wait for 'Ready to Fly' button to appear and simulate a left mouse click. - + 3. Wait for cockpit view to appear 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. - Wait delay for each step during auto pop out process (in seconds) + Wait delay for each step during auto pop out process (in seconds) - + - Amount of time to wait for 'Ready to Fly' button to appear.(Default: 6 seconds) + Amount of time to wait for 'Ready to Fly' button to appear.(Default: 6 seconds) - - + + - Amount of time to wait for the cockpit to appear.(Default: 2 seconds) + Amount of time to wait for the cockpit to appear.(Default: 2 seconds) - + - Amount of time to wait for cold start instrumentation power on to complete.(Default: 2 seconds) + Amount of time to wait for cold start instrumentation power on to complete.(Default: 2 seconds) - - + \ No newline at end of file diff --git a/WpfApp/UserControlPanelSelection.xaml b/WpfApp/UserControlPanelSelection.xaml index 7a937b4..4d79461 100644 --- a/WpfApp/UserControlPanelSelection.xaml +++ b/WpfApp/UserControlPanelSelection.xaml @@ -38,7 +38,7 @@