3074/App.xaml.cs

50 lines
1.4 KiB
C#
Raw Normal View History

2024-04-05 18:12:07 +02:00
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Threading;
2024-04-05 21:41:56 +02:00
using tsf_3074.Data;
using tsf_3074.Window;
using tsf_3074.Windows.Dialog;
2024-04-05 18:12:07 +02:00
2024-04-05 21:41:56 +02:00
namespace tsf_3074
2024-04-05 18:12:07 +02:00
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App
{
private void App_OnStartup(object sender, StartupEventArgs e)
{
SetCurrentProcessExplicitAppUserModelID("com.squirrel.Tsf");
2024-04-05 21:41:56 +02:00
Config.Instance.ToString();
2024-04-05 18:12:07 +02:00
Tsf.FFullGame.ToString();
var window = new OverlayWindow();
window.Show();
}
private void App_OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
// export the exception info
var date = DateTime.Now;
var fileName = $"tsf-crash_{date.Day}_{date.Month}_{date.Year}-{date.Hour}_{date.Minute}_{date.Second}.txt";
using (var writer = new StreamWriter(fileName, true))
{
writer.WriteLine("##########" + DateTime.Now + "##########");
writer.WriteLine("An exception occurred when loading tsf.");
writer.WriteLine(e.Exception);
}
2024-04-05 18:41:29 +02:00
Console.WriteLine("TSF is crashed.");
2024-04-05 18:12:07 +02:00
Console.WriteLine(fileName);
2024-04-05 18:41:29 +02:00
Console.WriteLine(e.Exception);
2024-04-05 18:12:07 +02:00
e.Handled = true;
2024-04-05 18:41:29 +02:00
Shutdown();
2024-04-05 18:12:07 +02:00
}
[DllImport("shell32.dll", SetLastError = true)]
public static extern void SetCurrentProcessExplicitAppUserModelID(
[MarshalAs(UnmanagedType.LPWStr)] string appUserModelId);
}
}