Skip to content

Commit

Permalink
Added progress bar and upload selected button
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed Nov 4, 2023
1 parent 59fe9ac commit 4c28765
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 9 deletions.
44 changes: 42 additions & 2 deletions MiniserverForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 46 additions & 6 deletions MiniserverForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LoxStatEdit
Expand Down Expand Up @@ -329,7 +330,12 @@ private void DataGridView_CellContentClick(object sender, DataGridViewCellEventA
switch(e.ColumnIndex)
{
case 4: //Download
progressBar.Maximum = 1;
progressBar.Value = 0;
progressLabel.Text = "Starting download...";
Download(fileItem);
progressBar.Value = 1;
progressLabel.Text = "Download complete!";
RefreshLocal();
RefreshGridView();
break;
Expand All @@ -338,27 +344,61 @@ private void DataGridView_CellContentClick(object sender, DataGridViewCellEventA
form.ShowDialog(this);
break;
case 6: //Upload
progressBar.Maximum = 1;
progressBar.Value = 0;
progressLabel.Text = "Starting upload...";
Upload(fileItem);
progressBar.Value = 1;
progressLabel.Text = "Upload complete!";
RefreshMs();
RefreshGridView();
break;
}
}

private void DownloadButton_Click(object sender, EventArgs e)
private async void DownloadButton_Click(object sender, EventArgs e)
{
progressBar.Maximum = _dataGridView.SelectedRows.Count;
progressBar.Value = 0;
progressLabel.Text = "Starting download...";

foreach(DataGridViewRow row in _dataGridView.SelectedRows)
Download(_fileItems[row.Index]);
{
int rowIndex = row.Index; // Capture the index for the closure
await Task.Run(() => Download(_fileItems[rowIndex]));
progressBar.Value++;
progressLabel.Text = $"Downloaded {progressBar.Value} of {progressBar.Maximum}";
}
progressLabel.Text = "Download complete!";

RefreshLocal();
RefreshGridView();

// foreach(DataGridViewRow row in _dataGridView.SelectedRows)
// Download(_fileItems[row.Index]);
// RefreshLocal();
// RefreshGridView();
}

private void UploadButton_Click(object sender, EventArgs e)
private async void UploadButton_Click(object sender, EventArgs e)
{
progressBar.Maximum = _dataGridView.SelectedRows.Count;
progressBar.Value = 0;
progressLabel.Text = "Starting upload...";

foreach(DataGridViewRow row in _dataGridView.SelectedRows)
Upload(_fileItems[row.Index]);
RefreshMs();
RefreshGridView();
{
int rowIndex = row.Index; // Capture the index for the closure
await Task.Run(() => Upload(_fileItems[rowIndex]));
progressBar.Value++;
progressLabel.Text = $"Uploaded {progressBar.Value} of {progressBar.Maximum}";
}
progressLabel.Text = "Upload complete!";

// foreach(DataGridViewRow row in _dataGridView.SelectedRows)
// Upload(_fileItems[row.Index]);
// RefreshMs();
// RefreshGridView();
}

// Launch project link
Expand Down
5 changes: 4 additions & 1 deletion MiniserverForm.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -159,6 +159,9 @@
<metadata name="_uploadCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="uploadButton.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down

0 comments on commit 4c28765

Please sign in to comment.