using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; namespace SourceGit.UI { /// /// Confirm finish git-flow branch dialog /// public partial class GitFlowFinishBranch : UserControl { private Git.Repository repo = null; private Git.Branch branch = null; /// /// Constructor. /// /// /// public GitFlowFinishBranch(Git.Repository repo, Git.Branch branch) { this.repo = repo; this.branch = branch; InitializeComponent(); switch (branch.Kind) { case Git.Branch.Type.Feature: txtTitle.Content = "Git Flow - Finish Feature"; txtBranchType.Content = "Feature :"; break; case Git.Branch.Type.Release: txtTitle.Content = "Git Flow - Finish Release"; txtBranchType.Content = "Release :"; break; case Git.Branch.Type.Hotfix: txtTitle.Content = "Git Flow - Finish Hotfix"; txtBranchType.Content = "Hotfix :"; break; default: repo.GetPopupManager()?.Close(); return; } txtBranchName.Text = branch.Name; } /// /// Show this dialog. /// /// /// public static void Show(Git.Repository repo, Git.Branch branch) { repo.GetPopupManager()?.Show(new GitFlowFinishBranch(repo, branch)); } /// /// Do finish /// /// /// private async void Sure(object sender, RoutedEventArgs e) { var popup = repo.GetPopupManager(); popup?.Lock(); await Task.Run(() => repo.FinishGitFlowBranch(branch)); popup?.Close(true); } /// /// Cancel finish /// /// /// private void Cancel(object sender, RoutedEventArgs e) { repo.GetPopupManager()?.Close(); } } }