mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-25 22:25:00 +00:00
feature<Preference>: auto restart application when general setting changed
This commit is contained in:
parent
e3a5b0b62a
commit
58e690e1dc
2 changed files with 35 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
|
@ -13,6 +14,7 @@ namespace SourceGit {
|
|||
/// 程序入口.
|
||||
/// </summary>
|
||||
public partial class App : Application {
|
||||
private static bool restart = false;
|
||||
|
||||
/// <summary>
|
||||
/// 读取本地化字串
|
||||
|
@ -26,6 +28,15 @@ namespace SourceGit {
|
|||
return string.Format(data, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重启程序
|
||||
/// </summary>
|
||||
public static void Restart() {
|
||||
restart = true;
|
||||
Process.Start(Process.GetCurrentProcess().MainModule.FileName);
|
||||
Current.Shutdown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动.
|
||||
/// </summary>
|
||||
|
@ -109,7 +120,7 @@ namespace SourceGit {
|
|||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnAppDeactivated(object sender, EventArgs e) {
|
||||
Models.Preference.Save();
|
||||
if (!restart) Models.Preference.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue