private void OkClick(object sender, EventArgs e)
        {
            try
            {
                var selectedBranches = Branches.GetSelectedBranches().ToArray();

                if (!selectedBranches.Any())
                {
                    return;
                }

                if (_currentBranch != null && selectedBranches.Any(branch => branch.Name == _currentBranch))
                {
                    MessageBox.Show(this, string.Format(_cannotDeleteCurrentBranchMessage.Text, _currentBranch), _deleteBranchCaption.Text);
                    return;
                }

                // always treat branches as unmerged if there is no current branch (HEAD is detached)
                var hasUnmergedBranches = _currentBranch == null || selectedBranches.Any(branch => !mergedBranches.Contains(branch.Name));

                // we could show yes/no dialog and set forcing checkbox automatically, but more safe way is asking user to do it himself
                if (hasUnmergedBranches && !ForceDelete.Checked)
                {
                    MessageBox.Show(this, _deleteUnmergedBranchForcingSuggestion.Text, _deleteBranchCaption.Text);
                    return;
                }

                // ask for confirmation to delete unmerged branch that may cause loosing commits
                // (actually we could check if there are another branches pointing to that commit)
                if (hasUnmergedBranches
                    && MessageBox.Show(this, _deleteBranchQuestion.Text, _deleteBranchCaption.Text, MessageBoxButtons.YesNo) != DialogResult.Yes)
                    return;

                var cmd = new GitDeleteBranchCmd(selectedBranches, ForceDelete.Checked);
                UICommands.StartCommandLineProcessDialog(cmd, this);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
            Close();
        }
        private void OkClick(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show(this, _deleteBranchQuestion.Text, _deleteBranchCaption.Text, MessageBoxButtons.YesNo) ==
                    DialogResult.Yes)
                {

                    GitDeleteBranchCmd cmd = new GitDeleteBranchCmd {Force = ForceDelete.Checked};
                    foreach (GitHead head in Branches.GetSelectedBranches())
                        cmd.AddBranch(head.Name, head.IsRemote);

                    GitUICommands.Instance.StartCommandLineProcessDialog(cmd, this);

                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
            Close();
        }
 public void DeleteAllForce()
 {
     var branches = Nodes.DepthEnumerator<BranchNode>();
     var branchHeads = branches.Select(branch => GitRef.CreateBranchRef(UICommands.Module, null, branch.FullPath));
     var cmd = new GitDeleteBranchCmd(branchHeads, true);
     UICommands.StartCommandLineProcessDialog(cmd, null);
 }
 public void DeleteForce()
 {
     var branchHead = GitRef.CreateBranchRef(UICommands.Module, null, FullPath);
     var cmd = new GitDeleteBranchCmd(new GitRef[] { branchHead }, true);
     UICommands.StartCommandLineProcessDialog(cmd, null);
 }