mirror of
https://github.com/chylex/Code-Statistics.git
synced 2025-07-25 19:59:07 +02:00
Improve ProjectLoadForm progress bar handling and have marquee for unknown GitHub DL size
This commit is contained in:
parent
9b9a8ac8f1
commit
5c88e51a79
CodeStatistics
@ -9,7 +9,6 @@ using System.Globalization;
|
||||
using CodeStatistics.Data;
|
||||
using CodeStatistics.Input.Methods;
|
||||
using CodeStatistics.Properties;
|
||||
using System.Resources;
|
||||
|
||||
namespace CodeStatistics.Forms{
|
||||
public partial class ProjectLoadForm : Form{
|
||||
@ -53,25 +52,12 @@ namespace CodeStatistics.Forms{
|
||||
search.Finish += data => this.InvokeOnUIThread(() => {
|
||||
labelLoadInfo.Text = Lang.Get["LoadProjectProcess"];
|
||||
labelLoadData.Text = "";
|
||||
progressBarLoad.Value = 0;
|
||||
progressBarLoad.Style = ProgressBarStyle.Continuous;
|
||||
UpdateProgress(ProgressBarStyle.Continuous,0);
|
||||
|
||||
project = new Project(data);
|
||||
|
||||
project.Progress += (percentage, processedEntries, totalEntries) => this.InvokeOnUIThread(() => {
|
||||
int percValue = percentage*10;
|
||||
|
||||
// instant progress bar update hack
|
||||
if (percValue == progressBarLoad.Maximum){
|
||||
progressBarLoad.Value = percValue;
|
||||
progressBarLoad.Value = percValue-1;
|
||||
progressBarLoad.Value = percValue;
|
||||
}
|
||||
else{
|
||||
progressBarLoad.Value = percValue+1;
|
||||
progressBarLoad.Value = percValue;
|
||||
}
|
||||
|
||||
UpdateProgress(ProgressBarStyle.Continuous,percentage);
|
||||
labelLoadData.Text = processedEntries+" / "+totalEntries;
|
||||
});
|
||||
|
||||
@ -96,6 +82,23 @@ namespace CodeStatistics.Forms{
|
||||
search.StartAsync();
|
||||
}
|
||||
|
||||
private void UpdateProgress(ProgressBarStyle style, int percentage){
|
||||
progressBarLoad.Style = style;
|
||||
|
||||
int percValue = percentage*10;
|
||||
|
||||
// instant progress bar update hack
|
||||
if (percValue == progressBarLoad.Maximum){
|
||||
progressBarLoad.Value = percValue;
|
||||
progressBarLoad.Value = percValue-1;
|
||||
progressBarLoad.Value = percValue;
|
||||
}
|
||||
else{
|
||||
progressBarLoad.Value = percValue+1;
|
||||
progressBarLoad.Value = percValue;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e){
|
||||
if (variables == null){
|
||||
if (project != null)project.Cancel(() => this.InvokeOnUIThread(OnCancel));
|
||||
@ -156,14 +159,8 @@ namespace CodeStatistics.Forms{
|
||||
|
||||
public void UpdateProgress(int progress){
|
||||
form.InvokeOnUIThread(() => {
|
||||
if (progress == -1){
|
||||
form.progressBarLoad.Style = ProgressBarStyle.Marquee;
|
||||
form.progressBarLoad.Value = 1000;
|
||||
}
|
||||
else{
|
||||
form.progressBarLoad.Style = ProgressBarStyle.Continuous;
|
||||
form.progressBarLoad.Value = progress*10;
|
||||
}
|
||||
if (progress == -1)form.UpdateProgress(ProgressBarStyle.Marquee,100);
|
||||
else form.UpdateProgress(ProgressBarStyle.Continuous,progress);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ namespace CodeStatistics.Input.Methods{
|
||||
string tmpFile = tmpDir == null ? "github.zip" : Path.Combine(tmpDir,"github.zip");
|
||||
|
||||
DownloadProgressChanged += (sender, args) => {
|
||||
callbacks.UpdateProgress(args.ProgressPercentage);
|
||||
callbacks.UpdateProgress(args.TotalBytesToReceive == -1 ? -1 : args.ProgressPercentage);
|
||||
callbacks.UpdateDataLabel(args.TotalBytesToReceive == -1 ? (args.BytesReceived/1024)+" kB" : (args.BytesReceived/1024)+" / "+(args.TotalBytesToReceive/1024)+" kB");
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user