Пример #1
0
        public async void BrowserDownload(GameBananaRecord record, GameFilter game)
        {
            var gameName = "";

            switch (game)
            {
            case GameFilter.P3:
                gameName = "Persona 3 FES";
                break;

            case GameFilter.P4G:
                gameName = "Persona 4 Golden";
                break;

            case GameFilter.P5:
                gameName = "Persona 5";
                break;

            case GameFilter.P5S:
                gameName = "Persona 5 Strikers";
                break;
            }
            DownloadWindow downloadWindow = new DownloadWindow(record);

            downloadWindow.ShowDialog();
            if (downloadWindow.YesNo)
            {
                string downloadUrl = null;
                string fileName    = null;
                if (record.Files.Count == 1)
                {
                    downloadUrl = record.Files[0].DownloadUrl;
                    fileName    = record.Files[0].FileName;
                }
                else if (record.Files.Count > 1)
                {
                    UpdateFileBox fileBox = new UpdateFileBox(record.Files, record.Title);
                    fileBox.Activate();
                    fileBox.ShowDialog();
                    downloadUrl = fileBox.chosenFileUrl;
                    fileName    = fileBox.chosenFileName;
                }
                if (downloadUrl != null && fileName != null)
                {
                    await DownloadFile(downloadUrl, fileName, new Progress <DownloadProgress>(ReportUpdateProgress),
                                       CancellationTokenSource.CreateLinkedTokenSource(cancellationToken.Token));

                    if (!cancelled)
                    {
                        await ExtractFile($@"{assemblyLocation}\Downloads\{fileName}", gameName);

                        if (File.Exists($@"{assemblyLocation}\refresh.aem"))
                        {
                            FileIOWrapper.Delete($@"{assemblyLocation}\refresh.aem");
                        }
                        FileIOWrapper.WriteAllText($@"{assemblyLocation}\refresh.aem", gameName);
                    }
                }
            }
        }
Пример #2
0
        public async void Download(string line, bool running)
        {
            if (ParseProtocol(line))
            {
                if (await GetData())
                {
                    DownloadWindow downloadWindow = new DownloadWindow(response);
                    downloadWindow.ShowDialog();
                    downloadWindow.Activate();
                    if (downloadWindow.YesNo)
                    {
                        await DownloadFile(URL_TO_ARCHIVE, fileName, new Progress <DownloadProgress>(ReportUpdateProgress),
                                           CancellationTokenSource.CreateLinkedTokenSource(cancellationToken.Token));
                        await ExtractFile($@"{assemblyLocation}\Downloads\{fileName}", response.Game.Replace(" (PC)", ""));

                        if (File.Exists($@"{assemblyLocation}\refresh.aem"))
                        {
                            FileIOWrapper.Delete($@"{assemblyLocation}\refresh.aem");
                        }
                        FileIOWrapper.WriteAllText($@"{assemblyLocation}\refresh.aem", response.Game.Replace(" (PC)", ""));
                    }
                }
            }
            if (running)
            {
                Environment.Exit(0);
            }
        }
Пример #3
0
        public void ShowDownloadDialog(DownloadParameters downloadParams, Action <bool, DownloadParameters> dialogCompleteCallback)
        {
            if (downloadParams == null)
            {
                throw new ArgumentNullException(nameof(downloadParams));
            }

            if (dialogCompleteCallback == null)
            {
                throw new ArgumentNullException(nameof(dialogCompleteCallback));
            }

            DownloadWindowVM vm = this.kernel.Get <DownloadWindowVM>();

            vm.DownloadParams = downloadParams;

            DownloadWindow window = this.kernel.Get <DownloadWindow>();

            window.DataContext = vm;

            bool?result = window.ShowDialog();

            DownloadParameters resultObject = vm.ResultObject;

            dialogCompleteCallback(result != true, resultObject);
        }
Пример #4
0
        public void ShowDownloadForgeList(MinecraftVersion version)
        {
            Settings.Save();
            var downloader     = new ForgeDownloader(Settings.UseBMCL, version);
            var downloadDialog = new DownloadWindow(downloader);

            downloadDialog.ShowDialog(MainForm);
            downloadDialog.Dispose();
        }
Пример #5
0
        public void ShowDownloadMinecraftList()
        {
            Settings.Save();
            var downloader     = new MinecraftDownloader(Settings.UseBMCL, Settings.MinecraftFolderName);
            var downloadDialog = new DownloadWindow(downloader);

            downloadDialog.ShowDialog(MainForm);
            downloadDialog.Dispose();
        }
        /// <summary>
        /// Ask a directory to download all selected reports
        /// </summary>
        private async Task DownloadExecute(object parameter)
        {
            int reportsCount = this.SelectedReports.Count();

            if (reportsCount > 0)
            {
                DownloadWindow frmDownload = new DownloadWindow();
                frmDownload.Owner = parameter as Window;
                frmDownload.WindowStartupLocation = WindowStartupLocation.CenterOwner;

                if (frmDownload.ShowDialog() == true)
                {
                    try
                    {
                        // Save all reports
                        int n = 0;
                        foreach (Data.Report report in this.SelectedReports)
                        {
                            // Progress
                            n++;
                            this.ProgressPercent = Convert.ToDouble(n) / Convert.ToDouble(reportsCount) * 100d;
                            DoEvents();


                            // Download
                            string filename = await report.DownloadToFolder(frmDownload.Result.TargetFolder);

                            // Replace old string by new string
                            if (!String.IsNullOrEmpty(filename) && !String.IsNullOrEmpty(frmDownload.Result.ReplaceSource))
                            {
                                string content    = System.IO.File.ReadAllText(filename);
                                string newContent = Regex.Replace(
                                    content,
                                    Regex.Escape(frmDownload.Result.ReplaceSource),
                                    frmDownload.Result.ReplaceTarget,
                                    RegexOptions.IgnoreCase);

                                System.IO.File.WriteAllText(filename, newContent);
                            }
                        }

                        MessageBox.Show("Download completed.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    catch (Exception ex)
                    {
                        this.DisplayException(ex);
                    }
                }
            }
        }
Пример #7
0
        private void DownloadDocumentExec(object sender, ExecutedRoutedEventArgs e)
        {
            DownloadWindow dw = new DownloadWindow();

            dw.ShowDialog();
            if (dw.ShouldExecute && dw.ACCESSCODE != "")
            {
                DocumentManager.downloadProcedure(dw.ACCESSCODE, mbox.Document);
                setWindowTitle(dw.ACCESSCODE);
            }
            else if (dw.ShouldExecute && dw.ACCESSCODE == "")
            {
                MessageBox.Show("Incorrect URL!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public void ShowDownloadDialog(TwitchVideo video, TwitchVideoResolution resolution, string folder, string filename, Action <bool, DownloadParameters> dialogCompleteCallback)
        {
            if (video == null)
            {
                throw new ArgumentNullException(nameof(video));
            }

            if (resolution == null)
            {
                throw new ArgumentNullException(nameof(resolution));
            }

            if (string.IsNullOrWhiteSpace(folder))
            {
                throw new ArgumentNullException(nameof(folder));
            }

            if (string.IsNullOrWhiteSpace(filename))
            {
                throw new ArgumentNullException(nameof(filename));
            }

            if (dialogCompleteCallback == null)
            {
                throw new ArgumentNullException(nameof(dialogCompleteCallback));
            }

            DownloadWindowVM vm = this.kernel.Get <DownloadWindowVM>();

            vm.Video      = video;
            vm.Resolution = resolution;
            vm.Folder     = folder;
            vm.Filename   = filename;

            DownloadWindow window = this.kernel.Get <DownloadWindow>();

            window.DataContext = vm;

            bool?result = window.ShowDialog();

            DownloadParameters resultObject = vm.ResultObject;

            dialogCompleteCallback(result != true, resultObject);
        }
Пример #9
0
        protected virtual void ShowDownloadWindow(RemoteAppcast appcast)
        {
            var viewModel    = new DownloadWindowViewModel(_appInfo, _logger, RemoteContentDownloader);
            var artifactPath = CreateTempPath(appcast.ArtifactUrl);
            var window       = new DownloadWindow {
                DataContext = viewModel
            };

            viewModel.ContinueWithInstallationCommand = new DelegateCommand(e =>
            {
                _logger.Log("Continue after downloading artifact");
                _analyticsLogger.LogContinueWithInstallation();
                OnArtifactDownloadedEvent(new SingleEventArgs <string>(artifactPath));
                window.Close();
                if (ShouldOpenArtifact(appcast, artifactPath))
                {
                    OpenArtifact(artifactPath);
                    _logger.Log("Opened artifact");
                }
            });
            SetOwner(window);
            viewModel.StartAsync(appcast, artifactPath);
            window.ShowDialog();
        }