diff options
| author | Michael <[email protected]> | 2017-02-02 19:51:57 -0500 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-02-02 19:51:57 -0500 |
| commit | 487deee243c7b1994f049c3d190e1e0971973bca (patch) | |
| tree | 0d46457bbe426ede9787faf9216d68d9dafc581e /ShiftOS.WinForms/Applications/Downloader.cs | |
| parent | bf100ab099e7335711ea739cb10a4a9df4b89dc5 (diff) | |
| download | shiftos_thereturn-487deee243c7b1994f049c3d190e1e0971973bca.tar.gz shiftos_thereturn-487deee243c7b1994f049c3d190e1e0971973bca.tar.bz2 shiftos_thereturn-487deee243c7b1994f049c3d190e1e0971973bca.zip | |
Fix download UI
Diffstat (limited to 'ShiftOS.WinForms/Applications/Downloader.cs')
| -rw-r--r-- | ShiftOS.WinForms/Applications/Downloader.cs | 48 |
1 files changed, 11 insertions, 37 deletions
diff --git a/ShiftOS.WinForms/Applications/Downloader.cs b/ShiftOS.WinForms/Applications/Downloader.cs index 021af3e..0c3076d 100644 --- a/ShiftOS.WinForms/Applications/Downloader.cs +++ b/ShiftOS.WinForms/Applications/Downloader.cs @@ -50,7 +50,6 @@ namespace ShiftOS.WinForms.Applications SetupUI(); })); }; - DownloadManager.ProgressUpdate += pupdate; DownloadManager.DownloadStarted += started; DownloadManager.DownloadCompleted += completed; } @@ -62,7 +61,6 @@ namespace ShiftOS.WinForms.Applications public bool OnUnload() { - DownloadManager.ProgressUpdate -= pupdate; DownloadManager.DownloadStarted -= started; DownloadManager.DownloadCompleted -= completed; return true; @@ -78,46 +76,22 @@ namespace ShiftOS.WinForms.Applications int heightMultiplier = 0; - foreach(var download in DownloadManager.Downloads) + for(int i = 0; i < DownloadManager.Downloads.Length; i++) { - var pnl = new Panel(); - pnl.Width = fllist.Width; - pnl.Height = 50; - var picpreview = new PictureBox(); - picpreview.Size = new Size(42, 42); - picpreview.Image = FileSkimmerBackend.GetImage(download.Destination); - picpreview.Location = new Point(4, 4); - if (heightMultiplier < 5) + var dctrl = new DownloadControl(i); + if(heightMultiplier < 10) + { heightMultiplier++; - pnl.Controls.Add(picpreview); - picpreview.Show(); - var prg = new ShiftedProgressBar(); - prg.Maximum = 100; - prg.Value = download.Progress; - prg.Width = pnl.Width - 8; - prg.Left = 4; - prg.Top = picpreview.Height + 8; - prg.Height = 20; - var lbtitle = new Label(); - lbtitle.Tag = "header1"; - lbtitle.Text = download.ShiftnetUrl; - lbtitle.Top = 4; - lbtitle.Left = 8 + picpreview.Height; - pnl.Controls.Add(lbtitle); - lbtitle.Show(); - lbtitle.AutoSize = true; - pnl.Controls.Add(prg); - prg.Show(); - - fllist.Controls.Add(pnl); - pnl.Show(); - ControlManager.SetupControls(pnl); + } + + fllist.Controls.Add(dctrl); + dctrl.Show(); } if (heightMultiplier == 0) heightMultiplier = 1; - this.Parent.Height = 50 * heightMultiplier; + this.ParentForm.Height = 150 * heightMultiplier; } } @@ -149,8 +123,8 @@ namespace ShiftOS.WinForms.Applications for (int i = 0; i < down.Bytes.Length; i += byteWrite) { Thread.Sleep(1000); - _downloads[_downloads.IndexOf(down)].Progress = i / down.Bytes.Length; - ProgressUpdate?.Invoke(_downloads.IndexOf(down), i / down.Bytes.Length); + _downloads[_downloads.IndexOf(down)].Progress = (int)((float)(i / down.Bytes.Length) * 100); + ProgressUpdate?.Invoke(_downloads.IndexOf(down), (int)((float)(i / down.Bytes.Length) * 100)); } ShiftOS.Objects.ShiftFS.Utils.WriteAllBytes(down.Destination, down.Bytes); _downloads.Remove(down); |
