diff --git a/Orchestration/FlightSimData.cs b/Orchestration/FlightSimData.cs index 05fbf82..0db6897 100644 --- a/Orchestration/FlightSimData.cs +++ b/Orchestration/FlightSimData.cs @@ -6,13 +6,13 @@ namespace MSFSPopoutPanelManager.Orchestration { public class FlightSimData : ObservableObject { - public event PropertyChangedEventHandler CurrentMsfsPlaneTitleChanged; + public event PropertyChangedEventHandler CurrentMsfsAircraftChanged; - public string CurrentMsfsPlaneTitle { get; set; } + public string CurrentMsfsAircraft { get; set; } - public bool HasCurrentMsfsPlaneTitle + public bool HasCurrentMsfsAircraft { - get { return !String.IsNullOrEmpty(CurrentMsfsPlaneTitle); } + get { return !String.IsNullOrEmpty(CurrentMsfsAircraft); } } public bool ElectricalMasterBatteryStatus { get; set; } @@ -25,8 +25,8 @@ namespace MSFSPopoutPanelManager.Orchestration { if (oldValue != newValue) { - if (propertyName == "CurrentMsfsPlaneTitle") - CurrentMsfsPlaneTitleChanged?.Invoke(this, null); + if (propertyName == "CurrentMsfsAircraft") + CurrentMsfsAircraftChanged?.Invoke(this, null); base.OnPropertyChanged(propertyName, oldValue, newValue); } @@ -34,7 +34,7 @@ namespace MSFSPopoutPanelManager.Orchestration public void ClearData() { - CurrentMsfsPlaneTitle = null; + CurrentMsfsAircraft = null; ElectricalMasterBatteryStatus = false; IsEnteredFlight = false; } diff --git a/Orchestration/FlightSimOrchestrator.cs b/Orchestration/FlightSimOrchestrator.cs index f0a7b69..46a4a5f 100644 --- a/Orchestration/FlightSimOrchestrator.cs +++ b/Orchestration/FlightSimOrchestrator.cs @@ -43,14 +43,15 @@ namespace MSFSPopoutPanelManager.Orchestration }; _simConnectProvider.OnSimConnectDataRefreshed += (sender, e) => { - var title = Convert.ToString(e.Find(d => d.PropName == "Title").Value); + var aircraftName = Convert.ToString(e.Find(d => d.PropName == "AircraftName").Value); + aircraftName = String.IsNullOrEmpty(aircraftName) ? null : aircraftName; var electricalMasterBattery = Convert.ToBoolean(e.Find(d => d.PropName == "ElectricalMasterBattery").Value); - // Automatic switching of active profile when SimConnect active aircraft livery changes - if (FlightSimData.CurrentMsfsPlaneTitle != title) + // Automatic switching of active profile when SimConnect active aircraft change + if (FlightSimData.CurrentMsfsAircraft != aircraftName) { - FlightSimData.CurrentMsfsPlaneTitle = title; - ProfileData.AutoSwitchProfile(title); + FlightSimData.CurrentMsfsAircraft = aircraftName; + ProfileData.AutoSwitchProfile(aircraftName); } if (electricalMasterBattery != FlightSimData.ElectricalMasterBatteryStatus) diff --git a/Orchestration/MainOrchestrator.cs b/Orchestration/MainOrchestrator.cs index 8220b42..aeee2c4 100644 --- a/Orchestration/MainOrchestrator.cs +++ b/Orchestration/MainOrchestrator.cs @@ -20,7 +20,7 @@ namespace MSFSPopoutPanelManager.Orchestration TouchPanel = new TouchPanelOrchestrator(); FlightSimData = new FlightSimData(); - FlightSimData.CurrentMsfsPlaneTitleChanged += (sernder, e) => ProfileData.RefreshProfile(); + FlightSimData.CurrentMsfsAircraftChanged += (sernder, e) => ProfileData.RefreshProfile(); AppSettingData = new AppSettingData(); AppSettingData.AutoPopOutPanelsChanged += (sender, e) => FlightSim.AutoPanelPopOutActivation(e); diff --git a/Orchestration/PanelPopOutOrchestrator.cs b/Orchestration/PanelPopOutOrchestrator.cs index 51ec894..478655d 100644 --- a/Orchestration/PanelPopOutOrchestrator.cs +++ b/Orchestration/PanelPopOutOrchestrator.cs @@ -55,14 +55,14 @@ namespace MSFSPopoutPanelManager.Orchestration if (ActiveProfile == null) return; - ProfileData.AutoSwitchProfile(FlightSimData.CurrentMsfsPlaneTitle); + ProfileData.AutoSwitchProfile(FlightSimData.CurrentMsfsAircraft); FlightSimData.IsEnteredFlight = true; - // find the profile with the matching binding plane title - var profile = ProfileData.Profiles.FirstOrDefault(p => p.BindingAircraftLiveries.Any(p => p == FlightSimData.CurrentMsfsPlaneTitle)); + // find the profile with the matching binding aircraft + var profile = ProfileData.Profiles.FirstOrDefault(p => p.BindingAircrafts.Any(p => p == FlightSimData.CurrentMsfsAircraft)); - // Do not do auto pop out if no profile matches the current livery + // Do not do auto pop out if no profile matches the current aircraft if (profile == null) return; diff --git a/Orchestration/ProfileData.cs b/Orchestration/ProfileData.cs index 893355f..673b583 100644 --- a/Orchestration/ProfileData.cs +++ b/Orchestration/ProfileData.cs @@ -47,21 +47,21 @@ namespace MSFSPopoutPanelManager.Orchestration return true; } - public void AddProfileBinding(string planeTitle, int activeProfileId) + public void AddProfileBinding(string aircraft, int activeProfileId) { if (ActiveProfile == null) return; - ProfileManager.AddProfileBinding(planeTitle, activeProfileId, Profiles); + ProfileManager.AddProfileBinding(aircraft, activeProfileId, Profiles); RefreshProfile(); } - public void DeleteProfileBinding(string planeTitle, int activeProfileId) + public void DeleteProfileBinding(string aircraft, int activeProfileId) { if (ActiveProfile == null) return; - ProfileManager.DeleteProfileBinding(planeTitle, activeProfileId, Profiles); + ProfileManager.DeleteProfileBinding(aircraft, activeProfileId, Profiles); RefreshProfile(); } @@ -111,7 +111,7 @@ namespace MSFSPopoutPanelManager.Orchestration if (ActiveProfile == null) return false; - return ActiveProfile.BindingAircraftLiveries.Any(p => p == FlightSimData.CurrentMsfsPlaneTitle); + return ActiveProfile.BindingAircrafts.Any(p => p == FlightSimData.CurrentMsfsAircraft); } } @@ -119,14 +119,14 @@ namespace MSFSPopoutPanelManager.Orchestration { get { - if (ActiveProfile == null || !FlightSimData.HasCurrentMsfsPlaneTitle) + if (ActiveProfile == null || !FlightSimData.HasCurrentMsfsAircraft) return false; - var uProfile = Profiles.FirstOrDefault(u => u.BindingAircraftLiveries.Any(p => p == FlightSimData.CurrentMsfsPlaneTitle)); + var uProfile = Profiles.FirstOrDefault(u => u.BindingAircrafts.Any(p => p == FlightSimData.CurrentMsfsAircraft)); if (uProfile != null && uProfile.ProfileId != ActiveProfile.ProfileId) return false; - return ActiveProfile.BindingAircraftLiveries.Any(p => p == FlightSimData.CurrentMsfsPlaneTitle); + return ActiveProfile.BindingAircrafts.Any(p => p == FlightSimData.CurrentMsfsAircraft); } } @@ -134,17 +134,17 @@ namespace MSFSPopoutPanelManager.Orchestration { get { - if (ActiveProfile == null || !FlightSimData.HasCurrentMsfsPlaneTitle) + if (ActiveProfile == null || !FlightSimData.HasCurrentMsfsAircraft) return false; - var uProfile = Profiles.FirstOrDefault(u => u.BindingAircraftLiveries.Any(p => p == FlightSimData.CurrentMsfsPlaneTitle)); + var uProfile = Profiles.FirstOrDefault(u => u.BindingAircrafts.Any(p => p == FlightSimData.CurrentMsfsAircraft)); if (uProfile != null && uProfile.ProfileId != ActiveProfile.ProfileId) return false; - if (FlightSimData == null || ActiveProfile.BindingAircraftLiveries == null) + if (FlightSimData == null || ActiveProfile.BindingAircrafts == null) return false; - return ActiveProfile == null ? false : !ActiveProfile.BindingAircraftLiveries.Any(p => p == FlightSimData.CurrentMsfsPlaneTitle); + return ActiveProfile == null ? false : !ActiveProfile.BindingAircrafts.Any(p => p == FlightSimData.CurrentMsfsAircraft); } } @@ -160,12 +160,12 @@ namespace MSFSPopoutPanelManager.Orchestration UpdateActiveProfile(currentProfileId); } - public void AutoSwitchProfile(string activeAircraftTitle) + public void AutoSwitchProfile(string activeAircraft) { - // Automatic switching of active profile when SimConnect active aircraft livery changes + // Automatic switching of active profile when SimConnect active aircraft changes if (Profiles != null) { - var matchedProfile = Profiles.FirstOrDefault(p => p.BindingAircraftLiveries.Any(t => t == activeAircraftTitle)); + var matchedProfile = Profiles.FirstOrDefault(p => p.BindingAircrafts.Any(t => t == activeAircraft)); if (matchedProfile != null) UpdateActiveProfile(matchedProfile.ProfileId); } diff --git a/Orchestration/ProfileOrchestrator.cs b/Orchestration/ProfileOrchestrator.cs index 14676f4..c6b7824 100644 --- a/Orchestration/ProfileOrchestrator.cs +++ b/Orchestration/ProfileOrchestrator.cs @@ -26,16 +26,16 @@ namespace MSFSPopoutPanelManager.Orchestration ProfileData.UpdateActiveProfile(profileId); } - public void AddProfileBinding(string bindingLiveryName) + public void AddProfileBinding(string bindingAircraft) { if (ProfileData.ActiveProfile != null) - ProfileData.AddProfileBinding(bindingLiveryName, ProfileData.ActiveProfile.ProfileId); + ProfileData.AddProfileBinding(bindingAircraft, ProfileData.ActiveProfile.ProfileId); } - public void DeleteProfileBinding(string bindingLiveryName) + public void DeleteProfileBinding(string bindingAircraft) { if (ProfileData.ActiveProfile != null) - ProfileData.DeleteProfileBinding(bindingLiveryName, ProfileData.ActiveProfile.ProfileId); + ProfileData.DeleteProfileBinding(bindingAircraft, ProfileData.ActiveProfile.ProfileId); } } } diff --git a/README.md b/README.md index 204b937..bac579e 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ If using SpaceDesk to host pop out panel display, since there is a latency for t * Intuitive user interface to defined location of panels to be popped out. -* [Auto Pop Out](#auto-pop-out-feature) feature. The application will detect active aircraft by livery and activate the corresponding profile on start of new flight session. +* [Auto Pop Out](#auto-pop-out-feature) feature. The application will detect active aircraft and activate the corresponding profile on start of new flight session. * [Cold Start feature](#auto-pop-out-feature). Instrumentation panels can be popped out even when they're not powered on (for G1000 / / G1000 NXi planes only). @@ -96,7 +96,7 @@ What if you can do the setup once by defining on screen where the pop out panels

-2. For step 2, if you want to associate the profile to the current aircraft livery to use in [Auto Pop Out](#auto-pop-out-feature) feature or for automatic profile switching when selecting a different aircraft, click the "plus" button next to the aircraft livery name. The aircraft livery title will become green once the livery is bound to the profile. Your chosen livery may not be available to select in the application for your newly selected plane until a flight is started. +2. For step 2, if you want to associate the profile to the current aircraft to use in [Auto Pop Out](#auto-pop-out-feature) feature or for automatic profile switching when selecting a different aircraft, click the "plus" button next to the aircraft name. The aircraft title will become green once the it is bound to the profile. Your chosen aircraft may not be available to select in the application for your newly selected plane until a flight is started.

@@ -134,19 +134,17 @@ What if you can do the setup once by defining on screen where the pop out panels [Online Video - How to enable auto pop out panels](https://vimeo.com/723165248) -The app will try to find a matching profile with the current selected aircraft livery. It will then detect when a flight is starting and automatically click the "Ready to Fly" button. It will also power on instrumentation for cold start (for G1000/NXi equipped plane only), and then pop out all panels. This feature allows panels to be popped out without the need of user interaction. If profiles are set and bound to your frequently used aircraft livery, you can auto-start the app minimized in system tray and as you start your flight, panels will automatically pop out for you for the selected aircraft. +The app will try to find a matching profile with the current selected aircraft. It will then detect when a flight is starting and automatically click the "Ready to Fly" button. It will also power on instrumentation for cold start (for G1000/NXi equipped plane only), and then pop out all panels. This feature allows panels to be popped out without the need of user interaction. If profiles are set and bound to your frequently used aircraft, you can auto-start the app minimized in system tray and as you start your flight, panels will automatically pop out for you for the selected aircraft. * In File->Preferences->Auto Pop Out Panel Settings, "Enable Auto Pop Out Panels" option is turned on. You can also adjust wait delay settings if you've a fast computer. -* For existing profile to use Auto Pop Out feature, just click the plus sign in the bind active aircraft livery to profile section. This will bind the active aircraft livery being displayed to the profile. Any bound aircraft livery will appear in GREEN color. Unbound ones will be in WHITE, and bound livery in another profile will be in RED. You can bind as many liveries to a profile as you desire but a livery can only bind to a single profile so Auto Pop Out knows which profile to start when a flight session starts. +* For existing profile to use Auto Pop Out feature, just click the plus sign in the bind active aircraft to profile section. This will bind the active aircraft being displayed to the profile. Any bound aircraft will appear in GREEN color. Unbound ones will be in WHITE, and bound aircraft in another profile will be in RED. You can bind as many liveries to a profile as you desire but an aircraft can only bind to a single profile so Auto Pop Out knows which profile to start when a flight session starts. * During my testing, instrumentations only need to be powered on for Auto Pop Out to work for G1000/G1000 NXi plane during cold start. (There seems to be a bug in the game that you can't do Alt-Right click to pop out cold start panel for this particular plane variant). For other plane instrumentations I've tested (G3000, CJ4, Aerosoft CRJ 550/700, FBW A32NX), panels can be popped out without powering on. So please make sure the checkbox "Power on required to pop out panels on cold start" is checked for G1000 related profiles. -* **TIPS:** If you want to fly an aircraft with different livery, just add the aircraft livery binding to your desire profile when you switch livery. - * **TIPS:** You can go to the preference settings to configure the time delay for each steps for the Auto Pop Out process based on the speed of your computer if things do not work correctly or if you want to speed up the Auto Pop Out process. -* **TIPS:** One trick to force SimConnect to update the current selected aircraft livery so you can do the binding immediately after selecting a new livery in the World Map is to click the "Go Back" button at the lower left of your screen. You should see aircraft title changes to the active ones. Or you can wait until the flight is almost fully loaded and you will see the current aircraft livery name gets updated. +* **TIPS:** One trick to force SimConnect to update the current selected aircraft so you can do the binding immediately after selecting a new aircraft in the World Map is to click the "Go Back" button at the lower left of your screen. You should see aircraft title changes to the active ones. Or you can wait until the flight is almost fully loaded and you will see the current aircraft name gets updated.


diff --git a/SimconnectAgent/DataDefinition.cs b/SimconnectAgent/DataDefinition.cs index ed24e35..9be1285 100644 --- a/SimconnectAgent/DataDefinition.cs +++ b/SimconnectAgent/DataDefinition.cs @@ -13,6 +13,7 @@ namespace MSFSPopoutPanelManager.SimConnectAgent definitions.Add(new SimConnectDataDefinition() { DataDefinitionType = DataDefinitionType.SimConnect, PropName = "TrackIREnable", VariableName = "TRACK IR ENABLE", SimConnectUnit = "Bool", DataType = DataType.Float64, DefaultValue = String.Empty, JavaScriptFormatting = null }); definitions.Add(new SimConnectDataDefinition() { DataDefinitionType = DataDefinitionType.SimConnect, PropName = "PlaneInParkingSpot", VariableName = "ATC ON PARKING SPOT", SimConnectUnit = "Bool", DataType = DataType.Float64, DefaultValue = String.Empty, JavaScriptFormatting = null }); definitions.Add(new SimConnectDataDefinition() { DataDefinitionType = DataDefinitionType.SimConnect, PropName = "CameraState", VariableName = "CAMERA STATE", SimConnectUnit = "Number", DataType = DataType.Float64, DefaultValue = String.Empty, JavaScriptFormatting = null }); + definitions.Add(new SimConnectDataDefinition() { DataDefinitionType = DataDefinitionType.SimEvent, PropName = "AircraftName", VariableName = "", SimConnectUnit = "", DataType = DataType.String, DefaultValue = String.Empty, JavaScriptFormatting = null }); return definitions; } } diff --git a/SimconnectAgent/Enums.cs b/SimconnectAgent/Enums.cs index e4e0472..e904778 100644 --- a/SimconnectAgent/Enums.cs +++ b/SimconnectAgent/Enums.cs @@ -51,6 +51,7 @@ namespace MSFSPopoutPanelManager.SimConnectAgent SIMSTART, SIMSTOP, FLIGHTLOADED, + AIRCRAFTLOADED, PAUSED, VIEW, NONE diff --git a/SimconnectAgent/SimConnectDataDefinition.cs b/SimconnectAgent/SimConnectDataDefinition.cs index b29acd8..5cbc62f 100644 --- a/SimconnectAgent/SimConnectDataDefinition.cs +++ b/SimconnectAgent/SimConnectDataDefinition.cs @@ -38,7 +38,8 @@ { AVar, LVar, - SimConnect + SimConnect, + SimEvent } public enum DataType diff --git a/SimconnectAgent/SimConnector.cs b/SimconnectAgent/SimConnector.cs index e266608..4a14d19 100644 --- a/SimconnectAgent/SimConnector.cs +++ b/SimconnectAgent/SimConnector.cs @@ -152,6 +152,7 @@ namespace MSFSPopoutPanelManager.SimConnectAgent _simConnect.OnRecvException += HandleOnRecvException; _simConnect.OnRecvEvent += HandleOnReceiveSystemEvent; _simConnect.OnRecvSimobjectDataBytype += HandleOnRecvSimobjectDataBytype; + _simConnect.OnRecvEventFilename += HandleOnRecvEventFilename; // Register simConnect system events _simConnect.UnsubscribeFromSystemEvent(SimConnectSystemEvent.SIMSTART); @@ -160,6 +161,8 @@ namespace MSFSPopoutPanelManager.SimConnectAgent _simConnect.SubscribeToSystemEvent(SimConnectSystemEvent.SIMSTOP, "SimStop"); _simConnect.UnsubscribeFromSystemEvent(SimConnectSystemEvent.VIEW); _simConnect.SubscribeToSystemEvent(SimConnectSystemEvent.VIEW, "View"); + _simConnect.UnsubscribeFromSystemEvent(SimConnectSystemEvent.AIRCRAFTLOADED); + _simConnect.SubscribeToSystemEvent(SimConnectSystemEvent.AIRCRAFTLOADED, "AircraftLoaded"); System.Threading.Thread.Sleep(5000); ReceiveMessage(); @@ -171,6 +174,20 @@ namespace MSFSPopoutPanelManager.SimConnectAgent StatusMessageWriter.WriteMessage("MSFS is connected", StatusMessageType.Info, false); } + private void HandleOnRecvEventFilename(SimConnect sender, SIMCONNECT_RECV_EVENT_FILENAME data) + { + switch (data.uEventID) + { + case (uint)SimConnectSystemEvent.AIRCRAFTLOADED: + var filePathToken = data.szFileName.Split(@"\"); + var aircraftName = filePathToken[filePathToken.Length - 2]; + aircraftName = aircraftName.Replace("_", " ").ToUpper(); + + SimConnectDataDefinitions.Find(s => s.PropName == "AircraftName").Value = aircraftName; + break; + } + } + private void AddDataDefinitions() { int definitionId = 1; @@ -180,33 +197,36 @@ namespace MSFSPopoutPanelManager.SimConnectAgent foreach (var definition in SimConnectDataDefinitions) { - SIMCONNECT_DATATYPE simmConnectDataType; - switch (definition.DataType) + if (definition.DataDefinitionType == DataDefinitionType.SimConnect) { - case DataType.String: - simmConnectDataType = SIMCONNECT_DATATYPE.STRING256; - break; - case DataType.Float64: - simmConnectDataType = SIMCONNECT_DATATYPE.FLOAT64; - break; - default: - simmConnectDataType = SIMCONNECT_DATATYPE.FLOAT64; - break; + SIMCONNECT_DATATYPE simmConnectDataType; + switch (definition.DataType) + { + case DataType.String: + simmConnectDataType = SIMCONNECT_DATATYPE.STRING256; + break; + case DataType.Float64: + simmConnectDataType = SIMCONNECT_DATATYPE.FLOAT64; + break; + default: + simmConnectDataType = SIMCONNECT_DATATYPE.FLOAT64; + break; + } + + _simConnect.AddToDataDefinition((SIMCONNECT_DEFINE_ID)definitionId, definition.VariableName, definition.SimConnectUnit, simmConnectDataType, 0.0f, SimConnect.SIMCONNECT_UNUSED); + + // Assign definition id and request id back into definition object + definition.DefineId = (SIMCONNECT_DEFINE_ID)definitionId; + definition.RequestId = (SIMCONNECT_REQUEST)requestId; + + if (definition.DataType == DataType.String) + _simConnect.RegisterDataDefineStruct(definition.DefineId); + else + _simConnect.RegisterDataDefineStruct(definition.DefineId); + + definitionId++; + requestId++; } - - _simConnect.AddToDataDefinition((SIMCONNECT_DEFINE_ID)definitionId, definition.VariableName, definition.SimConnectUnit, simmConnectDataType, 0.0f, SimConnect.SIMCONNECT_UNUSED); - - // Assign definition id and request id back into definition object - definition.DefineId = (SIMCONNECT_DEFINE_ID)definitionId; - definition.RequestId = (SIMCONNECT_REQUEST)requestId; - - if (definition.DataType == DataType.String) - _simConnect.RegisterDataDefineStruct(definition.DefineId); - else - _simConnect.RegisterDataDefineStruct(definition.DefineId); - - definitionId++; - requestId++; } // Setup SimEvent mapping diff --git a/UserDataAgent/Profile.cs b/UserDataAgent/Profile.cs index 5acc4f4..b7c598c 100644 --- a/UserDataAgent/Profile.cs +++ b/UserDataAgent/Profile.cs @@ -9,7 +9,7 @@ namespace MSFSPopoutPanelManager.UserDataAgent { public Profile() { - BindingAircraftLiveries = new ObservableCollection(); + BindingAircrafts = new ObservableCollection(); PanelConfigs = new ObservableCollection(); PanelSourceCoordinates = new ObservableCollection(); TouchPanelBindings = new ObservableCollection(); @@ -21,7 +21,7 @@ namespace MSFSPopoutPanelManager.UserDataAgent public string ProfileName { get; set; } [JsonConverter(typeof(SingleValueArrayConvertor))] - public ObservableCollection BindingAircraftLiveries { get; set; } + public ObservableCollection BindingAircrafts { get; set; } public ObservableCollection PanelSourceCoordinates { get; set; } @@ -37,14 +37,14 @@ namespace MSFSPopoutPanelManager.UserDataAgent public bool IsActive { get; set; } [JsonIgnore] - public bool HasBindingAircraftLiveries + public bool HasBindingAircrafts { get { - if (BindingAircraftLiveries == null) + if (BindingAircrafts == null) return false; - return BindingAircraftLiveries.Count > 0; + return BindingAircrafts.Count > 0; } } diff --git a/UserDataAgent/ProfileManager.cs b/UserDataAgent/ProfileManager.cs index eaa4c19..88fe4a4 100644 --- a/UserDataAgent/ProfileManager.cs +++ b/UserDataAgent/ProfileManager.cs @@ -28,7 +28,7 @@ namespace MSFSPopoutPanelManager.UserDataAgent var matchedProfile = profiles.FirstOrDefault(p => p.ProfileId == copyProfileId); var copiedProfile = matchedProfile.Copy(); // Using Shared/ObjectExtensions.cs extension method - copiedProfile.BindingAircraftLiveries = new ObservableCollection(); + copiedProfile.BindingAircrafts = new ObservableCollection(); return AddProfile(copiedProfile, newProfileName, profiles); } @@ -46,24 +46,24 @@ namespace MSFSPopoutPanelManager.UserDataAgent return true; } - public static void AddProfileBinding(string planeTitle, int activeProfileId, IList profiles) + public static void AddProfileBinding(string aircraft, int activeProfileId, IList profiles) { - var boundProfile = profiles.FirstOrDefault(p => p.BindingAircraftLiveries.Any(p => p == planeTitle)); + var boundProfile = profiles.FirstOrDefault(p => p.BindingAircrafts.Any(p => p == aircraft)); if (boundProfile != null) { - StatusMessageWriter.WriteMessage($"Unable to add binding to the profile because '{planeTitle}' was already bound to profile '{boundProfile.ProfileName}'.", StatusMessageType.Error, false); + StatusMessageWriter.WriteMessage($"Unable to add binding to the profile because '{aircraft}' was already bound to profile '{boundProfile.ProfileName}'.", StatusMessageType.Error, false); return; } - profiles.First(p => p.ProfileId == activeProfileId).BindingAircraftLiveries.Add(planeTitle); + profiles.First(p => p.ProfileId == activeProfileId).BindingAircrafts.Add(aircraft); WriteProfiles(profiles); StatusMessageWriter.WriteMessage($"Binding for the profile has been added successfully.", StatusMessageType.Info, false); } - public static void DeleteProfileBinding(string planeTitle, int activeProfileId, IList profiles) + public static void DeleteProfileBinding(string aircraft, int activeProfileId, IList profiles) { - profiles.First(p => p.ProfileId == activeProfileId).BindingAircraftLiveries.Remove(planeTitle); + profiles.First(p => p.ProfileId == activeProfileId).BindingAircrafts.Remove(aircraft); WriteProfiles(profiles); StatusMessageWriter.WriteMessage($"Binding for the profile has been deleted successfully.", StatusMessageType.Info, false); diff --git a/VERSION.md b/VERSION.md index 34e5930..cabccbd 100644 --- a/VERSION.md +++ b/VERSION.md @@ -3,16 +3,16 @@ ## Version 3.4.1 -This release is solely focus on addressing issues regarding touch panel capabilities as well as making improvements to touch feature. Panels I used for testing are +This release is solely focused on addressing issues regarding touch panel capabilities as well as making improvements to touch feature. Panels I used for testing are PMT GTN750, WT G3X mod, PMS GTN530, FBW A32NX EFB, King Air 350 PFD/MFD touch screen. -When using SpaceDesk, please increase touch down touch up delay to 25ms in preference touch settings to improve sensitivity in registering touch input. +When using SpaceDesk, please increase touch down touch up delay to 25ms in preference touch settings to improve sensitivity for touch input. * Implemented new algorithm to improve general performance for touch panel. * Button touches are now more responsive. On touch monitor, lag after touch had been minimized and is now performing much closer to a mouse click. On SpaceDesk, the lag is more in line with latency of remote display technology. When using SpaceDesk, you can increase touch delay to 25ms in preference settings to account for the latency if your touch is not register consistently. -* You can now slide your finger to pan the map in panel. There is still a slight delay but touch response is much improved. +* You can now slide your finger to pan map in panel. There is still a slight delay but touch response is much improved. * Full screen mode for touch panel can now be turned on. diff --git a/WindowsAgent/InputEmulationManager.cs b/WindowsAgent/InputEmulationManager.cs index 4afcbd9..513046e 100644 --- a/WindowsAgent/InputEmulationManager.cs +++ b/WindowsAgent/InputEmulationManager.cs @@ -15,6 +15,7 @@ namespace MSFSPopoutPanelManager.WindowsAgent const uint VK_RMENU = 0xA5; const uint VK_LMENU = 0xA4; const uint VK_LCONTROL = 0xA2; + const uint VK_RCONTROL = 0xA3; const uint VK_SPACE = 0x20; const uint VK_ENT = 0x0D; const uint KEY_0 = 0x30; @@ -102,6 +103,11 @@ namespace MSFSPopoutPanelManager.WindowsAgent if (simualatorProcess == null) return; + CenterView(simualatorProcess); + } + + public static void CenterView(WindowProcess simualatorProcess) + { Rectangle rectangle; PInvoke.GetWindowRect(simualatorProcess.Handle, out rectangle); @@ -113,14 +119,13 @@ namespace MSFSPopoutPanelManager.WindowsAgent PInvoke.SetForegroundWindow(simualatorProcess.Handle); LeftClick(x, y); - Thread.Sleep(200); // First center view using Ctrl-Space - PInvoke.keybd_event(Convert.ToByte(VK_LCONTROL), 0, KEYEVENTF_KEYDOWN, 0); + PInvoke.keybd_event(Convert.ToByte(VK_RCONTROL), 0, KEYEVENTF_KEYDOWN, 0); PInvoke.keybd_event(Convert.ToByte(VK_SPACE), 0, KEYEVENTF_KEYDOWN, 0); Thread.Sleep(200); PInvoke.keybd_event(Convert.ToByte(VK_SPACE), 0, KEYEVENTF_KEYUP, 0); - PInvoke.keybd_event(Convert.ToByte(VK_LCONTROL), 0, KEYEVENTF_KEYUP, 0); + PInvoke.keybd_event(Convert.ToByte(VK_RCONTROL), 0, KEYEVENTF_KEYUP, 0); Thread.Sleep(200); } diff --git a/WpfApp/UserControlPanelSelection.xaml b/WpfApp/UserControlPanelSelection.xaml index 1c3f054..7f3ee91 100644 --- a/WpfApp/UserControlPanelSelection.xaml +++ b/WpfApp/UserControlPanelSelection.xaml @@ -45,12 +45,12 @@ -