Exemplo n.º 1
0
 private void listWebMods_SelectedIndexChanged(object sender, EventArgs e)
 {
     // Populate online mod details pane
     if (listWebMods.SelectedIndex >= 0)
     {
         WebMod selectedWebMod = webMods[listWebMods.SelectedIndex];
         labelWebName.Text       = selectedWebMod.Name;
         labelWebVersion.Text    = selectedWebMod.Version;
         labelWebAuthor.Text     = "by " + selectedWebMod.Author;
         labelWebAuthor.Left     = labelWebName.Left + labelWebName.Width + 4;
         labelWebWebsite.Text    = selectedWebMod.Website;
         textWebDescription.Text = selectedWebMod.Description;
         string modUrl = selectedWebMod.DownloadUrl;
         if (modUrl == "browse:")
         {
             buttonWebInstall.Text   = "Website";
             buttonWebRemove.Visible = false;
         }
         else
         {
             string dlName = Path.Combine("downloaded", selectedWebMod.DownloadUrl.Substring(selectedWebMod.DownloadUrl.LastIndexOf("/") + 1));
             buttonWebInstall.Text   = (File.Exists(dlName)) ? "Install" : "Download";
             buttonWebRemove.Visible = (File.Exists(dlName)) ? true : false;
         }
     }
 }
Exemplo n.º 2
0
        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;
            });
        }
Exemplo n.º 3
0
        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;
            });
        }