1
0
mirror of https://github.com/chylex/Code-Statistics.git synced 2025-03-15 00:15:42 +01:00

Add GitHub repo existence check and move remaining GitHub texts to Lang

This commit is contained in:
chylex 2016-03-03 21:35:09 +01:00
parent da016f8807
commit 7b7bcc2a5c
4 changed files with 23 additions and 10 deletions
CodeStatistics

View File

@ -43,6 +43,12 @@ namespace CodeStatistics.Data{
{ "LoadGitHubDownload", "Download" },
{ "LoadGitHubCancel", "Cancel" },
{ "LoadGitHubDownloadingRepo", "Downloading repository..." },
{ "LoadGitHubExtractingRepo", "Extracting repository..." },
{ "LoadGitHubNoConnection", "No internet connection." },
{ "LoadGitHubNoInternet", "Could not establish connection with GitHub." },
{ "LoadGitHubDownloadError", "Could not download the repository." },
{ "DebugProjectReprocess", "Reprocess" },
{ "DebugProjectLoadOriginal", "Original" },
{ "DebugProjectDebug", "Debug" }

View File

@ -94,6 +94,7 @@
// btnDownload
//
this.btnDownload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnDownload.Enabled = false;
this.btnDownload.Location = new System.Drawing.Point(218, 164);
this.btnDownload.Name = "btnDownload";
this.btnDownload.Size = new System.Drawing.Size(75, 23);

View File

@ -35,9 +35,7 @@ namespace CodeStatistics.Forms{
private void OnLoad(object sender, EventArgs e){
ActiveControl = textBoxRepository;
listBranches.Items.Add(GitHub.DefaultBranch);
listBranches.SelectedIndex = 0; // calls the change event to initialize previousSelectedBranch
listBranches.Text = GitHub.DefaultBranch;
}
private void btnDownload_Click(object sender, EventArgs e){
@ -72,13 +70,13 @@ namespace CodeStatistics.Forms{
github.RetrieveBranchList(branches => this.InvokeOnUIThread(() => {
github.Dispose();
listBranches.Items.Clear();
if (branches == null){
listBranches.Items.Remove(branchLoading);
btnDownload.Enabled = false;
return;
}
listBranches.Items.Clear();
foreach(string branch in branches){
listBranches.Items.Add(branch);
@ -86,6 +84,8 @@ namespace CodeStatistics.Forms{
listBranches.SelectedIndex = listBranches.Items.Count-1;
}
}
btnDownload.Enabled = true;
}));
}
}

View File

@ -9,6 +9,7 @@ using CodeStatistics.Forms;
using System.Threading;
using System.IO;
using System.Text.RegularExpressions;
using CodeStatistics.Data;
using CodeStatistics.Input.Helpers;
namespace CodeStatistics.Input.Methods{
@ -130,7 +131,12 @@ namespace CodeStatistics.Input.Methods{
};
DownloadFinished += (sender, args) => {
callbacks.UpdateInfoLabel("Extracting repository...");
if (args.Error != null){
callbacks.UpdateInfoLabel(Lang.Get["LoadGitHubDownloadError"]);
return;
}
callbacks.UpdateInfoLabel(Lang.Get["LoadGitHubExtractingRepo"]);
ZipArchive archive = new ZipArchive(tmpFile);
@ -142,15 +148,15 @@ namespace CodeStatistics.Input.Methods{
switch(DownloadRepositoryZip(tmpFile)){
case DownloadStatus.Started:
callbacks.UpdateInfoLabel("Downloading repository...");
callbacks.UpdateInfoLabel(Lang.Get["LoadGitHubDownloadingRepo"]);
break;
case DownloadStatus.NoInternet:
callbacks.UpdateInfoLabel("No internet connection.");
callbacks.UpdateInfoLabel(Lang.Get["LoadGitHubNoInternet"]);
break;
case DownloadStatus.NoConnection:
callbacks.UpdateInfoLabel("Could not establish connection with GitHub.");
callbacks.UpdateInfoLabel(Lang.Get["LoadGitHubNoEstablishedConnection"]);
break;
}
}