1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-21 13:20:11 +00:00

Update timing code

This commit is contained in:
hawkeye 2023-08-01 23:39:03 -04:00
parent 988ffae245
commit d169223912
4 changed files with 62 additions and 57 deletions

View file

@ -5,6 +5,9 @@ using MSFSPopoutPanelManager.Orchestration;
using MSFSPopoutPanelManager.Shared;
using MSFSPopoutPanelManager.WindowsAgent;
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
@ -26,7 +29,17 @@ namespace MSFSPopoutPanelManager.MainApp
DpiAwareness.Enable();
// Must run this first
Initialize();
if(IsRunning())
{
//app is already running! Exiting the application
Application.Current.Shutdown();
}
else
{
// Setup all unhandle exception handlers
Dispatcher.UnhandledException += HandleDispatcherException;
TaskScheduler.UnobservedTaskException += HandleTaskSchedulerUnobservedTaskException;
AppDomain.CurrentDomain.UnhandledException += HandledDomainException;
// Setup dependency injections
AppHost = Host.CreateDefaultBuilder()
@ -60,35 +73,20 @@ namespace MSFSPopoutPanelManager.MainApp
MainWindow = AppHost.Services.GetRequiredService<AppWindow>();
MainWindow.Show();
base.OnStartup(e);
// Setup orchestration UI handler
var orchestrationUIHelper = App.AppHost.Services.GetRequiredService<OrchestratorUIHelper>();
// Setup message window dialog
var messageWindow = new MessageWindow();
messageWindow.Show();
base.OnStartup(e);
}
}
private void Initialize()
private bool IsRunning()
{
const string appName = "MSFS PopOut Panel Manager";
bool createdNew;
var mutex = new Mutex(true, appName, out createdNew);
if (!createdNew)
{
//app is already running! Exiting the application
Application.Current.Shutdown();
}
else
{
// Setup all unhandle exception handlers
Dispatcher.UnhandledException += HandleDispatcherException;
TaskScheduler.UnobservedTaskException += HandleTaskSchedulerUnobservedTaskException;
AppDomain.CurrentDomain.UnhandledException += HandledDomainException;
}
return Process.GetProcesses().Count(p => p.ProcessName.Contains(Assembly.GetEntryAssembly().GetName().Name)) > 1;
}
private void HandleTaskSchedulerUnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e)

View file

@ -186,6 +186,7 @@ namespace MSFSPopoutPanelManager.Orchestration
// Remember current game's zoom level to be recall after pop out
_prePopOutCockpitZoomLevel = _flightSimData.CockpitCameraZoom;
InputEmulationManager.LoadCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding);
Thread.Sleep(1000);
FlightSimOrchestrator.SetCockpitCameraZoomLevel(50);
StatusMessageWriter.WriteOkStatusMessage();
}
@ -482,12 +483,13 @@ namespace MSFSPopoutPanelManager.Orchestration
switch (AppSetting.PopOutSetting.AfterPopOutCameraView.CameraView)
{
case AfterPopOutCameraViewType.CockpitCenterView:
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePopOutCockpitZoomLevel);
InputEmulationManager.CenterView();
Thread.Sleep(500);
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePopOutCockpitZoomLevel);
break;
case AfterPopOutCameraViewType.CustomCameraView:
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePopOutCockpitZoomLevel);
InputEmulationManager.LoadCustomView(AppSetting.PopOutSetting.AfterPopOutCameraView.KeyBinding);
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePopOutCockpitZoomLevel);
break;
}
}

View file

@ -100,20 +100,22 @@ namespace MSFSPopoutPanelManager.Orchestration
// Recenter game or return to after pop out camera view
if (!AppSetting.PopOutSetting.AfterPopOutCameraView.IsEnabled)
{
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePanelConfigurationCockpitZoomLevel);
InputEmulationManager.CenterView();
Thread.Sleep(500);
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePanelConfigurationCockpitZoomLevel);
}
else
{
switch (AppSetting.PopOutSetting.AfterPopOutCameraView.CameraView)
{
case AfterPopOutCameraViewType.CockpitCenterView:
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePanelConfigurationCockpitZoomLevel);
InputEmulationManager.CenterView();
Thread.Sleep(500);
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePanelConfigurationCockpitZoomLevel);
break;
case AfterPopOutCameraViewType.CustomCameraView:
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePanelConfigurationCockpitZoomLevel);
InputEmulationManager.LoadCustomView(AppSetting.PopOutSetting.AfterPopOutCameraView.KeyBinding);
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePanelConfigurationCockpitZoomLevel);
break;
}
}

View file

@ -141,6 +141,9 @@ namespace MSFSPopoutPanelManager.WindowsAgent
PInvoke.keybd_event(Convert.ToByte(customViewKey), 0, KEYEVENTF_KEYUP, 0);
PInvoke.keybd_event(Convert.ToByte(VK_LMENU), 0, KEYEVENTF_KEYUP, 0);
Thread.Sleep(200);
// Small delay to let load custom view finish
Thread.Sleep(500);
}
public static void ToggleFullScreenPanel(IntPtr hwnd)