Beispiel #1
0
        public async void Download(string line, bool running)
        {
            if (ParseProtocol(line))
            {
                if (await GetData())
                {
                    DownloadWindow downloadWindow = new DownloadWindow(response);
                    downloadWindow.ShowDialog();
                    if (downloadWindow.YesNo)
                    {
                        await DownloadFile(URL_TO_ARCHIVE, fileName, new Progress <DownloadProgress>(ReportUpdateProgress),
                                           CancellationTokenSource.CreateLinkedTokenSource(cancellationToken.Token));

                        if (!cancelled)
                        {
                            await ExtractFile(fileName);
                        }
                    }
                }
            }
            if (running)
            {
                Environment.Exit(0);
            }
        }
Beispiel #2
0
        public async void BrowserDownload(GameBananaRecord record)
        {
            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(fileName, record);
                    }
                }
            }
        }