private void DownloadAndInstallMod(WebMod mod) { string dlName = Path.Combine("downloaded", mod.DownloadUrl.Substring(mod.DownloadUrl.LastIndexOf("/") + 1)); // download mod if (!File.Exists(dlName)) { showProgressWindow(String.Format("{0} is being downloaded...", mod.Name)); if (!Directory.Exists("downloaded")) { Directory.CreateDirectory("downloaded"); } BackgroundWorker downloader = new BackgroundWorker(); downloader.DoWork += (obj, e) => WebManager.DownloadModFile(mod.DownloadUrl, dlName); downloader.RunWorkerAsync(); while (downloader.IsBusy) { Application.DoEvents(); } hideProgressWindow(); } else { GoToModList(); ProcessInstallMod(dlName); this.Invoke((MethodInvoker) delegate { RefreshInstalledMods(); listInstalledMods.SelectedIndex = listInstalledMods.Items.Count - 1; }); } this.Invoke((MethodInvoker) delegate { // update buttons buttonWebInstall.Text = (File.Exists(dlName)) ? "Install" : "Download"; buttonWebRemove.Visible = (File.Exists(dlName)) ? true : false; }); }
private void tabControl_SelectedIndexChanged(object sender, EventArgs e) { // Check if web mods have already been loaded if (webMods != null) { return; } // Download and populate mod list webMods = WebManager.GetOnlineMods(); if (webMods.Count > 0) { foreach (WebMod webMod in webMods) { listWebMods.Items.Add(webMod.Name); } listWebMods.SelectedIndex = 0; } else { tabControl.SelectedIndex = 0; tabControl.TabPages.RemoveAt(1); } }