optimize(*): move App.Launcher.GetPopupManager to App.GetPopupManager

This commit is contained in:
leo 2020-08-05 09:32:24 +08:00
parent 3c24eaa6a7
commit 5066b974a1
34 changed files with 126 additions and 133 deletions

View file

@ -36,14 +36,6 @@ namespace SourceGit {
set; set;
} }
/// <summary>
/// Get main window.
/// </summary>
public static UI.Launcher Launcher {
get;
private set;
}
/// <summary> /// <summary>
/// Raise error message. /// Raise error message.
/// </summary> /// </summary>
@ -52,6 +44,26 @@ namespace SourceGit {
OnError?.Invoke(message); OnError?.Invoke(message);
} }
/// <summary>
/// Get popup manager by repository
/// </summary>
/// <param name="repo"></param>
/// <returns></returns>
public static UI.PopupManager GetPopupManager(Git.Repository repo) {
var main = Current.MainWindow as UI.Launcher;
if (main == null) return null;
if (repo == null) return (main.Tabs[0].Page as UI.Manager).popupManager;
for (int i = 1; i < main.openedTabs.Items.Count; i++) {
var opened = main.openedTabs.Items[i] as UI.Launcher.Tab;
if (opened.Repo.Path == repo.Path) {
return (opened.Page as UI.Dashboard).popupManager;
}
}
return null;
}
/// <summary> /// <summary>
/// Startup event. /// Startup event.
/// </summary> /// </summary>
@ -100,8 +112,8 @@ namespace SourceGit {
} }
// Show main window // Show main window
Launcher = new UI.Launcher(); Current.MainWindow = new UI.Launcher();
Launcher.Show(); Current.MainWindow.Show();
} }
/// <summary> /// <summary>

View file

@ -34,7 +34,7 @@ namespace SourceGit.UI {
/// </summary> /// </summary>
/// <param name="repo"></param> /// <param name="repo"></param>
public static void Show(Git.Repository repo) { public static void Show(Git.Repository repo) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(new AddSubmodule(repo)); popup?.Show(new AddSubmodule(repo));
} }
@ -58,7 +58,7 @@ namespace SourceGit.UI {
if (Validation.GetHasError(txtPath)) return; if (Validation.GetHasError(txtPath)) return;
var recursive = chkRecursive.IsChecked == true; var recursive = chkRecursive.IsChecked == true;
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
await Task.Run(() => repo.AddSubmodule(RepoURL, LocalPath, recursive, msg => { await Task.Run(() => repo.AddSubmodule(RepoURL, LocalPath, recursive, msg => {
@ -68,7 +68,7 @@ namespace SourceGit.UI {
} }
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
#endregion #endregion
} }

View file

@ -52,7 +52,7 @@ namespace SourceGit.UI {
/// </summary> /// </summary>
/// <param name="opened"></param> /// <param name="opened"></param>
public static void Show(Git.Repository opened) { public static void Show(Git.Repository opened) {
var popup = App.Launcher.GetPopupManager(opened); var popup = App.GetPopupManager(opened);
popup?.Show(new Apply(opened)); popup?.Show(new Apply(opened));
} }
@ -83,7 +83,7 @@ namespace SourceGit.UI {
txtPatchFile.GetBindingExpression(TextBox.TextProperty).UpdateSource(); txtPatchFile.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtPatchFile)) return; if (Validation.GetHasError(txtPatchFile)) return;
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
var mode = combWhitespaceOptions.SelectedItem as WhitespaceOption; var mode = combWhitespaceOptions.SelectedItem as WhitespaceOption;
@ -99,7 +99,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -36,7 +36,7 @@ namespace SourceGit.UI {
double minWidth = content.ActualWidth; double minWidth = content.ActualWidth;
// Move to center. // Move to center.
var parent = App.Launcher; var parent = App.Current.MainWindow;
Left = parent.Left + (parent.Width - Width) * 0.5; Left = parent.Left + (parent.Width - Width) * 0.5;
Top = parent.Top + (parent.Height - Height) * 0.5; Top = parent.Top + (parent.Height - Height) * 0.5;

View file

@ -29,7 +29,7 @@ namespace SourceGit.UI {
/// <param name="repo"></param> /// <param name="repo"></param>
/// <param name="commit"></param> /// <param name="commit"></param>
public static void Show(Git.Repository repo, Git.Commit commit) { public static void Show(Git.Repository repo, Git.Commit commit) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(new CherryPick(repo, commit)); popup?.Show(new CherryPick(repo, commit));
} }
@ -41,7 +41,7 @@ namespace SourceGit.UI {
private void Start(object sender, RoutedEventArgs e) { private void Start(object sender, RoutedEventArgs e) {
repo.CherryPick(commitSHA, chkCommitChanges.IsChecked != true); repo.CherryPick(commitSHA, chkCommitChanges.IsChecked != true);
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Close(); popup?.Close();
} }
@ -51,7 +51,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Close(); popup?.Close();
} }
} }

View file

@ -42,7 +42,7 @@ namespace SourceGit.UI {
/// Show clone dialog. /// Show clone dialog.
/// </summary> /// </summary>
public static void Show() { public static void Show() {
var popup = App.Launcher.GetPopupManager(null); var popup = App.GetPopupManager(null);
popup?.Show(new Clone()); popup?.Show(new Clone());
} }
@ -92,7 +92,7 @@ namespace SourceGit.UI {
rName = RemoteName; rName = RemoteName;
} }
var popup = App.Launcher.GetPopupManager(null); var popup = App.GetPopupManager(null);
popup.Lock(); popup.Lock();
var repo = await Task.Run(() => { var repo = await Task.Run(() => {
@ -113,7 +113,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(null).Close(); App.GetPopupManager(null).Close();
} }
} }
} }

View file

@ -43,7 +43,7 @@ namespace SourceGit.UI {
/// </summary> /// </summary>
/// <param name="repo"></param> /// <param name="repo"></param>
public static void Show(Git.Repository repo) { public static void Show(Git.Repository repo) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(new Configure(repo)); popup?.Show(new Configure(repo));
} }
@ -64,7 +64,7 @@ namespace SourceGit.UI {
} }
private void Close(object sender, RoutedEventArgs e) { private void Close(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
#endregion #endregion
} }

View file

@ -59,7 +59,7 @@ namespace SourceGit.UI {
if (!branch.IsLocal) dialog.txtName.Text = branch.Name.Substring(branch.Remote.Length + 1); if (!branch.IsLocal) dialog.txtName.Text = branch.Name.Substring(branch.Remote.Length + 1);
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(dialog); popup?.Show(dialog);
} }
@ -74,7 +74,7 @@ namespace SourceGit.UI {
dialog.basedOnType.Data = dialog.FindResource("Icon.Tag") as Geometry; dialog.basedOnType.Data = dialog.FindResource("Icon.Tag") as Geometry;
dialog.basedOnDesc.Content = tag.Name; dialog.basedOnDesc.Content = tag.Name;
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(dialog); popup?.Show(dialog);
} }
@ -89,7 +89,7 @@ namespace SourceGit.UI {
dialog.basedOnType.Data = dialog.FindResource("Icon.Commit") as Geometry; dialog.basedOnType.Data = dialog.FindResource("Icon.Commit") as Geometry;
dialog.basedOnDesc.Content = $"{commit.ShortSHA} {commit.Subject}"; dialog.basedOnDesc.Content = $"{commit.ShortSHA} {commit.Subject}";
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(dialog); popup?.Show(dialog);
} }
@ -102,7 +102,7 @@ namespace SourceGit.UI {
txtName.GetBindingExpression(TextBox.TextProperty).UpdateSource(); txtName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtName)) return; if (Validation.GetHasError(txtName)) return;
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
bool checkout = chkCheckout.IsChecked == true; bool checkout = chkCheckout.IsChecked == true;
@ -135,7 +135,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -52,7 +52,7 @@ namespace SourceGit.UI {
dialog.basedOnType.Data = dialog.FindResource("Icon.Branch") as Geometry; dialog.basedOnType.Data = dialog.FindResource("Icon.Branch") as Geometry;
dialog.basedOnDesc.Content = branch.Name; dialog.basedOnDesc.Content = branch.Name;
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(dialog); popup?.Show(dialog);
} }
@ -67,7 +67,7 @@ namespace SourceGit.UI {
dialog.basedOnType.Data = dialog.FindResource("Icon.Commit") as Geometry; dialog.basedOnType.Data = dialog.FindResource("Icon.Commit") as Geometry;
dialog.basedOnDesc.Content = $"{commit.ShortSHA} {commit.Subject}"; dialog.basedOnDesc.Content = $"{commit.ShortSHA} {commit.Subject}";
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(dialog); popup?.Show(dialog);
} }
@ -82,7 +82,7 @@ namespace SourceGit.UI {
Git.Tag.Add(repo, TagName, based, tagMessage.Text); Git.Tag.Add(repo, TagName, based, tagMessage.Text);
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Close(); popup?.Close();
} }
@ -92,7 +92,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -7,7 +7,8 @@
xmlns:local="clr-namespace:SourceGit.UI" xmlns:local="clr-namespace:SourceGit.UI"
xmlns:converters="clr-namespace:SourceGit.Converters" xmlns:converters="clr-namespace:SourceGit.Converters"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800"
Unloaded="Cleanup">
<UserControl.Resources> <UserControl.Resources>
<RoutedUICommand x:Key="OpenSearchBarCommand" Text="OpenSearchBar"/> <RoutedUICommand x:Key="OpenSearchBarCommand" Text="OpenSearchBar"/>
<RoutedUICommand x:Key="HideSearchBarCommand" Text="HideSearchBar"/> <RoutedUICommand x:Key="HideSearchBarCommand" Text="HideSearchBar"/>

View file

@ -78,17 +78,6 @@ namespace SourceGit.UI {
UpdateSubmodules(); UpdateSubmodules();
} }
/// <summary>
/// Cleanup all items
/// </summary>
public void Cleanup() {
localBranchTree.ItemsSource = null;
remoteBranchTree.ItemsSource = null;
tagList.ItemsSource = null;
cachedLocalBranches.Clear();
cachedRemotes.Clear();
}
#region DATA_UPDATE #region DATA_UPDATE
private void UpdateHistories() { private void UpdateHistories() {
Dispatcher.Invoke(() => { Dispatcher.Invoke(() => {
@ -300,6 +289,14 @@ namespace SourceGit.UI {
}); });
}); });
} }
private void Cleanup(object sender, RoutedEventArgs e) {
localBranchTree.ItemsSource = null;
remoteBranchTree.ItemsSource = null;
tagList.ItemsSource = null;
cachedLocalBranches.Clear();
cachedRemotes.Clear();
}
#endregion #endregion
#region TOOLBAR #region TOOLBAR

View file

@ -28,7 +28,7 @@ namespace SourceGit.UI {
/// <param name="opened"></param> /// <param name="opened"></param>
/// <param name="branch"></param> /// <param name="branch"></param>
public static void Show(Git.Repository opened, Git.Branch branch) { public static void Show(Git.Repository opened, Git.Branch branch) {
var popup = App.Launcher.GetPopupManager(opened); var popup = App.GetPopupManager(opened);
popup?.Show(new DeleteBranch(opened, branch)); popup?.Show(new DeleteBranch(opened, branch));
} }
@ -38,7 +38,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private async void Sure(object sender, RoutedEventArgs e) { private async void Sure(object sender, RoutedEventArgs e) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
await Task.Run(() => branch.Delete(repo)); await Task.Run(() => branch.Delete(repo));
popup?.Close(true); popup?.Close(true);
@ -50,7 +50,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -29,7 +29,7 @@ namespace SourceGit.UI {
/// <param name="opened"></param> /// <param name="opened"></param>
/// <param name="remote"></param> /// <param name="remote"></param>
public static void Show(Git.Repository opened, string remote) { public static void Show(Git.Repository opened, string remote) {
var popup = App.Launcher.GetPopupManager(opened); var popup = App.GetPopupManager(opened);
popup?.Show(new DeleteRemote(opened, remote)); popup?.Show(new DeleteRemote(opened, remote));
} }
@ -39,7 +39,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private async void Sure(object sender, RoutedEventArgs e) { private async void Sure(object sender, RoutedEventArgs e) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
await Task.Run(() => Git.Remote.Delete(repo, remote)); await Task.Run(() => Git.Remote.Delete(repo, remote));
popup?.Close(true); popup?.Close(true);
@ -51,7 +51,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -30,7 +30,7 @@ namespace SourceGit.UI {
/// <param name="repo"></param> /// <param name="repo"></param>
/// <param name="tag"></param> /// <param name="tag"></param>
public static void Show(Git.Repository repo, Git.Tag tag) { public static void Show(Git.Repository repo, Git.Tag tag) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(new DeleteTag(repo, tag)); popup?.Show(new DeleteTag(repo, tag));
} }
@ -40,7 +40,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private async void Start(object sender, RoutedEventArgs e) { private async void Start(object sender, RoutedEventArgs e) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
var push = chkWithRemote.IsChecked == true; var push = chkWithRemote.IsChecked == true;
@ -55,7 +55,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -40,19 +40,19 @@ namespace SourceGit.UI {
/// <param name="opened"></param> /// <param name="opened"></param>
/// <param name="targets"></param> /// <param name="targets"></param>
public static void Show(Git.Repository opened, List<Git.Change> targets) { public static void Show(Git.Repository opened, List<Git.Change> targets) {
var popup = App.Launcher.GetPopupManager(opened); var popup = App.GetPopupManager(opened);
popup?.Show(new Discard(opened, targets)); popup?.Show(new Discard(opened, targets));
} }
private async void Sure(object sender, RoutedEventArgs e) { private async void Sure(object sender, RoutedEventArgs e) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
await Task.Run(() => repo.Discard(changes)); await Task.Run(() => repo.Discard(changes));
popup?.Close(true); popup?.Close(true);
} }
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -40,7 +40,7 @@ namespace SourceGit.UI {
/// <param name="repo"></param> /// <param name="repo"></param>
/// <param name="preferRemote"></param> /// <param name="preferRemote"></param>
public static void Show(Git.Repository repo, string preferRemote = null) { public static void Show(Git.Repository repo, string preferRemote = null) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(new Fetch(repo, preferRemote)); popup?.Show(new Fetch(repo, preferRemote));
} }
@ -52,7 +52,7 @@ namespace SourceGit.UI {
private async void Start(object sender, RoutedEventArgs e) { private async void Start(object sender, RoutedEventArgs e) {
bool prune = chkPrune.IsChecked == true; bool prune = chkPrune.IsChecked == true;
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
if (chkFetchAll.IsChecked == true) { if (chkFetchAll.IsChecked == true) {
@ -71,7 +71,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -29,7 +29,7 @@ namespace SourceGit.UI {
InitializeComponent(); InitializeComponent();
// Move to center // Move to center
var parent = App.Launcher; var parent = App.Current.MainWindow;
Left = parent.Left + (parent.Width - Width) * 0.5; Left = parent.Left + (parent.Width - Width) * 0.5;
Top = parent.Top + (parent.Height - Height) * 0.5; Top = parent.Top + (parent.Height - Height) * 0.5;

View file

@ -36,7 +36,7 @@ namespace SourceGit.UI {
txtBranchType.Content = "Hotfix :"; txtBranchType.Content = "Hotfix :";
break; break;
default: default:
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Close(); popup?.Close();
return; return;
} }
@ -50,7 +50,7 @@ namespace SourceGit.UI {
/// <param name="repo"></param> /// <param name="repo"></param>
/// <param name="branch"></param> /// <param name="branch"></param>
public static void Show(Git.Repository repo, Git.Branch branch) { public static void Show(Git.Repository repo, Git.Branch branch) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(new GitFlowFinishBranch(repo, branch)); popup?.Show(new GitFlowFinishBranch(repo, branch));
} }
@ -60,7 +60,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private async void Sure(object sender, RoutedEventArgs e) { private async void Sure(object sender, RoutedEventArgs e) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
await Task.Run(() => repo.FinishGitFlowBranch(branch)); await Task.Run(() => repo.FinishGitFlowBranch(branch));
popup?.Close(true); popup?.Close(true);
@ -72,7 +72,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -26,7 +26,7 @@ namespace SourceGit.UI {
/// </summary> /// </summary>
/// <param name="repo"></param> /// <param name="repo"></param>
public static void Show(Git.Repository repo) { public static void Show(Git.Repository repo) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(new GitFlowSetup(repo)); popup?.Show(new GitFlowSetup(repo));
} }
@ -36,7 +36,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private async void Sure(object sender, RoutedEventArgs e) { private async void Sure(object sender, RoutedEventArgs e) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
var master = txtMaster.Text; var master = txtMaster.Text;
@ -56,7 +56,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
/// <summary> /// <summary>

View file

@ -51,7 +51,7 @@ namespace SourceGit.UI {
nameValidator.Prefix = hotfixPrefix; nameValidator.Prefix = hotfixPrefix;
break; break;
default: default:
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Close(); popup?.Close();
return; return;
} }
@ -63,7 +63,7 @@ namespace SourceGit.UI {
/// <param name="repo"></param> /// <param name="repo"></param>
/// <param name="type"></param> /// <param name="type"></param>
public static void Show(Git.Repository repo, Git.Branch.Type type) { public static void Show(Git.Repository repo, Git.Branch.Type type) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(new GitFlowStartBranch(repo, type)); popup?.Show(new GitFlowStartBranch(repo, type));
} }
@ -76,7 +76,7 @@ namespace SourceGit.UI {
txtName.GetBindingExpression(TextBox.TextProperty).UpdateSource(); txtName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtName)) return; if (Validation.GetHasError(txtName)) return;
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
await Task.Run(() => repo.StartGitFlowBranch(type, SubName)); await Task.Run(() => repo.StartGitFlowBranch(type, SubName));
popup?.Close(true); popup?.Close(true);
@ -88,7 +88,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -526,7 +526,7 @@ namespace SourceGit.UI {
} }
var dialog = new InteractiveRebase(Repo, commit); var dialog = new InteractiveRebase(Repo, commit);
dialog.Owner = App.Launcher; dialog.Owner = App.Current.MainWindow;
dialog.ShowDialog(); dialog.ShowDialog();
} else { } else {
Rebase.Show(Repo, commit); Rebase.Show(Repo, commit);

View file

@ -25,7 +25,7 @@ namespace SourceGit.UI {
/// </summary> /// </summary>
/// <param name="path"></param> /// <param name="path"></param>
public static void Show(string path) { public static void Show(string path) {
var popup = App.Launcher.GetPopupManager(null); var popup = App.GetPopupManager(null);
popup.Show(new Init(path)); popup.Show(new Init(path));
} }
@ -35,7 +35,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private async void Sure(object sender, RoutedEventArgs e) { private async void Sure(object sender, RoutedEventArgs e) {
var popup = App.Launcher.GetPopupManager(null); var popup = App.GetPopupManager(null);
popup.Lock(); popup.Lock();
await Task.Run(() => { await Task.Run(() => {
@ -59,7 +59,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(null).Close(); App.GetPopupManager(null).Close();
} }
} }
} }

View file

@ -48,9 +48,9 @@ namespace SourceGit.UI {
Git.Repository.OnOpen = repo => { Git.Repository.OnOpen = repo => {
Dispatcher.Invoke(() => { Dispatcher.Invoke(() => {
foreach (var item in openedTabs.Items) { for (int i = 1; i < openedTabs.Items.Count; i++) {
var opened = item as Tab; var opened = openedTabs.Items[i] as Tab;
if (opened != null && opened.Repo != null && repo.Path == opened.Repo.Path) { if (opened.Repo.Path == repo.Path) {
openedTabs.SelectedItem = opened; openedTabs.SelectedItem = opened;
return; return;
} }
@ -76,23 +76,6 @@ namespace SourceGit.UI {
openedTabs.SelectedItem = Tabs[0]; openedTabs.SelectedItem = Tabs[0];
} }
/// <summary>
/// Get popup manager from given active page.
/// </summary>
/// <param name="repo"></param>
/// <returns></returns>
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 #region LAYOUT_CONTENT
/// <summary> /// <summary>
/// Close repository tab. /// Close repository tab.

View file

@ -53,7 +53,7 @@ namespace SourceGit.UI {
/// <param name="source"></param> /// <param name="source"></param>
/// <param name="dest"></param> /// <param name="dest"></param>
public static void Show(Git.Repository opened, string source, string dest) { public static void Show(Git.Repository opened, string source, string dest) {
var popup = App.Launcher.GetPopupManager(opened); var popup = App.GetPopupManager(opened);
popup?.Show(new Merge(opened, source, dest)); popup?.Show(new Merge(opened, source, dest));
} }
@ -65,7 +65,7 @@ namespace SourceGit.UI {
/// <param name="dest"></param> /// <param name="dest"></param>
public static void StartDirectly(Git.Repository opened, string source, string dest) { public static void StartDirectly(Git.Repository opened, string source, string dest) {
var merge = new Merge(opened, source, dest); var merge = new Merge(opened, source, dest);
var popup = App.Launcher.GetPopupManager(opened); var popup = App.GetPopupManager(opened);
popup?.Show(merge); popup?.Show(merge);
popup?.Lock(); popup?.Lock();
@ -83,7 +83,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private async void Start(object sender, RoutedEventArgs e) { private async void Start(object sender, RoutedEventArgs e) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
var branch = sourceBranch.Content as string; var branch = sourceBranch.Content as string;
@ -99,7 +99,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -30,7 +30,7 @@ namespace SourceGit.UI {
/// <param name="opened">Opened repository</param> /// <param name="opened">Opened repository</param>
/// <param name="preferRemoteBranch">Prefered remote branch</param> /// <param name="preferRemoteBranch">Prefered remote branch</param>
public static void Show(Git.Repository opened, string preferRemoteBranch = null) { public static void Show(Git.Repository opened, string preferRemoteBranch = null) {
var popup = App.Launcher.GetPopupManager(opened); var popup = App.GetPopupManager(opened);
popup?.Show(new Pull(opened, preferRemoteBranch)); popup?.Show(new Pull(opened, preferRemoteBranch));
} }
@ -77,7 +77,7 @@ namespace SourceGit.UI {
if (remote == null || branch == null) return; if (remote == null || branch == null) return;
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
await Task.Run(() => repo.Pull(remote, branch.Substring(branch.IndexOf('/')+1), msg => popup?.UpdateStatus(msg), rebase, autoStash)); await Task.Run(() => repo.Pull(remote, branch.Substring(branch.IndexOf('/')+1), msg => popup?.UpdateStatus(msg), rebase, autoStash));
popup?.Close(true); popup?.Close(true);
@ -89,7 +89,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
/// <summary> /// <summary>

View file

@ -29,7 +29,7 @@ namespace SourceGit.UI {
/// <param name="repo"></param> /// <param name="repo"></param>
/// <param name="prefer"></param> /// <param name="prefer"></param>
public static void Show(Git.Repository repo, Git.Branch prefer = null) { public static void Show(Git.Repository repo, Git.Branch prefer = null) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(new Push(repo, prefer)); popup?.Show(new Push(repo, prefer));
} }
@ -45,7 +45,7 @@ namespace SourceGit.UI {
} }
var push = new Push(repo, current); var push = new Push(repo, current);
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(push); popup?.Show(push);
popup?.Lock(); popup?.Lock();
@ -98,7 +98,7 @@ namespace SourceGit.UI {
remoteBranch = remoteBranch.Substring(0, remoteBranch.Length - 6); remoteBranch = remoteBranch.Substring(0, remoteBranch.Length - 6);
} }
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
await Task.Run(() => repo.Push(remote, localBranch.Name, remoteBranch, msg => popup?.UpdateStatus(msg), tags, track, force)); await Task.Run(() => repo.Push(remote, localBranch.Name, remoteBranch, msg => popup?.UpdateStatus(msg), tags, track, force));
popup?.Close(true); popup?.Close(true);
@ -110,7 +110,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
/// <summary> /// <summary>

View file

@ -32,7 +32,7 @@ namespace SourceGit.UI {
/// <param name="repo"></param> /// <param name="repo"></param>
/// <param name="tag"></param> /// <param name="tag"></param>
public static void Show(Git.Repository repo, Git.Tag tag) { public static void Show(Git.Repository repo, Git.Tag tag) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(new PushTag(repo, tag)); popup?.Show(new PushTag(repo, tag));
} }
@ -45,7 +45,7 @@ namespace SourceGit.UI {
var remote = combRemotes.SelectedItem as Git.Remote; var remote = combRemotes.SelectedItem as Git.Remote;
if (remote == null) return; if (remote == null) return;
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
await Task.Run(() => Git.Tag.Push(repo, tag.Name, remote.Name)); await Task.Run(() => Git.Tag.Push(repo, tag.Name, remote.Name));
popup?.Close(true); popup?.Close(true);
@ -57,7 +57,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Close(); popup?.Close();
} }
} }

View file

@ -38,7 +38,7 @@ namespace SourceGit.UI {
dialog.type.Data = dialog.FindResource("Icon.Branch") as Geometry; dialog.type.Data = dialog.FindResource("Icon.Branch") as Geometry;
dialog.desc.Content = branch.Name; dialog.desc.Content = branch.Name;
var popup = App.Launcher.GetPopupManager(opened); var popup = App.GetPopupManager(opened);
popup?.Show(dialog); popup?.Show(dialog);
} }
@ -57,7 +57,7 @@ namespace SourceGit.UI {
dialog.type.Data = dialog.FindResource("Icon.Commit") as Geometry; dialog.type.Data = dialog.FindResource("Icon.Commit") as Geometry;
dialog.desc.Content = $"{commit.ShortSHA} {commit.Subject}"; dialog.desc.Content = $"{commit.ShortSHA} {commit.Subject}";
var popup = App.Launcher.GetPopupManager(opened); var popup = App.GetPopupManager(opened);
popup?.Show(dialog); popup?.Show(dialog);
} }
@ -67,7 +67,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private async void Start(object sender, RoutedEventArgs e) { private async void Start(object sender, RoutedEventArgs e) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
var autoStash = chkAutoStash.IsChecked == true; var autoStash = chkAutoStash.IsChecked == true;
@ -77,7 +77,7 @@ namespace SourceGit.UI {
} }
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -44,7 +44,7 @@ namespace SourceGit.UI {
/// <param name="opened"></param> /// <param name="opened"></param>
/// <param name="editing"></param> /// <param name="editing"></param>
public static void Show(Git.Repository opened, Git.Remote editing = null) { public static void Show(Git.Repository opened, Git.Remote editing = null) {
App.Launcher.GetPopupManager(opened)?.Show(new Remote(opened, editing)); App.GetPopupManager(opened)?.Show(new Remote(opened, editing));
} }
/// <summary> /// <summary>
@ -59,7 +59,7 @@ namespace SourceGit.UI {
txtUrl.GetBindingExpression(TextBox.TextProperty).UpdateSource(); txtUrl.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtUrl)) return; if (Validation.GetHasError(txtUrl)) return;
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
await Task.Run(() => { await Task.Run(() => {
@ -79,7 +79,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -38,7 +38,7 @@ namespace SourceGit.UI {
/// <param name="opened"></param> /// <param name="opened"></param>
/// <param name="branch"></param> /// <param name="branch"></param>
public static void Show(Git.Repository opened, Git.Branch branch) { public static void Show(Git.Repository opened, Git.Branch branch) {
App.Launcher.GetPopupManager(opened)?.Show(new RenameBranch(opened, branch)); App.GetPopupManager(opened)?.Show(new RenameBranch(opened, branch));
} }
/// <summary> /// <summary>
@ -50,7 +50,7 @@ namespace SourceGit.UI {
txtNewName.GetBindingExpression(TextBox.TextProperty).UpdateSource(); txtNewName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtNewName)) return; if (Validation.GetHasError(txtNewName)) return;
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
await Task.Run(() => branch.Rename(repo, NewName)); await Task.Run(() => branch.Rename(repo, NewName));
popup?.Close(true); popup?.Close(true);
@ -62,7 +62,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -59,7 +59,7 @@ namespace SourceGit.UI {
var current = repo.CurrentBranch(); var current = repo.CurrentBranch();
if (current == null) return; if (current == null) return;
App.Launcher.GetPopupManager(repo)?.Show(new Reset(repo, current, commit)); App.GetPopupManager(repo)?.Show(new Reset(repo, current, commit));
} }
/// <summary> /// <summary>
@ -71,7 +71,7 @@ namespace SourceGit.UI {
var mode = combMode.SelectedItem as Mode; var mode = combMode.SelectedItem as Mode;
if (mode == null) return; if (mode == null) return;
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
await Task.Run(() => repo.Reset(revision, mode.Arg)); await Task.Run(() => repo.Reset(revision, mode.Arg));
popup?.Close(true); popup?.Close(true);
@ -83,7 +83,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -30,7 +30,7 @@ namespace SourceGit.UI {
/// <param name="repo"></param> /// <param name="repo"></param>
/// <param name="commit"></param> /// <param name="commit"></param>
public static void Show(Git.Repository repo, Git.Commit commit) { public static void Show(Git.Repository repo, Git.Commit commit) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(new Revert(repo, commit)); popup?.Show(new Revert(repo, commit));
} }
@ -41,7 +41,7 @@ namespace SourceGit.UI {
/// <param name="e"></param> /// <param name="e"></param>
private async void Sure(object sender, RoutedEventArgs e) { private async void Sure(object sender, RoutedEventArgs e) {
bool autoCommit = chkCommit.IsChecked == true; bool autoCommit = chkCommit.IsChecked == true;
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Lock(); popup?.Lock();
await Task.Run(() => repo.Revert(sha, autoCommit)); await Task.Run(() => repo.Revert(sha, autoCommit));
popup?.Close(true); popup?.Close(true);
@ -53,7 +53,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Close(); popup?.Close();
} }
} }

View file

@ -28,7 +28,7 @@ namespace SourceGit.UI {
/// <param name="repo">Opened repository</param> /// <param name="repo">Opened repository</param>
/// <param name="files">Special files to stash</param> /// <param name="files">Special files to stash</param>
public static void Show(Git.Repository repo, List<string> files) { public static void Show(Git.Repository repo, List<string> files) {
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(new Stash(repo, files)); popup?.Show(new Stash(repo, files));
} }
@ -42,7 +42,7 @@ namespace SourceGit.UI {
string message = txtName.Text; string message = txtName.Text;
Git.Stash.Push(repo, includeUntracked, message, files); Git.Stash.Push(repo, includeUntracked, message, files);
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
/// <summary> /// <summary>
@ -51,7 +51,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Cancel(object sender, RoutedEventArgs e) { private void Cancel(object sender, RoutedEventArgs e) {
App.Launcher.GetPopupManager(repo)?.Close(); App.GetPopupManager(repo)?.Close();
} }
} }
} }

View file

@ -23,7 +23,7 @@ namespace SourceGit.UI {
/// <param name="job"></param> /// <param name="job"></param>
public static void Show(Git.Repository repo, Action job) { public static void Show(Git.Repository repo, Action job) {
var dialog = new Waiting(); var dialog = new Waiting();
var popup = App.Launcher.GetPopupManager(repo); var popup = App.GetPopupManager(repo);
popup?.Show(dialog); popup?.Show(dialog);
popup?.Lock(); popup?.Lock();