mirror of
https://github.com/hawkeye-stan/msfs-popout-panel-manager.git
synced 2024-11-21 21:30:12 +00:00
Update timing code
This commit is contained in:
parent
988ffae245
commit
d169223912
4 changed files with 62 additions and 57 deletions
|
@ -5,6 +5,9 @@ using MSFSPopoutPanelManager.Orchestration;
|
||||||
using MSFSPopoutPanelManager.Shared;
|
using MSFSPopoutPanelManager.Shared;
|
||||||
using MSFSPopoutPanelManager.WindowsAgent;
|
using MSFSPopoutPanelManager.WindowsAgent;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -26,7 +29,17 @@ namespace MSFSPopoutPanelManager.MainApp
|
||||||
DpiAwareness.Enable();
|
DpiAwareness.Enable();
|
||||||
|
|
||||||
// Must run this first
|
// 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
|
// Setup dependency injections
|
||||||
AppHost = Host.CreateDefaultBuilder()
|
AppHost = Host.CreateDefaultBuilder()
|
||||||
|
@ -60,35 +73,20 @@ namespace MSFSPopoutPanelManager.MainApp
|
||||||
MainWindow = AppHost.Services.GetRequiredService<AppWindow>();
|
MainWindow = AppHost.Services.GetRequiredService<AppWindow>();
|
||||||
MainWindow.Show();
|
MainWindow.Show();
|
||||||
|
|
||||||
base.OnStartup(e);
|
|
||||||
|
|
||||||
// Setup orchestration UI handler
|
// Setup orchestration UI handler
|
||||||
var orchestrationUIHelper = App.AppHost.Services.GetRequiredService<OrchestratorUIHelper>();
|
var orchestrationUIHelper = App.AppHost.Services.GetRequiredService<OrchestratorUIHelper>();
|
||||||
|
|
||||||
// Setup message window dialog
|
// Setup message window dialog
|
||||||
var messageWindow = new MessageWindow();
|
var messageWindow = new MessageWindow();
|
||||||
messageWindow.Show();
|
messageWindow.Show();
|
||||||
|
|
||||||
|
base.OnStartup(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Initialize()
|
private bool IsRunning()
|
||||||
{
|
{
|
||||||
const string appName = "MSFS PopOut Panel Manager";
|
return Process.GetProcesses().Count(p => p.ProcessName.Contains(Assembly.GetEntryAssembly().GetName().Name)) > 1;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleTaskSchedulerUnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e)
|
private void HandleTaskSchedulerUnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e)
|
||||||
|
|
|
@ -186,6 +186,7 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
// Remember current game's zoom level to be recall after pop out
|
// Remember current game's zoom level to be recall after pop out
|
||||||
_prePopOutCockpitZoomLevel = _flightSimData.CockpitCameraZoom;
|
_prePopOutCockpitZoomLevel = _flightSimData.CockpitCameraZoom;
|
||||||
InputEmulationManager.LoadCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding);
|
InputEmulationManager.LoadCustomView(AppSetting.PopOutSetting.AutoPanning.KeyBinding);
|
||||||
|
Thread.Sleep(1000);
|
||||||
FlightSimOrchestrator.SetCockpitCameraZoomLevel(50);
|
FlightSimOrchestrator.SetCockpitCameraZoomLevel(50);
|
||||||
StatusMessageWriter.WriteOkStatusMessage();
|
StatusMessageWriter.WriteOkStatusMessage();
|
||||||
}
|
}
|
||||||
|
@ -482,12 +483,13 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
switch (AppSetting.PopOutSetting.AfterPopOutCameraView.CameraView)
|
switch (AppSetting.PopOutSetting.AfterPopOutCameraView.CameraView)
|
||||||
{
|
{
|
||||||
case AfterPopOutCameraViewType.CockpitCenterView:
|
case AfterPopOutCameraViewType.CockpitCenterView:
|
||||||
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePopOutCockpitZoomLevel);
|
|
||||||
InputEmulationManager.CenterView();
|
InputEmulationManager.CenterView();
|
||||||
|
Thread.Sleep(500);
|
||||||
|
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePopOutCockpitZoomLevel);
|
||||||
break;
|
break;
|
||||||
case AfterPopOutCameraViewType.CustomCameraView:
|
case AfterPopOutCameraViewType.CustomCameraView:
|
||||||
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePopOutCockpitZoomLevel);
|
|
||||||
InputEmulationManager.LoadCustomView(AppSetting.PopOutSetting.AfterPopOutCameraView.KeyBinding);
|
InputEmulationManager.LoadCustomView(AppSetting.PopOutSetting.AfterPopOutCameraView.KeyBinding);
|
||||||
|
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePopOutCockpitZoomLevel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,20 +100,22 @@ namespace MSFSPopoutPanelManager.Orchestration
|
||||||
// Recenter game or return to after pop out camera view
|
// Recenter game or return to after pop out camera view
|
||||||
if (!AppSetting.PopOutSetting.AfterPopOutCameraView.IsEnabled)
|
if (!AppSetting.PopOutSetting.AfterPopOutCameraView.IsEnabled)
|
||||||
{
|
{
|
||||||
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
|
||||||
InputEmulationManager.CenterView();
|
InputEmulationManager.CenterView();
|
||||||
|
Thread.Sleep(500);
|
||||||
|
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (AppSetting.PopOutSetting.AfterPopOutCameraView.CameraView)
|
switch (AppSetting.PopOutSetting.AfterPopOutCameraView.CameraView)
|
||||||
{
|
{
|
||||||
case AfterPopOutCameraViewType.CockpitCenterView:
|
case AfterPopOutCameraViewType.CockpitCenterView:
|
||||||
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
|
||||||
InputEmulationManager.CenterView();
|
InputEmulationManager.CenterView();
|
||||||
|
Thread.Sleep(500);
|
||||||
|
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
||||||
break;
|
break;
|
||||||
case AfterPopOutCameraViewType.CustomCameraView:
|
case AfterPopOutCameraViewType.CustomCameraView:
|
||||||
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
|
||||||
InputEmulationManager.LoadCustomView(AppSetting.PopOutSetting.AfterPopOutCameraView.KeyBinding);
|
InputEmulationManager.LoadCustomView(AppSetting.PopOutSetting.AfterPopOutCameraView.KeyBinding);
|
||||||
|
FlightSimOrchestrator.SetCockpitCameraZoomLevel(_prePanelConfigurationCockpitZoomLevel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,9 @@ namespace MSFSPopoutPanelManager.WindowsAgent
|
||||||
PInvoke.keybd_event(Convert.ToByte(customViewKey), 0, KEYEVENTF_KEYUP, 0);
|
PInvoke.keybd_event(Convert.ToByte(customViewKey), 0, KEYEVENTF_KEYUP, 0);
|
||||||
PInvoke.keybd_event(Convert.ToByte(VK_LMENU), 0, KEYEVENTF_KEYUP, 0);
|
PInvoke.keybd_event(Convert.ToByte(VK_LMENU), 0, KEYEVENTF_KEYUP, 0);
|
||||||
Thread.Sleep(200);
|
Thread.Sleep(200);
|
||||||
|
|
||||||
|
// Small delay to let load custom view finish
|
||||||
|
Thread.Sleep(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ToggleFullScreenPanel(IntPtr hwnd)
|
public static void ToggleFullScreenPanel(IntPtr hwnd)
|
||||||
|
|
Loading…
Reference in a new issue