private async void SettingsForm_FormClosing(object sender, FormClosingEventArgs e) { await Task.Delay(100); SaveSettings(); EmbeddedPython.Init(); if (Config.GetInt("pythonRuntime") == 1 && !File.Exists(EmbeddedPython.GetEmbedPyPath())) { MsgBox msg = Program.ShowMessage("You enabled the embedded Python runtime but haven't downloaded and installed it.\n" + "You can download it in the Dependency Checker window."); while (DialogQueue.IsOpen(msg)) { await Task.Delay(50); } new DependencyCheckerForm(true).ShowDialog(); } }
public static async Task Install() { Program.mainForm.Enabled = false; DialogForm dialog = new DialogForm("Installing resources...\nThis only needs to be done once."); await Task.Delay(20); if (IOUtils.GetDirSize(path) > 0) { Logger.Log("[Installer] {path} is not 0 bytes - removing everything there to ensure a clean install."); dialog.ChangeText("Uninstalling older files..."); await Task.Delay(20); Uninstall(false); } Directory.CreateDirectory(path); path7za = Path.Combine(path, "7za.exe"); File.WriteAllBytes(path7za, Resources.x64_7za); try { await DownloadAndInstall(exeFilesVersion, "esrgan.7z"); await DownloadAndInstall(exeFilesVersion, "esrgan-ncnn.7z"); await DownloadAndInstall(exeFilesVersion, "av.7z"); await DownloadAndInstall(exeFilesVersion, "shipped-files-version.txt", false); } catch (Exception e) { MsgBox msg = Logger.ErrorMessage("Web Installer failed to run!\n", e); while (DialogQueue.IsOpen(msg)) { await Task.Delay(50); } Environment.Exit(1); return; } dialog.Close(); Program.mainForm.Enabled = true; Program.mainForm.WindowState = System.Windows.Forms.FormWindowState.Maximized; Program.mainForm.BringToFront(); }
static async Task Install() { Print("Done downloading!"); Print("Extracting..."); if (Directory.Exists(extractPath)) { IOUtils.ClearDir(extractPath); } List <Task> tasks = new List <Task>(); isExtracting = true; tasks.Add(CheckDownloadedFileSizeAsync()); tasks.Add(ExtractAsync()); await Task.WhenAll(tasks); Print("Done extracting files."); MsgBox msg = Program.ShowMessage("The Python files will now be compressed to reduce the amount of storage space needed " + "from 2.4 GB to 1.6 GB.\nThis can take a few minutes.", "Message"); while (DialogQueue.IsOpen(msg)) { await Task.Delay(50); } Print("Compressing files..."); RunCompact(); Print("Done!"); Config.Set("pythonRuntime", "1"); await Init(); MsgBox msg2 = Program.ShowMessage("Installed embedded Python runtime and enabled it!\nIf you want to disable it, you can do so in the settings.", "Message"); while (DialogQueue.IsOpen(msg2)) { await Task.Delay(50); } runBtn.Enabled = true; }