Example #1
0
        private void _createBtn_Click(object sender, EventArgs e)
        {
            if (_currentHostedRemote == null)
            {
                return;
            }

            var title = _titleTB.Text.Trim();
            var body  = _bodyTB.Text.Trim();

            if (title.Length == 0)
            {
                MessageBox.Show(this, _strYouMustSpecifyATitle.Text, _strError.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                var hostedRepo = _currentHostedRemote.GetHostedRepository();

                hostedRepo.CreatePullRequest(_yourBranchesCB.Text, _remoteBranchesCB.Text, title, body);
                MessageBox.Show(this, _strDone.Text, _strPullRequest.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, _strFailedToCreatePullRequest.Text + Environment.NewLine +
                                ex.Message, _strError.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void PopulateBranchesComboAndEnableCreateButton(IHostedRemote remote, ComboBox comboBox)
        {
            ThreadHelper.JoinableTaskFactory.RunAsync(
                async() =>
            {
                await TaskScheduler.Default;

                IHostedRepository hostedRepository = remote.GetHostedRepository();
                var branches = hostedRepository.GetBranches();

                await this.SwitchToMainThreadAsync();

                comboBox.Items.Clear();

                var selectItem    = 0;
                var defaultBranch = hostedRepository.GetDefaultBranch();
                for (var i = 0; i < branches.Count; i++)
                {
                    if (branches[i].Name == defaultBranch)
                    {
                        selectItem = i;
                    }

                    comboBox.Items.Add(branches[i].Name);
                }

                if (branches.Count > 0)
                {
                    comboBox.SelectedIndex = selectItem;
                }

                _createBtn.Enabled = true;
            })
            .FileAndForget();
        }
Example #3
0
        private void _pullReqTargetsCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            _currentHostedRemote = _pullReqTargetsCB.SelectedItem as IHostedRemote;

            _remoteBranchesCB.Items.Clear();
            _remoteBranchesCB.Text = _strLoading.Text;

            AsyncLoader.DoAsync(
                () => _currentHostedRemote.GetHostedRepository().Branches,
                branches =>
            {
                branches.Sort((a, b) => string.Compare(a.Name, b.Name, true));
                int selectItem = 0;
                _remoteBranchesCB.Items.Clear();
                for (int i = 0; i < branches.Count; i++)
                {
                    if (branches[i].Name == _currentBranch)
                    {
                        selectItem = i;
                    }

                    _remoteBranchesCB.Items.Add(branches[i].Name);
                }

                _createBtn.Enabled = true;
                if (branches.Count > 0)
                {
                    _remoteBranchesCB.SelectedIndex = selectItem;
                }
            },
                ex => { ex.Handled = false; });
        }
        private void _pullReqTargetsCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            _currentHostedRemote = _pullReqTargetsCB.SelectedItem as IHostedRemote;

            _remoteBranchesCB.Items.Clear();
            _remoteBranchesCB.Text = _strLoading.Text;

            AsyncHelpers.DoAsync(
                () => _currentHostedRemote.GetHostedRepository().Branches,
                branches =>
            {
                foreach (var branch in branches)
                {
                    _remoteBranchesCB.Items.Add(branch.Name);
                }
                _createBtn.Enabled = true;
                if (branches.Count > 0)
                {
                    _remoteBranchesCB.SelectedIndex = 0;
                }
            },
                ex => { throw ex; });
        }
        private void _pullReqTargetsCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            _currentHostedRemote = _pullReqTargetsCB.SelectedItem as IHostedRemote;

            _remoteBranchesCB.Items.Clear();
            _remoteBranchesCB.Text = _strLoading.Text;

            AsyncLoader.DoAsync(
                () => _currentHostedRemote.GetHostedRepository().Branches,
                branches =>
                {
                    branches.Sort((a, b) => String.Compare(a.Name, b.Name, true));
                    int selectItem = 0;
                    _remoteBranchesCB.Items.Clear();
                    for (int i = 0; i < branches.Count; i++)
                    {
                        if (branches[i].Name == _currentBranch)
                            selectItem = i;
                        _remoteBranchesCB.Items.Add(branches[i].Name);
                    }
                    _createBtn.Enabled = true;
                    if (branches.Count > 0)
                        _remoteBranchesCB.SelectedIndex = selectItem;
                },
                ex => { ex.Handled = false; });
        }
        private void _pullReqTargetsCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            _currentHostedRemote = _pullReqTargetsCB.SelectedItem as IHostedRemote;

            _remoteBranchesCB.Items.Clear();
            _remoteBranchesCB.Text = _strLoading.Text;

            AsyncHelpers.DoAsync(
                () => _currentHostedRemote.GetHostedRepository().Branches,
                (branches) =>
                {
                    foreach (var branch in branches)
                        _remoteBranchesCB.Items.Add(branch.Name);
                    _createBtn.Enabled = true;
                    if (branches.Count > 0)
                        _remoteBranchesCB.SelectedIndex = 0;
                },
                (ex) => { throw ex; });
        }