Esempio n. 1
0
        public void webclient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            string websiteName = GlobalInfo.WebsiteNamePop(_form1.modList[modIndex].DownloadAddress);
            string output      = "Downloading: " + _form1.modList[modIndex].ArchiveFileName + " from " + websiteName + " " + e.ProgressPercentage + "% complete...";

            _form1.ProgressLabelUpdate(output);
        }
Esempio n. 2
0
        public void ExtractMod(Form1 form1)
        {
            _form1 = form1;

            if (modIndex < _form1.modList.Count)
            {
                if (_form1.modList[modIndex].State_Extracted == false &&
                    _form1.modList[modIndex].ActionToTake == "Install" &&
                    _form1.modList[modIndex].ArchiveFileName != "")
                {
                    _form1.ProgressLabelUpdate("Extracting " + _form1.modList[modIndex].ModName + "...");

                    string fileName       = _form1.modList[modIndex].ArchiveFileName;
                    int    fileNameLength = fileName.Length;
                    string dirName        = fileName.Remove((fileNameLength - 4), 4);
                    string destDir        = @".\GPPInstaller\" + dirName;

                    DirectoryInfo destDirInfo = new DirectoryInfo(destDir);

                    string zipFile = @".\GPPInstaller\" + fileName;

                    if (!destDirInfo.Exists)
                    {
                        Directory.CreateDirectory(destDir);

                        if (File.Exists(zipFile))
                        {
                            // NOTE: It appears that when entering the worker for
                            // a second time (re-use the previous worker) the values
                            // of variables are re-used.
                            // NOTE: The solution to this problem was to pass new arguments to the
                            // background worker DoWork event. Used a Tuple since you can only pass
                            // one arg.

                            var args = new Tuple <string, string>(zipFile, destDir);

                            try
                            {
                                workerExtract.RunWorkerAsync(args);
                            }
                            catch (Exception)
                            {
                                throw new InvalidDataException();
                            }
                        }
                    }
                }
                else
                {
                    modIndex++;
                    ExtractMod(_form1);
                }
            }
            else
            {
                modIndex = 0;
                GlobalInfo.DeleteAllZips(@".\GPPInstaller");
                CopyMod(_form1);
            }
        }
Esempio n. 3
0
        public void webclient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                GlobalInfo.DeleteAllZips(@".\GPPInstaller");
                _form1.InstallCanceled();
                _form1.EndOfInstall();

                return;
            }

            _form1.ProgressBar1Step();
            modIndex++;
            DownloadMod(_form1);
        }
Esempio n. 4
0
        public void DownloadMod(Form1 form1)
        {
            _form1 = form1;

            if (modIndex < _form1.modList.Count)
            {
                if (_form1.modList[modIndex].State_Extracted == false &&
                    _form1.modList[modIndex].ActionToTake == "Install" &&
                    _form1.modList[modIndex].DownloadAddress != "")
                {
                    string downloadAddress = _form1.modList[modIndex].DownloadAddress;
                    string fileName        = _form1.modList[modIndex].ArchiveFileName;
                    string downloadDest    = @".\GPPInstaller\" + fileName;

                    Uri uri = new Uri(downloadAddress);

                    if (!GlobalInfo.IsConnectedToInternet())
                    {
                        webclient.CancelAsync();
                        _form1.InstallCanceled();
                        throw new WebException();
                    }

                    webclient.DownloadFileAsync(uri, downloadDest);
                }
                else
                {
                    modIndex++;
                    DownloadMod(_form1);
                }
            }
            else
            {
                modIndex = 0;
                ExtractMod(_form1);
            }
        }