using System.Windows;
using CyberX8_Simulator.Instances;
using MECF.Framework.UI.Core.Applications;
using CyberX8_Core;
using System;
namespace CyberX8_Simulator
{
///
/// App.xaml 的交互逻辑
///
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
base.OnStartup(e);
SystemConfig.Instance.Initialize();
//SimulatorJetChamber.CurrentPMAChamber = (JetChamber)SystemConfig.Instance.GetValue($"PMA.ChamberType");
//SimulatorJetChamber.CurrentPMBChamber = (JetChamber)SystemConfig.Instance.GetValue($"PMB.ChamberType");
//SimulatorJetChamber.CurrentPMCChamber = (JetChamber)SystemConfig.Instance.GetValue($"PMC.ChamberType");
//SimulatorJetChamber.CurrentPMDChamber = (JetChamber)SystemConfig.Instance.GetValue($"PMD.ChamberType");
UiApplication.Instance.Initialize(new UiInstance());
SimulatorSystem.Instance.Initialize();
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
ShowMessageDialog((Exception)e.ExceptionObject);
}
static void ShowMessageDialog(Exception ex)
{
string message = string.Format(" UI unknown exception:{0},\n", $"{ex.StackTrace} {DateTime.Now}");
System.Windows.MessageBox.Show(message + ex.Message, "Unexpected exception", System.Windows.MessageBoxButton.YesNo,
System.Windows.MessageBoxImage.Exclamation,
System.Windows.MessageBoxResult.No,
System.Windows.MessageBoxOptions.DefaultDesktopOnly);
//Environment.Exit(0);
}
protected override void OnExit(ExitEventArgs e)
{
UiApplication.Instance.Terminate();
SimulatorSystem.Instance.Terminate();
base.OnExit(e);
}
}
}