diff --git a/GlennGUI/GlennGUI.Gtk/Program.cs b/GlennGUI/GlennGUI.Gtk/Program.cs index 4d5a553..7abd480 100644 --- a/GlennGUI/GlennGUI.Gtk/Program.cs +++ b/GlennGUI/GlennGUI.Gtk/Program.cs @@ -8,6 +8,24 @@ static class Program [STAThread] public static void Main(string[] args) { - new Application(Eto.Platforms.Gtk).Run(new MainForm()); + var app = new Application(Eto.Platforms.Gtk); + try + { + app.UnhandledException += ApplicationOnUnhandledException; + app.Run(new MainForm()); + } + catch (Exception e) + { + Console.WriteLine($"Unhandled Exception!\n*****Stack Trace*****\n\n{e}"); + } + + } + + private static void ApplicationOnUnhandledException(object sender, Eto.UnhandledExceptionEventArgs e) + { + Application.Instance.Invoke(() => + { + MessageBox.Show($"Unhandled Exception!\n*****Stack Trace*****\n\n{e.ExceptionObject}", "GTK", MessageBoxType.Error); + }); } } \ No newline at end of file diff --git a/GlennGUI/GlennGUI.Mac/Program.cs b/GlennGUI/GlennGUI.Mac/Program.cs index 77b9237..8e83bb5 100644 --- a/GlennGUI/GlennGUI.Mac/Program.cs +++ b/GlennGUI/GlennGUI.Mac/Program.cs @@ -8,6 +8,24 @@ static class Program [STAThread] public static void Main(string[] args) { - new Application(Eto.Platforms.Mac64).Run(new MainForm()); + var app = new Application(Eto.Platforms.macOS); + try + { + app.UnhandledException += ApplicationOnUnhandledException; + app.Run(new MainForm()); + } + catch (Exception e) + { + Console.WriteLine($"Unhandled Exception!\n*****Stack Trace*****\n\n{e}"); + } + + } + + private static void ApplicationOnUnhandledException(object sender, Eto.UnhandledExceptionEventArgs e) + { + Application.Instance.Invoke(() => + { + MessageBox.Show($"Unhandled Exception!\n*****Stack Trace*****\n\n{e.ExceptionObject}", "Mac", MessageBoxType.Error); + }); } } \ No newline at end of file diff --git a/GlennGUI/GlennGUI.Wpf/Program.cs b/GlennGUI/GlennGUI.Wpf/Program.cs index e799773..f0b0516 100644 --- a/GlennGUI/GlennGUI.Wpf/Program.cs +++ b/GlennGUI/GlennGUI.Wpf/Program.cs @@ -8,6 +8,24 @@ static class Program [STAThread] public static void Main(string[] args) { - new Application(Eto.Platforms.Wpf).Run(new MainForm()); + var app = new Application(Eto.Platforms.Wpf); + try + { + app.UnhandledException += ApplicationOnUnhandledException; + app.Run(new MainForm()); + } + catch (Exception e) + { + Console.WriteLine($"Unhandled Exception!\n*****Stack Trace*****\n\n{e}"); + } + + } + + private static void ApplicationOnUnhandledException(object sender, Eto.UnhandledExceptionEventArgs e) + { + Application.Instance.Invoke(() => + { + MessageBox.Show($"Unhandled Exception!\n*****Stack Trace*****\n\n{e.ExceptionObject}", "WPF", MessageBoxType.Error); + }); } } \ No newline at end of file diff --git a/GlennLib/Core.cs b/GlennLib/Core.cs index cbca25e..c237ce6 100644 --- a/GlennLib/Core.cs +++ b/GlennLib/Core.cs @@ -4,13 +4,13 @@ public static class Core { private static string ReturnAndCreateConfigDir() { - string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create) + "/PortHelper/"; + string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create) + "/GlennPortHelper/"; Directory.CreateDirectory(path); return path; } /// - /// The full path to the PortHelper's place in Configuration Application Data. + /// The full path to the tools's place in Configuration Application Data. /// public static readonly string ConfigDir = ReturnAndCreateConfigDir(); diff --git a/GlennLib/ModsBase.cs b/GlennLib/ModsBase.cs index db8d04d..bd44116 100644 --- a/GlennLib/ModsBase.cs +++ b/GlennLib/ModsBase.cs @@ -14,8 +14,15 @@ public abstract class ModsBase /// /// A temporary directory /// - protected static readonly string TempDir = Path.GetTempPath() + "/PortHelper/"; - + protected static string TempDir => CreateAndReturnTempPath(); + + private static string CreateAndReturnTempPath() + { + string path = Path.GetTempPath() + "/GlennPortHelper/"; + Directory.CreateDirectory(path); + return path; + } + /// /// The current directory of the program. /// diff --git a/GlennLibTests/RawModsTests.cs b/GlennLibTests/RawModsTests.cs index 1cf315e..c40caf0 100644 --- a/GlennLibTests/RawModsTests.cs +++ b/GlennLibTests/RawModsTests.cs @@ -9,7 +9,7 @@ namespace GlennLibTests; public class RawModsTests : IDisposable { private readonly string testTempDir; - private readonly string libTempDir = Path.GetTempPath() + "/PortHelper/"; + private readonly string libTempDir = Path.GetTempPath() + "/GlennPortHelper/"; private readonly ITestOutputHelper output; public RawModsTests(ITestOutputHelper output)