mirror of
https://github.com/hawkeye-stan/msfs-popout-panel-manager.git
synced 2024-11-24 14:50:10 +00:00
43caff1ca9
commit 2bbda3c4e4969fdf05566908fde01f1c9e4e23f7 Author: Stanley <hawkeyesk@outlook.com> Date: Mon Sep 5 23:54:39 2022 -0400 Added in-game panel support commit ec29b0ec2612b10e45ab9a73c10b88a98fcf6eaf Author: Stanley <hawkeyesk@outlook.com> Date: Sun Sep 4 21:21:37 2022 -0400 Added in-game panel support commit 97edc184f349e1fde74a15a643fb90fb9bd90395 Author: Stanley <hawkeyesk@outlook.com> Date: Thu Sep 1 18:08:44 2022 -0400 Update touch panel commit da48ca0a272290466952c5c1bd1ca035d56f930c Author: Stanley <hawkeyesk@outlook.com> Date: Mon Aug 29 22:19:38 2022 -0400 Added pop out panel temporary display commit 701346193804f93616b0e6e2222d9d55223f516f Author: Stanley <hawkeyesk@outlook.com> Date: Wed Aug 24 10:33:59 2022 -0400 Added auto resize window display mode commit 98cbcd949f1555b44db22267ce5c54858bef47cd Author: Stanley <hawkeyesk@outlook.com> Date: Wed Aug 24 09:39:38 2022 -0400 Added auto resize window display mode
141 lines
5.5 KiB
C#
141 lines
5.5 KiB
C#
using AutoUpdaterDotNET;
|
|
using MSFSPopoutPanelManager.Shared;
|
|
using System;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MSFSPopoutPanelManager.Orchestration
|
|
{
|
|
public class MainOrchestrator : ObservableObject
|
|
{
|
|
private IntPtr _msfsGameWindowHandle;
|
|
|
|
public MainOrchestrator()
|
|
{
|
|
_msfsGameWindowHandle = IntPtr.Zero;
|
|
|
|
Profile = new ProfileOrchestrator();
|
|
PanelSource = new PanelSourceOrchestrator();
|
|
PanelPopOut = new PanelPopOutOrchestrator();
|
|
PanelConfiguration = new PanelConfigurationOrchestrator();
|
|
FlightSim = new FlightSimOrchestrator();
|
|
OnlineFeature = new OnlineFeatureOrchestrator();
|
|
TouchPanel = new TouchPanelOrchestrator();
|
|
|
|
FlightSimData = new FlightSimData();
|
|
FlightSimData.CurrentMsfsAircraftChanged += (sernder, e) => { ProfileData.RefreshProfile(); ProfileData.AutoSwitchProfile(); };
|
|
FlightSimData.CurrentMsfsLiveryTitleChanged += (sernder, e) => { ProfileData.MigrateLiveryToAircraftBinding(); ProfileData.AutoSwitchProfile(); };
|
|
|
|
AppSettingData = new AppSettingData();
|
|
AppSettingData.TouchPanelIntegrationChanged += async (sender, e) =>
|
|
{
|
|
await TouchPanel.TouchPanelIntegrationUpdated(e);
|
|
};
|
|
|
|
ProfileData = new ProfileData();
|
|
ProfileData.FlightSimData = FlightSimData;
|
|
ProfileData.AppSettingData = AppSettingData;
|
|
ProfileData.ActiveProfileChanged += (sender, e) =>
|
|
{
|
|
PanelSource.CloseAllPanelSource();
|
|
};
|
|
}
|
|
|
|
public ProfileOrchestrator Profile { get; set; }
|
|
|
|
public PanelSourceOrchestrator PanelSource { get; set; }
|
|
|
|
public PanelPopOutOrchestrator PanelPopOut { get; set; }
|
|
|
|
public PanelConfigurationOrchestrator PanelConfiguration { get; set; }
|
|
|
|
public TouchPanelOrchestrator TouchPanel { get; set; }
|
|
|
|
public ProfileData ProfileData { get; set; }
|
|
|
|
public AppSettingData AppSettingData { get; private set; }
|
|
|
|
public FlightSimData FlightSimData { get; private set; }
|
|
|
|
public FlightSimOrchestrator FlightSim { get; set; }
|
|
|
|
public OnlineFeatureOrchestrator OnlineFeature { get; set; }
|
|
|
|
public IntPtr ApplicationHandle { get; set; }
|
|
|
|
public async void Initialize()
|
|
{
|
|
MigrateData.MigrateUserDataFiles();
|
|
|
|
AppSettingData.ReadSettings();
|
|
ProfileData.ReadProfiles();
|
|
|
|
Profile.ProfileData = ProfileData;
|
|
Profile.FlightSimData = FlightSimData;
|
|
|
|
PanelSource.ProfileData = ProfileData;
|
|
PanelSource.AppSettingData = AppSettingData;
|
|
PanelSource.FlightSimData = FlightSimData;
|
|
PanelSource.FlightSimOrchestrator = FlightSim;
|
|
|
|
PanelPopOut.ProfileData = ProfileData;
|
|
PanelPopOut.AppSettingData = AppSettingData;
|
|
PanelPopOut.FlightSimData = FlightSimData;
|
|
PanelPopOut.FlightSimOrchestrator = FlightSim;
|
|
PanelPopOut.PanelSourceOrchestrator = PanelSource;
|
|
PanelPopOut.TouchPanelOrchestrator = TouchPanel;
|
|
PanelPopOut.OnPopOutCompleted += (sender, e) => TouchPanel.ReloadTouchPanelSimConnectDataDefinition();
|
|
|
|
PanelConfiguration.ProfileData = ProfileData;
|
|
PanelConfiguration.AppSettingData = AppSettingData;
|
|
|
|
FlightSim.ProfileData = ProfileData;
|
|
FlightSim.AppSettingData = AppSettingData;
|
|
FlightSim.FlightSimData = FlightSimData;
|
|
FlightSim.OnFlightStartedForAutoPopOut += (sender, e) => PanelPopOut.AutoPopOut();
|
|
|
|
TouchPanel.ProfileData = ProfileData;
|
|
TouchPanel.AppSettingData = AppSettingData;
|
|
TouchPanel.ApplicationHandle = ApplicationHandle;
|
|
|
|
CheckForAutoUpdate();
|
|
|
|
ProfileData.UpdateActiveProfile(AppSettingData.AppSetting.LastUsedProfileId); // Load last used profile
|
|
FlightSim.StartSimConnectServer(); // Start the SimConnect server
|
|
|
|
// Enable/Disable touch panel feature (Personal use only feature)
|
|
try
|
|
{
|
|
var assembly = Assembly.LoadFrom(Path.Combine(AppContext.BaseDirectory, "WebServer.dll"));
|
|
if (assembly != null)
|
|
AppSettingData.AppSetting.IsEnabledTouchPanelServer = true;
|
|
|
|
if (AppSettingData.AppSetting.TouchPanelSettings.EnableTouchPanelIntegration)
|
|
await TouchPanel.StartServer();
|
|
|
|
assembly = null;
|
|
}
|
|
catch { }
|
|
}
|
|
|
|
public async Task ApplicationClose()
|
|
{
|
|
// Force unhook all win events
|
|
PanelConfiguration.EndConfiguration();
|
|
FlightSim.EndSimConnectServer(true);
|
|
await TouchPanel.StopServer();
|
|
}
|
|
|
|
private void CheckForAutoUpdate()
|
|
{
|
|
string jsonPath = Path.Combine(Path.Combine(FileIo.GetUserDataFilePath(), "autoupdate.json"));
|
|
AutoUpdater.PersistenceProvider = new JsonFilePersistenceProvider(jsonPath);
|
|
AutoUpdater.Synchronous = true;
|
|
AutoUpdater.AppTitle = "MSFS Pop Out Panel Manager";
|
|
AutoUpdater.RunUpdateAsAdmin = false;
|
|
AutoUpdater.UpdateFormSize = new System.Drawing.Size(930, 675);
|
|
AutoUpdater.Start(AppSettingData.AppSetting.AutoUpdaterUrl);
|
|
}
|
|
}
|
|
}
|