diff --git a/Artemis/Artemis/App.xaml b/Artemis/Artemis/App.xaml index 8b9f0d35e..39bea1e79 100644 --- a/Artemis/Artemis/App.xaml +++ b/Artemis/Artemis/App.xaml @@ -1,7 +1,9 @@  + xmlns:local="clr-namespace:Artemis" + DispatcherUnhandledException="Application_DispatcherUnhandledException" + Startup="Application_Startup"> diff --git a/Artemis/Artemis/App.xaml.cs b/Artemis/Artemis/App.xaml.cs index 5f252eeb7..29b2f9489 100644 --- a/Artemis/Artemis/App.xaml.cs +++ b/Artemis/Artemis/App.xaml.cs @@ -1,4 +1,7 @@ -using System.Windows; +using System; +using System.Windows; +using System.Windows.Threading; +using WpfExceptionViewer; namespace Artemis { @@ -11,5 +14,43 @@ namespace Artemis { InitializeComponent(); } + + public bool DoHandle { get; set; } + + private void Application_Startup(object sender, StartupEventArgs e) + { + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + } + + private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) + { + if (DoHandle) + { + GetArtemisExceptionViewer(e.Exception).ShowDialog(); + e.Handled = true; + } + else + { + GetArtemisExceptionViewer(e.Exception).ShowDialog(); + e.Handled = false; + } + } + + + private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + var ex = e.ExceptionObject as Exception; + GetArtemisExceptionViewer(ex).ShowDialog(); + } + + private static ExceptionViewer GetArtemisExceptionViewer(Exception e) + { + return new ExceptionViewer("An unexpected error occurred in Artemis.", e) + { + Title = "Artemis - Exception :c", + Height = 400, + Width = 800 + }; + } } } \ No newline at end of file diff --git a/Artemis/Artemis/AppBootStrapper.cs b/Artemis/Artemis/AppBootStrapper.cs index a34e4aac7..99494355c 100644 --- a/Artemis/Artemis/AppBootStrapper.cs +++ b/Artemis/Artemis/AppBootStrapper.cs @@ -15,15 +15,7 @@ namespace Artemis protected override void OnStartup(object sender, StartupEventArgs e) { - try - { - DisplayRootViewFor(); - } - catch (Exception ex) - { - MessageBox.Show("Startup failed :c \n" + ex.InnerException.Message); - throw; - } + DisplayRootViewFor(); } } } \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs index 1a35993f6..6f20c63ba 100644 --- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs +++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs @@ -93,7 +93,7 @@ namespace Artemis.Modules.Games.CounterStrike var smoked = CsJson["player"]["state"]["smoked"].Value(); if (smoked == 0 && !DrawingSmoke) return; - + EventRect.Colors = new List {Color.FromArgb(smoked, 255, 255, 255)}; DrawingSmoke = (smoked != 0); }