Beispiel #1
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            GitHub = new GitHub(textBoxRepository.Text){
                Branch = (string)listBranches.SelectedItem
            };

            DialogResult = DialogResult.OK;
            Close();
        }
Beispiel #2
0
        private void timer_Tick(object sender, EventArgs e)
        {
            timer.Stop();

            if (GitHub.IsRepositoryValid(textBoxRepository.Text)){
                listBranches.Items.Add(new ItemBranchTechnical("LoadGitHubBranchLoading"));

                GitHub github = new GitHub(textBoxRepository.Text);

                GitHub.DownloadStatus status = github.RetrieveBranchList((branches, ex) => this.InvokeSafe(() => {
                    github.Dispose();
                    listBranches.Items.Clear();

                    if (ex != null){
                        btnDownload.Enabled = false;
                        listBranches.Items.Add(new ItemBranchTechnical("LoadGitHubBranchFailure"));

                        #if MONO
                        Exception testEx = ex.InnerException;

                        while(testEx != null){
                            if (testEx.GetType().FullName == "Mono.Security.Protocol.Tls.TlsException"){
                                if (MessageBox.Show(Lang.Get["LoadGitHubTrustError"], Lang.Get["LoadGitHubError"], MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes){
                                    using(System.Diagnostics.Process process = System.Diagnostics.Process.Start("mozroots", "--import --ask-remove --quiet")){
                                        if (process != null){
                                            process.WaitForExit();
                                        }
                                    }

                                    timer_Tick(timer, new EventArgs());
                                }

                                break;
                            }

                            testEx = testEx.InnerException;
                        }
                        #endif

                        return;
                    }

                    if (branches == null){
                        btnDownload.Enabled = false;
                        return;
                    }

                    foreach(string branch in branches){
                        listBranches.Items.Add(branch);

                        if (branch == listBranches.Text){
                            listBranches.SelectedIndex = listBranches.Items.Count-1;
                        }
                    }

                    btnDownload.Enabled = true;
                }));

                switch(status){
                    case GitHub.DownloadStatus.NoInternet:
                        MessageBox.Show(Lang.Get["LoadGitHubNoInternet"], Lang.Get["LoadGitHubError"], MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;

                    case GitHub.DownloadStatus.NoConnection:
                        MessageBox.Show(Lang.Get["LoadGitHubNoEstablishedConnection"], Lang.Get["LoadGitHubError"], MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                }
            }
        }