diff --git a/src/App.xaml.cs b/src/App.xaml.cs
index f4b5e643..cb15c548 100644
--- a/src/App.xaml.cs
+++ b/src/App.xaml.cs
@@ -85,6 +85,18 @@ namespace SourceGit {
}
if (repo != null) Models.Watcher.Open(repo);
+ } else {
+ var restore = Models.Preference.Instance.Restore;
+ var actived = null as Models.Repository;
+ if (restore.IsEnabled && restore.Opened.Count > 0) {
+ foreach (var path in restore.Opened) {
+ var repo = Models.Preference.Instance.FindRepository(path);
+ if (repo != null) Models.Watcher.Open(repo);
+ if (path == restore.Actived) actived = repo;
+ }
+
+ if (actived != null) Models.Watcher.Open(actived);
+ }
}
// 检测更新
diff --git a/src/Models/Preference.cs b/src/Models/Preference.cs
index 635ffb9e..9cf3fa8e 100644
--- a/src/Models/Preference.cs
+++ b/src/Models/Preference.cs
@@ -135,6 +135,27 @@ namespace SourceGit.Models {
public Change.DisplayMode ChangeInCommitInfo { get; set; } = Change.DisplayMode.Tree;
}
+ ///
+ /// 恢复上次打开的窗口
+ ///
+ public class RestoreTabs {
+
+ ///
+ /// 是否开启该功能
+ ///
+ public bool IsEnabled { get; set; } = false;
+
+ ///
+ /// 上次打开的仓库
+ ///
+ public List Opened { get; set; } = new List();
+
+ ///
+ /// 最后浏览的仓库
+ ///
+ public string Actived { get; set; } = null;
+ }
+
///
/// 全局配置
///
@@ -163,6 +184,7 @@ namespace SourceGit.Models {
public WindowInfo Window { get; set; } = new WindowInfo();
public List Groups { get; set; } = new List();
public List Repositories { get; set; } = new List();
+ public RestoreTabs Restore { get; set; } = new RestoreTabs();
#endregion
#region LOAD_SAVE
diff --git a/src/Resources/Locales/en_US.xaml b/src/Resources/Locales/en_US.xaml
index 02d1a10a..3865bc9d 100644
--- a/src/Resources/Locales/en_US.xaml
+++ b/src/Resources/Locales/en_US.xaml
@@ -364,6 +364,7 @@
Use dark theme
Check for update
Fetch remotes automatically
+ Restore windows
GIT SETTING
Install Path :
Input path for git.exe
diff --git a/src/Resources/Locales/zh_CN.xaml b/src/Resources/Locales/zh_CN.xaml
index 7e4d742c..c47f1f3a 100644
--- a/src/Resources/Locales/zh_CN.xaml
+++ b/src/Resources/Locales/zh_CN.xaml
@@ -363,6 +363,7 @@
启用暗色主题
启用检测更新
启用定时自动拉取远程更新
+ 启动时恢复上次打开的仓库
GIT配置
安装路径 :
填写git.exe所在位置
diff --git a/src/Views/Launcher.xaml b/src/Views/Launcher.xaml
index 79b18826..8f25151a 100644
--- a/src/Views/Launcher.xaml
+++ b/src/Views/Launcher.xaml
@@ -13,7 +13,8 @@
MinWidth="1280" MinHeight="720"
Title="{StaticResource Text.About.Title}"
Width="{Binding Source={x:Static models:Preference.Instance}, Path=Window.Width, Mode=TwoWay}"
- Height="{Binding Source={x:Static models:Preference.Instance}, Path=Window.Height, Mode=TwoWay}">
+ Height="{Binding Source={x:Static models:Preference.Instance}, Path=Window.Height, Mode=TwoWay}"
+ Closing="OnClosing">
diff --git a/src/Views/Launcher.xaml.cs b/src/Views/Launcher.xaml.cs
index a69eb910..d3d5a4f0 100644
--- a/src/Views/Launcher.xaml.cs
+++ b/src/Views/Launcher.xaml.cs
@@ -1,4 +1,5 @@
using System;
+using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
@@ -16,6 +17,31 @@ namespace SourceGit.Views {
tabs.Add();
}
+ private void OnClosing(object sender, CancelEventArgs e) {
+ var restore = Models.Preference.Instance.Restore;
+ if (!restore.IsEnabled) return;
+
+ restore.Opened.Clear();
+
+ foreach (var tab in tabs.Tabs) {
+ if (tab.IsWelcomePage) continue;
+
+ // 仅支持恢复加入管理的仓库页,Submodules等未加入管理的不支持
+ var repo = Models.Preference.Instance.FindRepository(tab.Id);
+ if (repo != null) restore.Opened.Add(tab.Id);
+ }
+
+ if (restore.Opened.Count > 0) {
+ if (restore.Opened.IndexOf(tabs.Current) >= 0) {
+ restore.Actived = tabs.Current;
+ } else {
+ restore.Actived = restore.Opened[0];
+ }
+ }
+
+ Models.Preference.Save();
+ }
+
#region OPEN_REPO
private void OpenRepository(Models.Repository repo) {
if (tabs.Goto(repo.Path)) return;
diff --git a/src/Views/Preference.xaml b/src/Views/Preference.xaml
index d4229300..8abc25d6 100644
--- a/src/Views/Preference.xaml
+++ b/src/Views/Preference.xaml
@@ -58,6 +58,7 @@
+
@@ -135,21 +136,27 @@
Grid.Row="5" Grid.Column="1"
Content="{StaticResource Text.Preference.AutoFetch}"
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.AutoFetchRemotes, Mode=TwoWay}"/>
-
+
+
+
+
-
+
@@ -172,11 +179,11 @@
-
+
@@ -199,36 +206,36 @@
-
+
@@ -294,12 +301,12 @@