diff --git a/WeModPatcher/App.xaml.cs b/WeModPatcher/App.xaml.cs
index e8aa294..9e6a6af 100644
--- a/WeModPatcher/App.xaml.cs
+++ b/WeModPatcher/App.xaml.cs
@@ -1,9 +1,32 @@
-namespace WeModPatcher
+using System;
+using System.Threading.Tasks;
+using System.Windows;
+using MessageBox = System.Windows.Forms.MessageBox;
+
+namespace WeModPatcher
{
///
/// Interaction logic for App.xaml
///
public partial class App
{
+ protected override void OnStartup(StartupEventArgs e)
+ {
+ AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
+ TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;
+ base.OnStartup(e);
+ }
+
+ private void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
+ {
+ MessageBox.Show(e.ToString());
+ Shutdown();
+ }
+
+ private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
+ {
+ MessageBox.Show(e.ToString());
+ Shutdown();
+ }
}
}
\ No newline at end of file
diff --git a/WeModPatcher/View/MainWindow/MainWindow.xaml b/WeModPatcher/View/MainWindow/MainWindow.xaml
index 303982c..252800c 100644
--- a/WeModPatcher/View/MainWindow/MainWindow.xaml
+++ b/WeModPatcher/View/MainWindow/MainWindow.xaml
@@ -75,15 +75,17 @@
-
-
+
+
-
-
+
+
+
+
+
diff --git a/WeModPatcher/View/MainWindow/MainWindow.xaml.cs b/WeModPatcher/View/MainWindow/MainWindow.xaml.cs
index 88dab31..84aa92b 100644
--- a/WeModPatcher/View/MainWindow/MainWindow.xaml.cs
+++ b/WeModPatcher/View/MainWindow/MainWindow.xaml.cs
@@ -15,7 +15,7 @@ namespace WeModPatcher.View.MainWindow
public MainWindow()
{
InitializeComponent();
- this.DataContext = new MainWindowVm();
+ this.DataContext = new MainWindowVm(this);
Instance = this;
}
diff --git a/WeModPatcher/View/MainWindow/MainWindowVm.cs b/WeModPatcher/View/MainWindow/MainWindowVm.cs
index d065f19..b662926 100644
--- a/WeModPatcher/View/MainWindow/MainWindowVm.cs
+++ b/WeModPatcher/View/MainWindow/MainWindowVm.cs
@@ -17,6 +17,7 @@ namespace WeModPatcher.View.MainWindow
public class MainWindowVm : ObservableObject
{
+ private readonly MainWindow _view;
public ObservableCollection LogList { get; } = new ObservableCollection();
private string _weModPath;
@@ -153,6 +154,7 @@ namespace WeModPatcher.View.MainWindow
}
File.Copy(backupPath, Path.Combine(WeModPath, "resources", "app.asar"), true);
+ File.Delete(backupPath);
Log("Backup restored successfully.", ELogType.Success);
AlreadyPatched = false;
IsPatchEnabled = true;
@@ -181,16 +183,19 @@ namespace WeModPatcher.View.MainWindow
{
message = $"[{logType.ToString().ToUpper()}] {message}";
- LogList.Add(new LogEntry
+ var entry = new LogEntry
{
LogType = logType,
Message = message
- });
+ };
+ LogList.Add(entry);
+ _view.LogList.ScrollIntoView(entry);
});
}
- public MainWindowVm()
+ public MainWindowVm(MainWindow view)
{
+ _view = view;
SetFolderPathCommand = new RelayCommand(OnFolderPathSelection);
ApplyPatchCommand = new RelayCommand(OnPatching);
RestoreBackupCommand = new RelayCommand(OnBackupRestoring);