diff --git a/App.xaml.cs b/App.xaml.cs
index d578d22..78aec92 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -16,14 +16,7 @@ namespace ProcessCpuUsageStatusWindow
[STAThread]
public static void Main(string[] args)
{
- if (Settings.Default.FirstRun)
- {
- Settings.Default.Upgrade();
- Settings.Default.FirstRun = false;
- Settings.Default.Save();
- }
-
- SquirrelAwareApp.HandleEvents();
+ SquirrelAwareApp.HandleEvents(onAppUpdate: version => SettingsExtensions.RestoreSettings());
var application = new App();
application.InitializeComponent();
diff --git a/ProcessCpuUsageStatusWindow.csproj b/ProcessCpuUsageStatusWindow.csproj
index 66e8798..07347ea 100644
--- a/ProcessCpuUsageStatusWindow.csproj
+++ b/ProcessCpuUsageStatusWindow.csproj
@@ -88,6 +88,7 @@
packages\squirrel.windows.1.7.9\lib\Net45\Squirrel.dll
+
packages\FloatingStatusWindow.1.0.0.9\lib\net45\System.Windows.Interactivity.dll
@@ -129,6 +130,7 @@
App.xaml
Code
+
diff --git a/SettingsExtensions.cs b/SettingsExtensions.cs
new file mode 100644
index 0000000..59b2d45
--- /dev/null
+++ b/SettingsExtensions.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Configuration;
+using System.Diagnostics;
+using System.IO;
+using System.Reflection;
+
+namespace ProcessCpuUsageStatusWindow
+{
+ public static class SettingsExtensions
+ {
+ public static void BackupSettings()
+ {
+ Debugger.Launch();
+
+ var settingsFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath;
+ var destination = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\..\last.config";
+ File.Copy(settingsFile, destination, true);
+ }
+
+ public static void RestoreSettings()
+ {
+ Debugger.Launch();
+
+ var destFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath;
+ var sourceFile = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\..\last.config";
+
+ if (!File.Exists(sourceFile))
+ return;
+
+ var destDirectory = Path.GetDirectoryName(destFile);
+
+ if (destDirectory == null)
+ return;
+
+ try
+ {
+ Directory.CreateDirectory(destDirectory);
+ }
+ catch (Exception exception)
+ {
+ Console.WriteLine(exception);
+ }
+
+ try
+ {
+ File.Copy(sourceFile, destFile, true);
+ }
+ catch (Exception exception)
+ {
+ Console.WriteLine(exception);
+ }
+
+ try
+ {
+ File.Delete(sourceFile);
+ }
+ catch (Exception exception)
+ {
+ Console.WriteLine(exception);
+ }
+ }
+ }
+}
diff --git a/WindowSource.cs b/WindowSource.cs
index 3bc545d..719fc46 100644
--- a/WindowSource.cs
+++ b/WindowSource.cs
@@ -43,14 +43,14 @@ namespace ProcessCpuUsageStatusWindow
return;
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(Resources.Updating));
- Thread.Sleep(1000);
+ Thread.Sleep(500);
+
+ SettingsExtensions.BackupSettings();
#if !DEBUG
await updateManager.DownloadReleases(new[] { lastVersion });
await updateManager.ApplyReleases(updates);
await updateManager.UpdateApp();
-
- Thread.Sleep(1000);
#endif
}