From 487deee243c7b1994f049c3d190e1e0971973bca Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 2 Feb 2017 19:51:57 -0500 Subject: Fix download UI --- ShiftOS.WinForms/DownloadControl.cs | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 ShiftOS.WinForms/DownloadControl.cs (limited to 'ShiftOS.WinForms/DownloadControl.cs') diff --git a/ShiftOS.WinForms/DownloadControl.cs b/ShiftOS.WinForms/DownloadControl.cs new file mode 100644 index 0000000..b905167 --- /dev/null +++ b/ShiftOS.WinForms/DownloadControl.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.WinForms.Applications; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms +{ + public partial class DownloadControl : UserControl + { + public DownloadControl(int index) + { + InitializeComponent(); + var d = DownloadManager.Downloads[index]; + lbshiftneturl.Text = d.ShiftnetUrl; + pcicon.Image = FileSkimmerBackend.GetImage(d.Destination); + int bytesTransferred = 0; + DownloadManager.ProgressUpdate += (i, p) => + { + try + { + this.Invoke(new Action(() => + { + if (i == index) + { + bytesTransferred += 256; + pgprogress.Value = bytesTransferred; + lbshiftneturl.Text = $@"{d.ShiftnetUrl} +{bytesTransferred} B out of {d.Bytes.Length} B transferred at 256 B per second. +To {d.Destination}"; + pgprogress.Maximum = d.Bytes.Length; + } + })); + } + catch + { + + } + }; + } + } +} -- cgit v1.2.3