Exemplo n.º 1
0
        private void btnDownloadVersion_Click(object sender, EventArgs e)
        {
            if (lbOnlineVersions.SelectedIndex == -1)
            {
                return;
            }

            string version = lbOnlineVersions.SelectedItem.ToString();

            if (Directory.Exists((launcherDir + "\\VERSIONS\\" + version)))
            {
                if (MessageBox.Show($"The version {version} is already installed.\nThis will DELETE version {version} and redownload it.\n\nWould you like to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Directory.Delete(launcherDir + "\\VERSIONS\\" + version, true);
                }
                else
                {
                    return;
                }
            }

            if (File.Exists(launcherDir + "\\PACKAGES\\" + version + ".zip"))
            {
                File.Delete(launcherDir + "\\PACKAGES\\" + version + ".zip");
            }

            dForm = new DownloadForm();

            dForm.TopLevel = false;
            dForm.Location = new Point(0, 0);
            Controls.Add(dForm);

            dForm.Show();
            dForm.Focus();
            dForm.BringToFront();

            WebClient webClient = new WebClient();

            webClient.DownloadProgressChanged += (ov, ev) =>
            {
                dForm.progressBar.Value = ev.ProgressPercentage;
            };

            webClient.DownloadFileCompleted += (ov, ev) =>
            {
                InvokeUI(() => { DownloadComplete(); });
            };


            webClient.DownloadFileAsync(new Uri($"{webRessourceDomain}/rtc/releases/" + version + ".zip"), launcherDir + "\\PACKAGES\\" + version + ".zip");
        }
Exemplo n.º 2
0
        public void DownloadComplete()
        {
            string version = lbOnlineVersions.SelectedItem.ToString();

            Directory.CreateDirectory(launcherDir + "\\VERSIONS\\" + version);
            System.IO.Compression.ZipFile.ExtractToDirectory(launcherDir + "\\PACKAGES\\" + version + ".zip", launcherDir + "\\VERSIONS\\" + version);

            lbVersions.SelectedIndex = -1;

            RefreshInstalledVersions();

            lbOnlineVersions.SelectedIndex = -1;
            btnDownloadVersion.Visible     = false;

            dForm.Close();
            dForm = null;
        }