From 91c6b3bf1c709cc392d52391407a70feabc9214b Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 25 Apr 2017 12:24:44 -0400 Subject: [PATCH] fix Appscape install bugs --- ShiftOS.WinForms/Applications/Installer.cs | 11 +++++++--- .../ShiftnetSites/AppscapeMain.cs | 20 ++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/ShiftOS.WinForms/Applications/Installer.cs b/ShiftOS.WinForms/Applications/Installer.cs index 2193f8a..4d8b712 100644 --- a/ShiftOS.WinForms/Applications/Installer.cs +++ b/ShiftOS.WinForms/Applications/Installer.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; +using System.Threading; namespace ShiftOS.WinForms.Applications { @@ -29,21 +30,21 @@ namespace ShiftOS.WinForms.Applications pnlselectfile.Hide(); install.ProgressReported += (p) => { - this.Invoke(new Action(() => + Desktop.InvokeOnWorkerThread(new Action(() => { pginstall.Value = p; })); }; install.StatusReported += (s) => { - this.Invoke(new Action(() => + Desktop.InvokeOnWorkerThread(new Action(() => { lbprogress.Text = s; })); }; install.InstallCompleted += () => { - this.Invoke(new Action(() => + Desktop.InvokeOnWorkerThread(new Action(() => { lbtitle.Text = "Select file"; pnlselectfile.Show(); @@ -51,6 +52,10 @@ namespace ShiftOS.WinForms.Applications isInstalling = false; InstallCompleted?.Invoke(); }; + while (!this.Visible) + { + + } isInstalling = true; install.Install(); } diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs index 84783e5..691f622 100644 --- a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs @@ -336,22 +336,28 @@ namespace ShiftOS.WinForms.ShiftnetSites int i = 0; while (i <= Size) { - SetProgress((i / Size) * 100); - i++; - Thread.Sleep(100); + double progress = ((i / Size) * 100); + + SetProgress((int)progress); + + i += Applications.DownloadManager.GetDownloadSpeed(); + Thread.Sleep(1000); } SetProgress(0); SetStatus("Installing..."); i = 0; while (i <= Size) { - SetProgress((i / Size) * 100); - i++; - Thread.Sleep(50); + double progress = ((i / Size) * 100); + + SetProgress((int)progress); + + i+=1024; + Thread.Sleep(1000); } - Shiftorium.Buy(ShiftoriumId, 0); Desktop.InvokeOnWorkerThread(() => { + Shiftorium.Buy(ShiftoriumId, 0); Infobox.Show("Install complete!", "The installation of " + Name + " has completed."); SaveSystem.SaveGame(); });