using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace SourceGit.UI {
///
/// Rename branch dialog.
///
public partial class RenameBranch : UserControl {
private Git.Repository repo = null;
private Git.Branch branch = null;
///
/// New branch name.
///
public string NewName { get; set; }
///
/// Constructor.
///
/// Opened repository.
/// Branch to rename.
public RenameBranch(Git.Repository opened, Git.Branch target) {
repo = opened;
branch = target;
NewName = target.Name;
InitializeComponent();
nameValidator.Repo = opened;
txtOldName.Content = target.Name;
}
///
/// Show this dialog
///
///
///
public static void Show(Git.Repository opened, Git.Branch branch) {
PopupManager.Show(new RenameBranch(opened, branch));
}
///
/// Rename
///
///
///
private async void Sure(object sender, RoutedEventArgs e) {
txtNewName.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtNewName)) return;
PopupManager.Lock();
await Task.Run(() => branch.Rename(repo, NewName));
PopupManager.Close(true);
}
///
/// Cancel merge.
///
///
///
private void Cancel(object sender, RoutedEventArgs e) {
PopupManager.Close();
}
}
}