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;
}
/// <summary>
/// Get main window.
/// </summary>
public static UI.Launcher Launcher {
get;
private set;
}
/// <summary>
/// Raise error message.
/// </summary>
@ -52,6 +44,26 @@ namespace SourceGit {
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>
/// Startup event.
/// </summary>
@ -100,8 +112,8 @@ namespace SourceGit {
}
// Show main window
Launcher = new UI.Launcher();
Launcher.Show();
Current.MainWindow = new UI.Launcher();
Current.MainWindow.Show();
}
/// <summary>