refactor(PopupManager): rewrite popup

This commit is contained in:
leo 2020-08-06 15:41:25 +08:00
parent 28e3a1bb27
commit 7558bbd4f2
34 changed files with 183 additions and 221 deletions

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
@ -111,4 +112,42 @@ namespace SourceGit.UI {
Close();
}
}
/// <summary>
/// Extension methods for Git.Repository
/// </summary>
public static class RepositoryPopupBindings {
private static Dictionary<string, PopupManager> popups = new Dictionary<string, PopupManager>();
/// <summary>
/// Set popup manager for given repo.
/// </summary>
/// <param name="repo"></param>
/// <param name="popup"></param>
public static void SetPopupManager(this Git.Repository repo, PopupManager popup) {
if (popups.ContainsKey(repo.Path)) popups[repo.Path] = popup;
else popups.Add(repo.Path, popup);
}
/// <summary>
/// Remove popup manager by given repo.
/// </summary>
/// <param name="repo"></param>
public static void RemovePopup(this Git.Repository repo) {
if (popups.ContainsKey(repo.Path)) {
popups[repo.Path].Unlock();
popups.Remove(repo.Path);
}
}
/// <summary>
///
/// </summary>
/// <param name="repo"></param>
/// <returns></returns>
public static PopupManager GetPopupManager(this Git.Repository repo) {
if (popups.ContainsKey(repo.Path)) return popups[repo.Path];
return null;
}
}
}