diff --git a/SourceGit/App.xaml.cs b/SourceGit/App.xaml.cs
index 2ba3756d..9f5e8de3 100644
--- a/SourceGit/App.xaml.cs
+++ b/SourceGit/App.xaml.cs
@@ -36,6 +36,14 @@ namespace SourceGit {
set;
}
+ ///
+ /// Get main window.
+ ///
+ public static UI.Launcher Launcher {
+ get;
+ private set;
+ }
+
///
/// Raise error message.
///
@@ -92,8 +100,8 @@ namespace SourceGit {
}
// Show main window
- var launcher = new UI.Launcher();
- launcher.Show();
+ Launcher = new UI.Launcher();
+ Launcher.Show();
}
///
diff --git a/SourceGit/Git/Repository.cs b/SourceGit/Git/Repository.cs
index 087ed5f4..9efc74e3 100644
--- a/SourceGit/Git/Repository.cs
+++ b/SourceGit/Git/Repository.cs
@@ -16,7 +16,6 @@ namespace SourceGit.Git {
#region HOOKS
public static Action OnOpen = null;
- public static Action OnClose = null;
[XmlIgnore] public Action OnNavigateCommit = null;
[XmlIgnore] public Action OnWorkingCopyChanged = null;
[XmlIgnore] public Action OnTagChanged = null;
@@ -355,7 +354,7 @@ namespace SourceGit.Git {
releasePrefix = null;
hotfixPrefix = null;
- OnClose?.Invoke();
+ GC.Collect();
}
#endregion
diff --git a/SourceGit/UI/AddSubmodule.xaml.cs b/SourceGit/UI/AddSubmodule.xaml.cs
index 6bd46603..cbb210ab 100644
--- a/SourceGit/UI/AddSubmodule.xaml.cs
+++ b/SourceGit/UI/AddSubmodule.xaml.cs
@@ -34,7 +34,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository repo) {
- PopupManager.Show(new AddSubmodule(repo));
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(new AddSubmodule(repo));
}
#region EVENTS
@@ -57,14 +58,17 @@ namespace SourceGit.UI {
if (Validation.GetHasError(txtPath)) return;
var recursive = chkRecursive.IsChecked == true;
+ var popup = App.Launcher.GetPopupManager(repo);
- PopupManager.Lock();
- await Task.Run(() => repo.AddSubmodule(RepoURL, LocalPath, recursive, PopupManager.UpdateStatus));
- PopupManager.Close(true);
+ popup?.Lock();
+ await Task.Run(() => repo.AddSubmodule(RepoURL, LocalPath, recursive, msg => {
+ popup?.UpdateStatus(msg);
+ }));
+ popup?.Close(true);
}
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
#endregion
}
diff --git a/SourceGit/UI/Apply.xaml.cs b/SourceGit/UI/Apply.xaml.cs
index e1452801..e180a07c 100644
--- a/SourceGit/UI/Apply.xaml.cs
+++ b/SourceGit/UI/Apply.xaml.cs
@@ -52,7 +52,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository opened) {
- PopupManager.Show(new Apply(opened));
+ var popup = App.Launcher.GetPopupManager(opened);
+ popup?.Show(new Apply(opened));
}
///
@@ -82,13 +83,14 @@ namespace SourceGit.UI {
txtPatchFile.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtPatchFile)) return;
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
var mode = combWhitespaceOptions.SelectedItem as WhitespaceOption;
var ignoreSpaceChanges = chkIgnoreWhitespace.IsChecked == true;
await Task.Run(() => repo.Apply(PatchFile, ignoreSpaceChanges, mode.Arg));
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -97,7 +99,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/Blame.xaml.cs b/SourceGit/UI/Blame.xaml.cs
index abf44055..3bf3fbeb 100644
--- a/SourceGit/UI/Blame.xaml.cs
+++ b/SourceGit/UI/Blame.xaml.cs
@@ -36,7 +36,7 @@ namespace SourceGit.UI {
double minWidth = content.ActualWidth;
// Move to center.
- var parent = App.Current.MainWindow;
+ var parent = App.Launcher;
Left = parent.Left + (parent.Width - Width) * 0.5;
Top = parent.Top + (parent.Height - Height) * 0.5;
diff --git a/SourceGit/UI/CherryPick.xaml.cs b/SourceGit/UI/CherryPick.xaml.cs
index 0c77b147..f8665a1d 100644
--- a/SourceGit/UI/CherryPick.xaml.cs
+++ b/SourceGit/UI/CherryPick.xaml.cs
@@ -1,4 +1,4 @@
-锘縰sing System.Windows;
+using System.Windows;
using System.Windows.Controls;
namespace SourceGit.UI {
@@ -29,7 +29,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository repo, Git.Commit commit) {
- PopupManager.Show(new CherryPick(repo, commit));
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(new CherryPick(repo, commit));
}
///
@@ -39,7 +40,9 @@ namespace SourceGit.UI {
///
private void Start(object sender, RoutedEventArgs e) {
repo.CherryPick(commitSHA, chkCommitChanges.IsChecked != true);
- PopupManager.Close();
+
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Close();
}
///
@@ -48,7 +51,8 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Close();
}
}
}
diff --git a/SourceGit/UI/Clone.xaml.cs b/SourceGit/UI/Clone.xaml.cs
index 658a5c1b..e05b1edf 100644
--- a/SourceGit/UI/Clone.xaml.cs
+++ b/SourceGit/UI/Clone.xaml.cs
@@ -42,7 +42,8 @@ namespace SourceGit.UI {
/// Show clone dialog.
///
public static void Show() {
- PopupManager.Show(new Clone());
+ var popup = App.Launcher.GetPopupManager(null);
+ popup?.Show(new Clone());
}
///
@@ -91,16 +92,17 @@ namespace SourceGit.UI {
rName = RemoteName;
}
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(null);
+ popup.Lock();
var repo = await Task.Run(() => {
- return Git.Repository.Clone(RemoteUri, ParentFolder, rName, repoName, PopupManager.UpdateStatus);
+ return Git.Repository.Clone(RemoteUri, ParentFolder, rName, repoName, popup.UpdateStatus);
});
if (repo == null) {
- PopupManager.Unlock();
+ popup.Unlock();
} else {
- PopupManager.Close(true);
+ popup.Close(true);
repo.Open();
}
}
@@ -111,7 +113,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(null).Close();
}
}
}
diff --git a/SourceGit/UI/Configure.xaml.cs b/SourceGit/UI/Configure.xaml.cs
index 2a459be6..f416297d 100644
--- a/SourceGit/UI/Configure.xaml.cs
+++ b/SourceGit/UI/Configure.xaml.cs
@@ -43,7 +43,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository repo) {
- PopupManager.Show(new Configure(repo));
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(new Configure(repo));
}
#region EVENTS
@@ -63,7 +64,7 @@ namespace SourceGit.UI {
}
private void Close(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
#endregion
}
diff --git a/SourceGit/UI/CreateBranch.xaml.cs b/SourceGit/UI/CreateBranch.xaml.cs
index 4edd8d41..12fdc908 100644
--- a/SourceGit/UI/CreateBranch.xaml.cs
+++ b/SourceGit/UI/CreateBranch.xaml.cs
@@ -58,7 +58,9 @@ namespace SourceGit.UI {
dialog.basedOnDesc.Content = branch.Name;
if (!branch.IsLocal) dialog.txtName.Text = branch.Name.Substring(branch.Remote.Length + 1);
- PopupManager.Show(dialog);
+
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(dialog);
}
///
@@ -71,7 +73,9 @@ namespace SourceGit.UI {
dialog.based = tag.Name;
dialog.basedOnType.Data = dialog.FindResource("Icon.Tag") as Geometry;
dialog.basedOnDesc.Content = tag.Name;
- PopupManager.Show(dialog);
+
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(dialog);
}
///
@@ -84,7 +88,9 @@ namespace SourceGit.UI {
dialog.based = commit.SHA;
dialog.basedOnType.Data = dialog.FindResource("Icon.Commit") as Geometry;
dialog.basedOnDesc.Content = $"{commit.ShortSHA} {commit.Subject}";
- PopupManager.Show(dialog);
+
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(dialog);
}
///
@@ -96,7 +102,8 @@ namespace SourceGit.UI {
txtName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtName)) return;
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
bool checkout = chkCheckout.IsChecked == true;
await Task.Run(() => {
@@ -119,7 +126,7 @@ namespace SourceGit.UI {
}
});
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -128,7 +135,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/CreateTag.xaml.cs b/SourceGit/UI/CreateTag.xaml.cs
index 2c87039f..17e1d940 100644
--- a/SourceGit/UI/CreateTag.xaml.cs
+++ b/SourceGit/UI/CreateTag.xaml.cs
@@ -1,4 +1,4 @@
-锘縰sing System.Linq;
+using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
@@ -51,7 +51,9 @@ namespace SourceGit.UI {
dialog.based = branch.Head;
dialog.basedOnType.Data = dialog.FindResource("Icon.Branch") as Geometry;
dialog.basedOnDesc.Content = branch.Name;
- PopupManager.Show(dialog);
+
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(dialog);
}
///
@@ -64,7 +66,9 @@ namespace SourceGit.UI {
dialog.based = commit.SHA;
dialog.basedOnType.Data = dialog.FindResource("Icon.Commit") as Geometry;
dialog.basedOnDesc.Content = $"{commit.ShortSHA} {commit.Subject}";
- PopupManager.Show(dialog);
+
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(dialog);
}
///
@@ -77,7 +81,9 @@ namespace SourceGit.UI {
if (Validation.GetHasError(tagName)) return;
Git.Tag.Add(repo, TagName, based, tagMessage.Text);
- PopupManager.Close();
+
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Close();
}
///
@@ -86,7 +92,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/Dashboard.xaml b/SourceGit/UI/Dashboard.xaml
index 478e14fb..d48a68bb 100644
--- a/SourceGit/UI/Dashboard.xaml
+++ b/SourceGit/UI/Dashboard.xaml
@@ -7,8 +7,7 @@
xmlns:local="clr-namespace:SourceGit.UI"
xmlns:converters="clr-namespace:SourceGit.Converters"
mc:Ignorable="d"
- d:DesignHeight="450" d:DesignWidth="800"
- Unloaded="Cleanup">
+ d:DesignHeight="450" d:DesignWidth="800">
@@ -34,41 +33,19 @@
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
diff --git a/SourceGit/UI/Dashboard.xaml.cs b/SourceGit/UI/Dashboard.xaml.cs
index 4dc7d982..88ebb355 100644
--- a/SourceGit/UI/Dashboard.xaml.cs
+++ b/SourceGit/UI/Dashboard.xaml.cs
@@ -67,17 +67,9 @@ namespace SourceGit.UI {
InitializeComponent();
repo = opened;
- repoName.Content = repo.Name;
histories.Repo = opened;
commits.Repo = opened;
- if (repo.Parent != null) {
- btnParent.Visibility = Visibility.Visible;
- txtParent.Content = repo.Parent.Name;
- } else {
- btnParent.Visibility = Visibility.Collapsed;
- }
-
UpdateBranches();
UpdateHistories();
UpdateLocalChanges();
@@ -86,6 +78,17 @@ namespace SourceGit.UI {
UpdateSubmodules();
}
+ ///
+ /// Cleanup all items
+ ///
+ public void Cleanup() {
+ localBranchTree.ItemsSource = null;
+ remoteBranchTree.ItemsSource = null;
+ tagList.ItemsSource = null;
+ cachedLocalBranches.Clear();
+ cachedRemotes.Clear();
+ }
+
#region DATA_UPDATE
private void UpdateHistories() {
Dispatcher.Invoke(() => {
@@ -244,8 +247,8 @@ namespace SourceGit.UI {
MakeBranchNode(b, remote.Children, folders, states, "remotes");
} else {
- /// 对于 SUBMODULE HEAD 出于游离状态(detached on commit id)
- /// 此时,分支既不是 本地分支,也不是远程分支
+ /// 瀵逛簬 SUBMODULE HEAD 鍑轰簬娓哥鐘舵侊紙detached on commit id锛
+ /// 姝ゆ椂锛屽垎鏀棦涓嶆槸 鏈湴鍒嗘敮锛屼篃涓嶆槸杩滅▼鍒嗘敮
IsDetached = b.IsCurrent;
}
}
@@ -297,33 +300,9 @@ namespace SourceGit.UI {
});
});
}
-
- private void Cleanup(object sender, RoutedEventArgs e) {
- localBranchTree.ItemsSource = null;
- remoteBranchTree.ItemsSource = null;
- tagList.ItemsSource = null;
- cachedLocalBranches.Clear();
- cachedRemotes.Clear();
- }
#endregion
#region TOOLBAR
- private void Close(object sender, RoutedEventArgs e) {
- if (PopupManager.IsLocked()) return;
- PopupManager.Close();
-
- cachedLocalBranches.Clear();
- cachedRemotes.Clear();
-
- repo.Close();
- }
-
- private void GotoParent(object sender, RoutedEventArgs e) {
- if (repo.Parent == null) return;
- repo.Parent.Open();
- e.Handled = true;
- }
-
private void OpenFetch(object sender, RoutedEventArgs e) {
Fetch.Show(repo);
}
@@ -345,7 +324,7 @@ namespace SourceGit.UI {
}
private void OpenSearch(object sender, RoutedEventArgs e) {
- if (PopupManager.IsLocked()) return;
+ if (popupManager.IsLocked()) return;
workspace.SelectedItem = historiesSwitch;
if (histories.searchBar.Margin.Top == 0) {
@@ -936,7 +915,7 @@ namespace SourceGit.UI {
}
private void UpdateSubmodule(object sender, RoutedEventArgs e) {
- Waiting.Show(() => repo.UpdateSubmodule());
+ Waiting.Show(repo, () => repo.UpdateSubmodule());
}
private void SubmoduleLostFocus(object sender, RoutedEventArgs e) {
diff --git a/SourceGit/UI/DeleteBranch.xaml.cs b/SourceGit/UI/DeleteBranch.xaml.cs
index 65fa02e5..00d2fd31 100644
--- a/SourceGit/UI/DeleteBranch.xaml.cs
+++ b/SourceGit/UI/DeleteBranch.xaml.cs
@@ -28,7 +28,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository opened, Git.Branch branch) {
- PopupManager.Show(new DeleteBranch(opened, branch));
+ var popup = App.Launcher.GetPopupManager(opened);
+ popup?.Show(new DeleteBranch(opened, branch));
}
///
@@ -37,9 +38,10 @@ namespace SourceGit.UI {
///
///
private async void Sure(object sender, RoutedEventArgs e) {
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
await Task.Run(() => branch.Delete(repo));
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -48,7 +50,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/DeleteRemote.xaml.cs b/SourceGit/UI/DeleteRemote.xaml.cs
index 04e091f8..b86bed8d 100644
--- a/SourceGit/UI/DeleteRemote.xaml.cs
+++ b/SourceGit/UI/DeleteRemote.xaml.cs
@@ -29,7 +29,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository opened, string remote) {
- PopupManager.Show(new DeleteRemote(opened, remote));
+ var popup = App.Launcher.GetPopupManager(opened);
+ popup?.Show(new DeleteRemote(opened, remote));
}
///
@@ -38,9 +39,10 @@ namespace SourceGit.UI {
///
///
private async void Sure(object sender, RoutedEventArgs e) {
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
await Task.Run(() => Git.Remote.Delete(repo, remote));
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -49,7 +51,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/DeleteTag.xaml.cs b/SourceGit/UI/DeleteTag.xaml.cs
index aeb22c54..c8b3c9dc 100644
--- a/SourceGit/UI/DeleteTag.xaml.cs
+++ b/SourceGit/UI/DeleteTag.xaml.cs
@@ -30,7 +30,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository repo, Git.Tag tag) {
- PopupManager.Show(new DeleteTag(repo, tag));
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(new DeleteTag(repo, tag));
}
///
@@ -39,12 +40,13 @@ namespace SourceGit.UI {
///
///
private async void Start(object sender, RoutedEventArgs e) {
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
var push = chkWithRemote.IsChecked == true;
await Task.Run(() => Git.Tag.Delete(repo, tag.Name, push));
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -53,7 +55,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/Discard.xaml.cs b/SourceGit/UI/Discard.xaml.cs
index 7d9372d6..0f8b8ca5 100644
--- a/SourceGit/UI/Discard.xaml.cs
+++ b/SourceGit/UI/Discard.xaml.cs
@@ -40,17 +40,19 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository opened, List targets) {
- PopupManager.Show(new Discard(opened, targets));
+ var popup = App.Launcher.GetPopupManager(opened);
+ popup?.Show(new Discard(opened, targets));
}
private async void Sure(object sender, RoutedEventArgs e) {
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
await Task.Run(() => repo.Discard(changes));
- PopupManager.Close(true);
+ popup?.Close(true);
}
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/Fetch.xaml.cs b/SourceGit/UI/Fetch.xaml.cs
index 843ab0cb..f5f05165 100644
--- a/SourceGit/UI/Fetch.xaml.cs
+++ b/SourceGit/UI/Fetch.xaml.cs
@@ -40,7 +40,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository repo, string preferRemote = null) {
- PopupManager.Show(new Fetch(repo, preferRemote));
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(new Fetch(repo, preferRemote));
}
///
@@ -51,16 +52,17 @@ namespace SourceGit.UI {
private async void Start(object sender, RoutedEventArgs e) {
bool prune = chkPrune.IsChecked == true;
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
if (chkFetchAll.IsChecked == true) {
- await Task.Run(() => repo.Fetch(null, prune, PopupManager.UpdateStatus));
+ await Task.Run(() => repo.Fetch(null, prune, msg => popup?.UpdateStatus(msg)));
} else {
var remote = combRemotes.SelectedItem as Git.Remote;
- await Task.Run(() => repo.Fetch(remote, prune, PopupManager.UpdateStatus));
+ await Task.Run(() => repo.Fetch(remote, prune, msg => popup?.UpdateStatus(msg)));
}
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -69,7 +71,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/FileHistories.xaml.cs b/SourceGit/UI/FileHistories.xaml.cs
index 5f72b4a2..91647601 100644
--- a/SourceGit/UI/FileHistories.xaml.cs
+++ b/SourceGit/UI/FileHistories.xaml.cs
@@ -29,7 +29,7 @@ namespace SourceGit.UI {
InitializeComponent();
// Move to center
- var parent = App.Current.MainWindow;
+ var parent = App.Launcher;
Left = parent.Left + (parent.Width - Width) * 0.5;
Top = parent.Top + (parent.Height - Height) * 0.5;
diff --git a/SourceGit/UI/GitFlowFinishBranch.xaml.cs b/SourceGit/UI/GitFlowFinishBranch.xaml.cs
index b5acd375..973622ae 100644
--- a/SourceGit/UI/GitFlowFinishBranch.xaml.cs
+++ b/SourceGit/UI/GitFlowFinishBranch.xaml.cs
@@ -36,7 +36,8 @@ namespace SourceGit.UI {
txtBranchType.Content = "Hotfix :";
break;
default:
- PopupManager.Close();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Close();
return;
}
@@ -49,7 +50,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository repo, Git.Branch branch) {
- PopupManager.Show(new GitFlowFinishBranch(repo, branch));
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(new GitFlowFinishBranch(repo, branch));
}
///
@@ -58,9 +60,10 @@ namespace SourceGit.UI {
///
///
private async void Sure(object sender, RoutedEventArgs e) {
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
await Task.Run(() => repo.FinishGitFlowBranch(branch));
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -69,7 +72,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/GitFlowSetup.xaml.cs b/SourceGit/UI/GitFlowSetup.xaml.cs
index dfbafde7..761ced41 100644
--- a/SourceGit/UI/GitFlowSetup.xaml.cs
+++ b/SourceGit/UI/GitFlowSetup.xaml.cs
@@ -26,7 +26,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository repo) {
- PopupManager.Show(new GitFlowSetup(repo));
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(new GitFlowSetup(repo));
}
///
@@ -35,7 +36,8 @@ namespace SourceGit.UI {
///
///
private async void Sure(object sender, RoutedEventArgs e) {
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
var master = txtMaster.Text;
var dev = txtDevelop.Text;
@@ -45,7 +47,7 @@ namespace SourceGit.UI {
var version = txtVersion.Text;
await Task.Run(() => repo.EnableGitFlow(master, dev, feature, release, hotfix, version));
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -54,7 +56,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
///
diff --git a/SourceGit/UI/GitFlowStartBranch.xaml.cs b/SourceGit/UI/GitFlowStartBranch.xaml.cs
index 242fa716..bedbe37b 100644
--- a/SourceGit/UI/GitFlowStartBranch.xaml.cs
+++ b/SourceGit/UI/GitFlowStartBranch.xaml.cs
@@ -51,7 +51,8 @@ namespace SourceGit.UI {
nameValidator.Prefix = hotfixPrefix;
break;
default:
- PopupManager.Close();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Close();
return;
}
}
@@ -62,7 +63,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository repo, Git.Branch.Type type) {
- PopupManager.Show(new GitFlowStartBranch(repo, type));
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(new GitFlowStartBranch(repo, type));
}
///
@@ -74,9 +76,10 @@ namespace SourceGit.UI {
txtName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtName)) return;
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
await Task.Run(() => repo.StartGitFlowBranch(type, SubName));
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -85,7 +88,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/Histories.xaml.cs b/SourceGit/UI/Histories.xaml.cs
index b8936766..b77ce542 100644
--- a/SourceGit/UI/Histories.xaml.cs
+++ b/SourceGit/UI/Histories.xaml.cs
@@ -526,7 +526,7 @@ namespace SourceGit.UI {
}
var dialog = new InteractiveRebase(Repo, commit);
- dialog.Owner = App.Current.MainWindow;
+ dialog.Owner = App.Launcher;
dialog.ShowDialog();
} else {
Rebase.Show(Repo, commit);
diff --git a/SourceGit/UI/Init.xaml.cs b/SourceGit/UI/Init.xaml.cs
index 03bb9aa9..bc1964fb 100644
--- a/SourceGit/UI/Init.xaml.cs
+++ b/SourceGit/UI/Init.xaml.cs
@@ -25,7 +25,8 @@ namespace SourceGit.UI {
///
///
public static void Show(string path) {
- PopupManager.Show(new Init(path));
+ var popup = App.Launcher.GetPopupManager(null);
+ popup.Show(new Init(path));
}
///
@@ -34,7 +35,8 @@ namespace SourceGit.UI {
///
///
private async void Sure(object sender, RoutedEventArgs e) {
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(null);
+ popup.Lock();
await Task.Run(() => {
var errs = Git.Repository.RunCommand(workingDir, "init -q", null);
@@ -45,7 +47,7 @@ namespace SourceGit.UI {
}
});
- PopupManager.Close(true);
+ popup.Close(true);
var repo = App.Preference.FindRepository(workingDir);
if (repo != null) repo.Open();
@@ -57,7 +59,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(null).Close();
}
}
}
diff --git a/SourceGit/UI/Launcher.xaml b/SourceGit/UI/Launcher.xaml
index 0720cfff..bca879e0 100644
--- a/SourceGit/UI/Launcher.xaml
+++ b/SourceGit/UI/Launcher.xaml
@@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:source="clr-namespace:SourceGit"
+ xmlns:local="clr-namespace:SourceGit.UI"
mc:Ignorable="d"
MinWidth="800" MinHeight="600"
Title="Source Git"
@@ -33,23 +34,23 @@
-
-
+
+
+
-
-
+
-
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -105,11 +201,32 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/SourceGit/UI/Launcher.xaml.cs b/SourceGit/UI/Launcher.xaml.cs
index bf8f0e11..24d78e47 100644
--- a/SourceGit/UI/Launcher.xaml.cs
+++ b/SourceGit/UI/Launcher.xaml.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
@@ -11,6 +10,16 @@ namespace SourceGit.UI {
///
public partial class Launcher : Window {
+ ///
+ /// Tab data.
+ ///
+ public class Tab {
+ public string Title { get; set; }
+ public bool IsActive { get; set; }
+ public Git.Repository Repo { get; set; }
+ public object Page { get; set; }
+ }
+
///
/// Alert data.
///
@@ -24,37 +33,82 @@ namespace SourceGit.UI {
///
public ObservableCollection Alerts { get; set; } = new ObservableCollection();
+ ///
+ /// Opened tabs.
+ ///
+ public ObservableCollection Tabs { get; set; } = new ObservableCollection();
+
///
/// Constructor
///
public Launcher() {
- Git.Repository.OnOpen = ShowDashboard;
- Git.Repository.OnClose = ShowManager;
+ App.OnError = msg => {
+ ShowAlert(new Alert() { Title = "ERROR", Message = msg });
+ };
- App.OnError = msg => ShowAlert(new Alert() { Title = "ERROR", Message = msg });
+ Git.Repository.OnOpen = repo => {
+ Dispatcher.Invoke(() => {
+ foreach (var item in openedTabs.Items) {
+ var opened = item as Tab;
+ if (opened != null && opened.Repo != null && repo.Path == opened.Repo.Path) {
+ openedTabs.SelectedItem = opened;
+ return;
+ }
+ }
+
+ var tab = new Tab() {
+ Title = repo.Parent == null ? repo.Name : $"{repo.Parent.Name} : {repo.Name}",
+ Repo = repo,
+ Page = new Dashboard(repo),
+ };
+
+ Tabs.Add(tab);
+ openedTabs.SelectedItem = tab;
+ });
+ };
+
+ Tabs.Add(new Tab() {
+ Title = "Repositories",
+ Page = new Manager(),
+ });
InitializeComponent();
- ShowManager();
+ openedTabs.SelectedItem = Tabs[0];
+ }
+
+ ///
+ /// Get popup manager from given active page.
+ ///
+ ///
+ ///
+ public PopupManager GetPopupManager(Git.Repository repo) {
+ if (repo == null) return (Tabs[0].Page as Manager).popupManager;
+
+ foreach (var tab in Tabs) {
+ if (tab.Repo != null && tab.Repo.Path == repo.Path) {
+ return (tab.Page as Dashboard).popupManager;
+ }
+ }
+
+ return null;
}
#region LAYOUT_CONTENT
///
- /// Show manager.
+ /// Close repository tab.
///
- private void ShowManager() {
- Dispatcher.Invoke(() => {
- body.Content = new Manager();
- });
- }
+ ///
+ ///
+ private void CloseRepo(object sender, RoutedEventArgs e) {
+ var tab = (sender as Button).DataContext as Tab;
+ if (tab == null || tab.Repo == null) return;
- ///
- /// Show dashboard.
- ///
- ///
- private void ShowDashboard(Git.Repository repo) {
- Dispatcher.Invoke(() => {
- body.Content = new Dashboard(repo);
- });
+ var popup = (tab.Page as Dashboard).popupManager;
+ if (popup.IsLocked()) popup.Close(true);
+ Tabs.Remove(tab);
+
+ tab.Page = null;
+ tab.Repo.Close();
}
///
@@ -63,7 +117,9 @@ namespace SourceGit.UI {
///
///
private void ShowPreference(object sender, RoutedEventArgs e) {
- Preference.Show();
+ var dialog = new Preference();
+ dialog.Owner = this;
+ dialog.ShowDialog();
}
///
diff --git a/SourceGit/UI/Manager.xaml b/SourceGit/UI/Manager.xaml
index 8949dec7..520bd6bb 100644
--- a/SourceGit/UI/Manager.xaml
+++ b/SourceGit/UI/Manager.xaml
@@ -8,37 +8,17 @@
xmlns:git="clr-namespace:SourceGit.Git"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
@@ -148,7 +128,7 @@
-
+
@@ -161,7 +141,7 @@
-
+
@@ -176,7 +156,7 @@
-
+
@@ -198,16 +178,16 @@
+ FontFamily="Consolas"
+ Padding="8"
+ Opacity="0.8"
+ Background="{StaticResource Brush.BG2}"
+ Foreground="{StaticResource Brush.FG}"
+ x:Name="readme"/>
-
+
@@ -217,8 +197,8 @@
-
-
-
+
+
+
diff --git a/SourceGit/UI/Manager.xaml.cs b/SourceGit/UI/Manager.xaml.cs
index 65fff061..c8bcbf4b 100644
--- a/SourceGit/UI/Manager.xaml.cs
+++ b/SourceGit/UI/Manager.xaml.cs
@@ -33,11 +33,6 @@ namespace SourceGit.UI {
/// Constructor.
///
public Manager() {
- Loaded += async (o, e) => {
- await Task.Delay(500);
- GC.Collect();
- };
-
InitializeComponent();
UpdateRecentOpened();
UpdateTree();
diff --git a/SourceGit/UI/Merge.xaml.cs b/SourceGit/UI/Merge.xaml.cs
index 1eb132b3..422e4a28 100644
--- a/SourceGit/UI/Merge.xaml.cs
+++ b/SourceGit/UI/Merge.xaml.cs
@@ -53,7 +53,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository opened, string source, string dest) {
- PopupManager.Show(new Merge(opened, source, dest));
+ var popup = App.Launcher.GetPopupManager(opened);
+ popup?.Show(new Merge(opened, source, dest));
}
///
@@ -64,13 +65,14 @@ namespace SourceGit.UI {
///
public static void StartDirectly(Git.Repository opened, string source, string dest) {
var merge = new Merge(opened, source, dest);
- PopupManager.Show(merge);
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(opened);
+ popup?.Show(merge);
+ popup?.Lock();
Task.Run(() => {
opened.Merge(source, "");
merge.Dispatcher.Invoke(() => {
- PopupManager.Close(true);
+ popup?.Close(true);
});
});
}
@@ -81,13 +83,14 @@ namespace SourceGit.UI {
///
///
private async void Start(object sender, RoutedEventArgs e) {
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
var branch = sourceBranch.Content as string;
var opt = combOptions.SelectedItem as Option;
await Task.Run(() => repo.Merge(branch, opt.Arg));
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -96,7 +99,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/PopupManager.xaml.cs b/SourceGit/UI/PopupManager.xaml.cs
index 7a856756..948bc8bf 100644
--- a/SourceGit/UI/PopupManager.xaml.cs
+++ b/SourceGit/UI/PopupManager.xaml.cs
@@ -10,14 +10,12 @@ namespace SourceGit.UI {
/// Common popup manager.
///
public partial class PopupManager : UserControl {
- private static PopupManager instance = null;
- private static bool locked = false;
+ private bool locked = false;
///
/// Constructor.
///
public PopupManager() {
- instance = this;
InitializeComponent();
}
@@ -25,8 +23,8 @@ namespace SourceGit.UI {
/// Show content as popup.
///
///
- public static void Show(UIElement elem) {
- if (instance == null || locked) return;
+ public void Show(UIElement elem) {
+ if (locked) return;
var gone = new Thickness(0, -(double)elem.GetValue(HeightProperty) - 16, 0, 0);
@@ -35,53 +33,49 @@ namespace SourceGit.UI {
anim.From = gone;
anim.To = new Thickness(0);
- instance.statusMsg.Content = "";
- instance.popupContent.Child = elem;
- instance.popupContent.Margin = gone;
- instance.Visibility = Visibility.Visible;
- instance.popupContent.BeginAnimation(MarginProperty, anim);
+ statusMsg.Content = "";
+ popupContent.Child = elem;
+ popupContent.Margin = gone;
+ Visibility = Visibility.Visible;
+ popupContent.BeginAnimation(MarginProperty, anim);
}
///
/// Is current locked.
///
///
- public static bool IsLocked() {
+ public bool IsLocked() {
return locked;
}
///
/// Lock
///
- public static void Lock() {
- if (instance == null) return;
+ public void Lock() {
locked = true;
+ status.Visibility = Visibility.Visible;
- instance.status.Visibility = Visibility.Visible;
DoubleAnimation anim = new DoubleAnimation(0, 360, TimeSpan.FromSeconds(1));
anim.RepeatBehavior = RepeatBehavior.Forever;
- instance.statusIcon.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, anim);
+ statusIcon.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, anim);
}
///
/// Unlock
///
- public static void Unlock() {
- if (instance == null) return;
+ public void Unlock() {
locked = false;
- instance.statusIcon.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, null);
- instance.status.Visibility = Visibility.Collapsed;
+ statusIcon.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, null);
+ status.Visibility = Visibility.Collapsed;
}
///
/// Update status description
///
///
- public static void UpdateStatus(string desc) {
- if (instance == null) return;
-
- instance.Dispatcher.Invoke(() => {
- instance.statusMsg.Content = desc;
+ public void UpdateStatus(string desc) {
+ Dispatcher.Invoke(() => {
+ statusMsg.Content = desc;
});
}
@@ -89,23 +83,23 @@ namespace SourceGit.UI {
/// Close current popup.
///
///
- public static void Close(bool unlockFirst = false) {
- if (instance == null) return;
- if (instance.popupContent.Child == null) return;
+ public void Close(bool unlockFirst = false) {
+ if (popupContent.Child == null) return;
if (locked && !unlockFirst) return;
locked = false;
ThicknessAnimation anim = new ThicknessAnimation();
anim.Duration = TimeSpan.FromMilliseconds(150);
anim.From = new Thickness(0);
- anim.To = new Thickness(0, -(double)instance.popupContent.Child.GetValue(HeightProperty) - 16, 0, 0);
+ anim.To = new Thickness(0, -(double)popupContent.Child.GetValue(HeightProperty) - 16, 0, 0);
anim.Completed += (obj, ev) => {
- instance.Visibility = Visibility.Collapsed;
- instance.popupContent.Child = null;
+ Visibility = Visibility.Collapsed;
+ popupContent.Child = null;
};
- instance.popupContent.BeginAnimation(MarginProperty, anim);
- instance.statusIcon.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, null);
- instance.status.Visibility = Visibility.Collapsed;
+
+ popupContent.BeginAnimation(MarginProperty, anim);
+ statusIcon.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, null);
+ status.Visibility = Visibility.Collapsed;
}
///
diff --git a/SourceGit/UI/Preference.xaml b/SourceGit/UI/Preference.xaml
index 2ced4374..52ab8e5e 100644
--- a/SourceGit/UI/Preference.xaml
+++ b/SourceGit/UI/Preference.xaml
@@ -1,4 +1,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Height="520" Width="500"
+ Title="Preference"
+ WindowStartupLocation="CenterOwner" ResizeMode="NoResize">
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/SourceGit/UI/Preference.xaml.cs b/SourceGit/UI/Preference.xaml.cs
index ce699e91..8fa950b6 100644
--- a/SourceGit/UI/Preference.xaml.cs
+++ b/SourceGit/UI/Preference.xaml.cs
@@ -11,7 +11,7 @@ namespace SourceGit.UI {
///
/// Preference window.
///
- public partial class Preference : UserControl {
+ public partial class Preference : Window {
///
/// Git global user name.
@@ -75,13 +75,6 @@ namespace SourceGit.UI {
cmbAutoCRLF.SelectedItem = crlfOptions.Find(o => o.Value == AutoCRLF);
}
- ///
- /// Show preference.
- ///
- public static void Show() {
- PopupManager.Show(new Preference());
- }
-
///
/// Close this dialog
///
@@ -95,7 +88,7 @@ namespace SourceGit.UI {
var oldAutoCRLF = GetConfig("core.autocrlf");
if (oldAutoCRLF != AutoCRLF) SetConfig("core.autocrlf", AutoCRLF);
- PopupManager.Close();
+ Close();
}
///
diff --git a/SourceGit/UI/Pull.xaml.cs b/SourceGit/UI/Pull.xaml.cs
index e88fea7d..d75e3a79 100644
--- a/SourceGit/UI/Pull.xaml.cs
+++ b/SourceGit/UI/Pull.xaml.cs
@@ -30,7 +30,8 @@ namespace SourceGit.UI {
/// Opened repository
/// Prefered remote branch
public static void Show(Git.Repository opened, string preferRemoteBranch = null) {
- PopupManager.Show(new Pull(opened, preferRemoteBranch));
+ var popup = App.Launcher.GetPopupManager(opened);
+ popup?.Show(new Pull(opened, preferRemoteBranch));
}
///
@@ -76,9 +77,10 @@ namespace SourceGit.UI {
if (remote == null || branch == null) return;
- PopupManager.Lock();
- await Task.Run(() => repo.Pull(remote, branch.Substring(branch.IndexOf('/')+1), PopupManager.UpdateStatus, rebase, autoStash));
- PopupManager.Close(true);
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
+ await Task.Run(() => repo.Pull(remote, branch.Substring(branch.IndexOf('/')+1), msg => popup?.UpdateStatus(msg), rebase, autoStash));
+ popup?.Close(true);
}
///
@@ -87,7 +89,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
///
diff --git a/SourceGit/UI/Push.xaml.cs b/SourceGit/UI/Push.xaml.cs
index 717da35a..352e3a76 100644
--- a/SourceGit/UI/Push.xaml.cs
+++ b/SourceGit/UI/Push.xaml.cs
@@ -29,7 +29,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository repo, Git.Branch prefer = null) {
- PopupManager.Show(new Push(repo, prefer));
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(new Push(repo, prefer));
}
///
@@ -44,8 +45,9 @@ namespace SourceGit.UI {
}
var push = new Push(repo, current);
- PopupManager.Show(push);
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(push);
+ popup?.Lock();
var upstream = current.Upstream.Substring(13);
var remoteIdx = upstream.IndexOf('/');
@@ -53,9 +55,9 @@ namespace SourceGit.UI {
var remoteBranch = upstream.Substring(remoteIdx + 1);
Task.Run(() => {
- repo.Push(remote, current.Name, remoteBranch, PopupManager.UpdateStatus);
+ repo.Push(remote, current.Name, remoteBranch, msg => popup?.UpdateStatus(msg));
push.Dispatcher.Invoke(() => {
- PopupManager.Close(true);
+ popup?.Close(true);
});
});
}
@@ -96,9 +98,10 @@ namespace SourceGit.UI {
remoteBranch = remoteBranch.Substring(0, remoteBranch.Length - 6);
}
- PopupManager.Lock();
- await Task.Run(() => repo.Push(remote, localBranch.Name, remoteBranch, PopupManager.UpdateStatus, tags, track, force));
- PopupManager.Close(true);
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
+ await Task.Run(() => repo.Push(remote, localBranch.Name, remoteBranch, msg => popup?.UpdateStatus(msg), tags, track, force));
+ popup?.Close(true);
}
///
@@ -107,7 +110,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
///
diff --git a/SourceGit/UI/PushTag.xaml.cs b/SourceGit/UI/PushTag.xaml.cs
index b2b49d50..1cc89a67 100644
--- a/SourceGit/UI/PushTag.xaml.cs
+++ b/SourceGit/UI/PushTag.xaml.cs
@@ -32,7 +32,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository repo, Git.Tag tag) {
- PopupManager.Show(new PushTag(repo, tag));
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(new PushTag(repo, tag));
}
///
@@ -44,9 +45,10 @@ namespace SourceGit.UI {
var remote = combRemotes.SelectedItem as Git.Remote;
if (remote == null) return;
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
await Task.Run(() => Git.Tag.Push(repo, tag.Name, remote.Name));
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -55,7 +57,8 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Close();
}
}
}
diff --git a/SourceGit/UI/Rebase.xaml.cs b/SourceGit/UI/Rebase.xaml.cs
index d1eaeaf4..577cbb14 100644
--- a/SourceGit/UI/Rebase.xaml.cs
+++ b/SourceGit/UI/Rebase.xaml.cs
@@ -37,7 +37,9 @@ namespace SourceGit.UI {
dialog.branch.Content = current.Name;
dialog.type.Data = dialog.FindResource("Icon.Branch") as Geometry;
dialog.desc.Content = branch.Name;
- PopupManager.Show(dialog);
+
+ var popup = App.Launcher.GetPopupManager(opened);
+ popup?.Show(dialog);
}
///
@@ -54,7 +56,9 @@ namespace SourceGit.UI {
dialog.branch.Content = current.Name;
dialog.type.Data = dialog.FindResource("Icon.Commit") as Geometry;
dialog.desc.Content = $"{commit.ShortSHA} {commit.Subject}";
- PopupManager.Show(dialog);
+
+ var popup = App.Launcher.GetPopupManager(opened);
+ popup?.Show(dialog);
}
///
@@ -63,16 +67,17 @@ namespace SourceGit.UI {
///
///
private async void Start(object sender, RoutedEventArgs e) {
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
var autoStash = chkAutoStash.IsChecked == true;
await Task.Run(() => repo.Rebase(based, autoStash));
- PopupManager.Close(true);
+ popup?.Close(true);
}
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/Remote.xaml.cs b/SourceGit/UI/Remote.xaml.cs
index f20c4bc5..eda0b4f3 100644
--- a/SourceGit/UI/Remote.xaml.cs
+++ b/SourceGit/UI/Remote.xaml.cs
@@ -44,7 +44,7 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository opened, Git.Remote editing = null) {
- PopupManager.Show(new Remote(opened, editing));
+ App.Launcher.GetPopupManager(opened)?.Show(new Remote(opened, editing));
}
///
@@ -59,7 +59,8 @@ namespace SourceGit.UI {
txtUrl.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtUrl)) return;
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
await Task.Run(() => {
if (remote != null) {
@@ -69,7 +70,7 @@ namespace SourceGit.UI {
}
});
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -78,7 +79,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/RenameBranch.xaml.cs b/SourceGit/UI/RenameBranch.xaml.cs
index fb535fa3..8886fdda 100644
--- a/SourceGit/UI/RenameBranch.xaml.cs
+++ b/SourceGit/UI/RenameBranch.xaml.cs
@@ -38,7 +38,7 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository opened, Git.Branch branch) {
- PopupManager.Show(new RenameBranch(opened, branch));
+ App.Launcher.GetPopupManager(opened)?.Show(new RenameBranch(opened, branch));
}
///
@@ -50,9 +50,10 @@ namespace SourceGit.UI {
txtNewName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtNewName)) return;
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
await Task.Run(() => branch.Rename(repo, NewName));
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -61,7 +62,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/Reset.xaml.cs b/SourceGit/UI/Reset.xaml.cs
index c48c302d..071c3f14 100644
--- a/SourceGit/UI/Reset.xaml.cs
+++ b/SourceGit/UI/Reset.xaml.cs
@@ -59,7 +59,7 @@ namespace SourceGit.UI {
var current = repo.CurrentBranch();
if (current == null) return;
- PopupManager.Show(new Reset(repo, current, commit));
+ App.Launcher.GetPopupManager(repo)?.Show(new Reset(repo, current, commit));
}
///
@@ -71,9 +71,10 @@ namespace SourceGit.UI {
var mode = combMode.SelectedItem as Mode;
if (mode == null) return;
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
await Task.Run(() => repo.Reset(revision, mode.Arg));
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -82,7 +83,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/Revert.xaml.cs b/SourceGit/UI/Revert.xaml.cs
index 960a129d..58bbc0ef 100644
--- a/SourceGit/UI/Revert.xaml.cs
+++ b/SourceGit/UI/Revert.xaml.cs
@@ -30,7 +30,8 @@ namespace SourceGit.UI {
///
///
public static void Show(Git.Repository repo, Git.Commit commit) {
- PopupManager.Show(new Revert(repo, commit));
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(new Revert(repo, commit));
}
///
@@ -40,10 +41,10 @@ namespace SourceGit.UI {
///
private async void Sure(object sender, RoutedEventArgs e) {
bool autoCommit = chkCommit.IsChecked == true;
-
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Lock();
await Task.Run(() => repo.Revert(sha, autoCommit));
- PopupManager.Close(true);
+ popup?.Close(true);
}
///
@@ -52,7 +53,8 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Close();
}
}
}
diff --git a/SourceGit/UI/Stash.xaml.cs b/SourceGit/UI/Stash.xaml.cs
index 3710dd50..0db25dc7 100644
--- a/SourceGit/UI/Stash.xaml.cs
+++ b/SourceGit/UI/Stash.xaml.cs
@@ -1,4 +1,4 @@
-锘縰sing System.Collections.Generic;
+using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
@@ -28,7 +28,8 @@ namespace SourceGit.UI {
/// Opened repository
/// Special files to stash
public static void Show(Git.Repository repo, List files) {
- PopupManager.Show(new Stash(repo, files));
+ var popup = App.Launcher.GetPopupManager(repo);
+ popup?.Show(new Stash(repo, files));
}
///
@@ -41,7 +42,7 @@ namespace SourceGit.UI {
string message = txtName.Text;
Git.Stash.Push(repo, includeUntracked, message, files);
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
///
@@ -50,7 +51,7 @@ namespace SourceGit.UI {
///
///
private void Cancel(object sender, RoutedEventArgs e) {
- PopupManager.Close();
+ App.Launcher.GetPopupManager(repo)?.Close();
}
}
}
diff --git a/SourceGit/UI/Waiting.xaml.cs b/SourceGit/UI/Waiting.xaml.cs
index 3c15c82e..cfc8d9eb 100644
--- a/SourceGit/UI/Waiting.xaml.cs
+++ b/SourceGit/UI/Waiting.xaml.cs
@@ -19,15 +19,18 @@ namespace SourceGit.UI {
///
/// Show this dialog.
///
+ ///
///
- public static void Show(Action job) {
+ public static void Show(Git.Repository repo, Action job) {
var dialog = new Waiting();
- PopupManager.Show(dialog);
- PopupManager.Lock();
+ var popup = App.Launcher.GetPopupManager(repo);
+
+ popup?.Show(dialog);
+ popup?.Lock();
Task.Run(() => {
job.Invoke();
dialog.Dispatcher.Invoke(() => {
- PopupManager.Close(true);
+ popup?.Close(true);
});
});
}