2022-07-23 19:23:32 +00:00
|
|
|
|
using MSFSPopoutPanelManager.Shared;
|
2022-08-02 15:51:28 +00:00
|
|
|
|
using System.Linq;
|
2022-07-23 19:23:32 +00:00
|
|
|
|
|
|
|
|
|
namespace MSFSPopoutPanelManager.Orchestration
|
|
|
|
|
{
|
|
|
|
|
public class ProfileOrchestrator : ObservableObject
|
|
|
|
|
{
|
|
|
|
|
internal ProfileData ProfileData { get; set; }
|
|
|
|
|
|
2022-08-02 15:51:28 +00:00
|
|
|
|
internal FlightSimData FlightSimData { get; set; }
|
|
|
|
|
|
2022-07-23 19:23:32 +00:00
|
|
|
|
public void AddProfile(string profileName, int copyProfileId)
|
|
|
|
|
{
|
|
|
|
|
if (copyProfileId == -1)
|
|
|
|
|
ProfileData.AddProfile(profileName);
|
|
|
|
|
else
|
|
|
|
|
ProfileData.AddProfile(profileName, copyProfileId);
|
2022-08-02 15:51:28 +00:00
|
|
|
|
|
|
|
|
|
// Automatically bind aircraft
|
|
|
|
|
var boundProfile = ProfileData.Profiles.FirstOrDefault(p => p.BindingAircrafts.Any(p => p == FlightSimData.CurrentMsfsAircraft));
|
|
|
|
|
if (boundProfile == null && FlightSimData.HasCurrentMsfsAircraft)
|
|
|
|
|
{
|
|
|
|
|
ProfileData.ActiveProfile.BindingAircrafts.Add(FlightSimData.CurrentMsfsAircraft);
|
|
|
|
|
ProfileData.WriteProfiles();
|
|
|
|
|
ProfileData.RefreshProfile();
|
|
|
|
|
}
|
2022-07-23 19:23:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DeleteActiveProfile()
|
|
|
|
|
{
|
|
|
|
|
if (ProfileData.ActiveProfile != null)
|
|
|
|
|
ProfileData.DeleteProfile(ProfileData.ActiveProfile.ProfileId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ChangeProfile(int profileId)
|
|
|
|
|
{
|
|
|
|
|
if (ProfileData != null)
|
|
|
|
|
ProfileData.UpdateActiveProfile(profileId);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 23:21:42 +00:00
|
|
|
|
public void AddProfileBinding(string bindingAircraft)
|
2022-07-23 19:23:32 +00:00
|
|
|
|
{
|
|
|
|
|
if (ProfileData.ActiveProfile != null)
|
2022-08-01 23:21:42 +00:00
|
|
|
|
ProfileData.AddProfileBinding(bindingAircraft, ProfileData.ActiveProfile.ProfileId);
|
2022-07-23 19:23:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 23:21:42 +00:00
|
|
|
|
public void DeleteProfileBinding(string bindingAircraft)
|
2022-07-23 19:23:32 +00:00
|
|
|
|
{
|
|
|
|
|
if (ProfileData.ActiveProfile != null)
|
2022-08-01 23:21:42 +00:00
|
|
|
|
ProfileData.DeleteProfileBinding(bindingAircraft, ProfileData.ActiveProfile.ProfileId);
|
2022-07-23 19:23:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|