using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; namespace SourceGit.UI { /// /// Start git-flow branch dialog. /// public partial class GitFlowStartBranch : UserControl { private Git.Repository repo = null; private Git.Branch.Type type = Git.Branch.Type.Feature; /// /// Sub-name for this git-flow branch. /// public string SubName { get; set; } /// /// Constructor. /// /// /// public GitFlowStartBranch(Git.Repository repo, Git.Branch.Type type) { this.repo = repo; this.type = type; InitializeComponent(); nameValidator.Repo = repo; switch (type) { case Git.Branch.Type.Feature: var featurePrefix = repo.GetFeaturePrefix(); txtTitle.Content = "Git Flow - Start Feature"; txtPrefix.Content = featurePrefix; nameValidator.Prefix = featurePrefix; break; case Git.Branch.Type.Release: var releasePrefix = repo.GetReleasePrefix(); txtTitle.Content = "Git Flow - Start Release"; txtPrefix.Content = releasePrefix; nameValidator.Prefix = releasePrefix; break; case Git.Branch.Type.Hotfix: var hotfixPrefix = repo.GetHotfixPrefix(); txtTitle.Content = "Git Flow - Start Hotfix"; txtPrefix.Content = hotfixPrefix; nameValidator.Prefix = hotfixPrefix; break; default: PopupManager.Close(); return; } } /// /// Display this dialog /// /// /// public static void Show(Git.Repository repo, Git.Branch.Type type) { PopupManager.Show(new GitFlowStartBranch(repo, type)); } /// /// Start git-flow branch /// /// /// private async void Sure(object sender, RoutedEventArgs e) { txtName.GetBindingExpression(TextBox.TextProperty).UpdateSource(); if (Validation.GetHasError(txtName)) return; PopupManager.Lock(); await Task.Run(() => repo.StartGitFlowBranch(type, SubName)); PopupManager.Close(true); } /// /// Cancel /// /// /// private void Cancel(object sender, RoutedEventArgs e) { PopupManager.Close(); } } }