Exemple #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);
                    }
                }
            }
        }
Exemple #2
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);
        }
Exemple #3
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);
            }
        }
        private void DownloadDataAsync_Click(object sender, RoutedEventArgs e)
        {
            DownloadWindow downloadWind = new DownloadWindow();

            App.Current.MainWindow = downloadWind;
            this.Close();
            downloadWind.Show();
        }
Exemple #5
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();
        }
Exemple #6
0
        public void ShowDownloadMinecraftList()
        {
            Settings.Save();
            var downloader     = new MinecraftDownloader(Settings.UseBMCL, Settings.MinecraftFolderName);
            var downloadDialog = new DownloadWindow(downloader);

            downloadDialog.ShowDialog(MainForm);
            downloadDialog.Dispose();
        }
 private void Timer_Tick(object sender, EventArgs e)
 {
     progressBar.Value += 1;
     if (progressBar.Value >= 100)
     {
         timer.Stop();
         progressBar.Value = 0;
         DownloadWindow mainWindow = new DownloadWindow();
         mainWindow.Show();
         this.Close();
     }
 }
Exemple #8
0
 //获取新版本
 private void GetNewVersion()
 {
     if (LocalVersion == NewVersion)
     {
         MessageBox.Show("你正在使用最新版本!");
     }
     else if (LocalVersion != NewVersion && File.Exists(UpdateXmlPath))
     {
         DownloadWindow DW = new DownloadWindow();
         DW.Show();
     }
 }
Exemple #9
0
        private void OnDownloadButtonClick(object sender, RoutedEventArgs e)
        {
            if (AnimeGrid.SelectedItem == null)
            {
                return;
            }
            var anime  = AnimeGrid.SelectedItem as Anime;
            var window = new DownloadWindow(anime, _password, _config);

            window.Show();
            window.StartDownload();
        }
Exemple #10
0
        /// <summary>
        /// Event handler for the click event on the download job button.
        /// Asks the user for confirmation, then downloads the results for each
        /// job the user has selected.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnDownload_Click(object sender, EventArgs e)
        {
            List <string> jobIds = GetSelectedJobIds();

            // Normally (when stopping or deleting) the presenter would check to make sure there is at least 1 job selected.
            // In this case though, we check here to prevent the download pop-up from appearing if nothing is selected.
            if (jobIds.Count < 1)
            {
                Presenter.ShowMessage("Unable to download jobs: no jobs are selected", Models.Core.Simulation.MessageType.Information);
                return;
            }
            DownloadWindow dl = new DownloadWindow(Presenter, jobIds);
        }
        /// <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);
                    }
                }
            }
        }
        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);
            }
        }
        /// <summary>
        /// 下载
        /// </summary>
        private void DownloadNewversion_()
        {
            DownloadWindow DW = new DownloadWindow();

            DW.Show();
            Download = true;
            //添加下载完成/下载进度事件
            client.DownloadFileCompleted   += new AsyncCompletedEventHandler(Completed);
            client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
            //
            stopwatch.Start();
            // 开始异步下载
            Uri newVersionDownloadURL = new Uri(NewVersionDownloadURL);

            client.DownloadFileAsync(newVersionDownloadURL, CurrentPath + NewVersionFileName + ".zip");
        }
Exemple #14
0
        public static bool Download(DownloadWindow dl, string hashSt, string exest, string destination)
        {
            if (!Directory.Exists(destination))
            {
                Directory.CreateDirectory(destination);
            }

            dl.syncStatus("Downloading: " + exest);

            string command = " --fc \"" + destination + "\" --fi \"" + destination + "\" --ft \"" + destination + "\" --fs \"" + destination + "\" " + hashSt + "\"";

            BitSwarm(command);

            dl.syncStatus("Download Complete: " + exest);

            return(true);
        }
        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);
        }
        public static string DownloadFile(string url, string destination, Action finishAction, bool isBackground = false)
        {
            string baseURL = GetBaseURL(url);

            if (baseURL != "")
            {
                url = baseURL;
            }

            string remote_filename = "";

            if (url != "")
            {
                remote_filename = GetRemoteFileName(url);
            }
            string filename = "temp.zip";

            if (remote_filename != "")
            {
                filename = remote_filename;
            }

            if (File.Exists($"{destination}\\{filename}"))
            {
                File.Delete($"{destination}\\{filename}");
            }
            if (!Directory.Exists(destination))
            {
                Directory.CreateDirectory(destination);
            }

            DownloadWindow downloadWindow = new DownloadWindow($"{Program.LanguageResource.GetString("Downloading")} \"{filename}\"", url, $"{destination}\\{filename}");

            downloadWindow.DownloadCompleted = finishAction;
            if (isBackground)
            {
                downloadWindow.StartBackground();
            }
            else
            {
                downloadWindow.Start();
            }
            return(filename);
        }
Exemple #17
0
        public static void AddDownload(DownloadFileInfo downloadItem)
        {
            DownloadWindow tempWindow = null;

            lock (DownloadWindows)
            {
                if (!DownloadWindows.TryGetValue(downloadItem.Id, out tempWindow))//不在缓存列表
                {
                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.FileName = downloadItem.SuggestedFileName;
                    sfd.Filter   = "所有文件|*";

                    var res = sfd.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        tempWindow = new DownloadWindow();
                        var vm = new DownloadItemViewModel()
                        {
                            FullPath      = sfd.FileName,
                            ID            = downloadItem.Id,
                            ReceivedBytes = 0,
                            Url           = downloadItem.Url,
                            TotalBytes    = downloadItem.TotalBytes
                        };
                        tempWindow.Closed += (s, e) =>
                        {
                            tempWindow.DataContext = null;
                            tempWindow.Close();
                            DownloadWindows.TryRemove(downloadItem.Id, out tempWindow);
                        };
                        tempWindow.DataContext = vm;
                        tempWindow.Show();
                        tempWindow.Activate();

                        DownloadWindows.TryAdd(downloadItem.Id, tempWindow);
                    }
                }
            }
        }
Exemple #18
0
        protected virtual async Task ShowDownloadWindow(Channel channel)
        {
            var viewModel    = new DownloadWindowViewModel(AppInfo, _logger, RemoteContentDownloader);
            var artifactPath = CreateTempPath(channel.ArtifactUrl);
            var window       = new DownloadWindow {
                DataContext = viewModel
            };

            bool[] finishedDownloading = { false };
            viewModel.ContinueWithInstallationCommand = new DelegateCommand(e =>
            {
                _logger.Log("Continue after downloading artifact");
                _analyticsLogger.LogContinueWithInstallation();
                OnArtifactDownloadedEvent(new SingleEventArgs <string>(artifactPath));
                window.Close();
                if (ShouldOpenArtifact(channel, artifactPath))
                {
                    OpenArtifact(artifactPath);
                    _logger.Log("Opened artifact");
                }
            }, o => finishedDownloading[0]);

            SetOwner(window);
            OnWindowWillBeDisplayed(window, channel);
            window.Show();

            var savedAt = await viewModel.StartAsync(channel, artifactPath).ConfigureAwait(true);

            finishedDownloading[0] = true;
            ((DelegateCommand)viewModel.ContinueWithInstallationCommand).RaiseCanExecuteChanged();

            if (string.IsNullOrWhiteSpace(savedAt))
            {
                window.Close();
                ShowErrorWindow();
            }
        }
Exemple #19
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();
        }
        private void DownloadButton_Click(object sender, RoutedEventArgs e)
        {
            DownloadWindow DownloadWindow = new DownloadWindow();

            DownloadWindow.Show();
        }
        public void OnDownloadUpdated(IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
        {
            try
            {
                if (!string.IsNullOrEmpty(downloadItem.FullPath))
                {
                    DownloadWindow tempWindow = null;

                    if (DownloadWindows.TryGetValue(downloadItem.Id, out tempWindow))//存在缓存里
                    {
                        var vm = tempWindow.DataContext as DownloadItemViewModel;
                        vm.ReceivedBytes = downloadItem.ReceivedBytes;
                        vm.TotalBytes    = downloadItem.TotalBytes;

                        if (downloadItem.IsComplete)//删除完成删除
                        {
                            tempWindow.Close();
                            callback.Dispose();
                            DownloadWindows.TryRemove(downloadItem.Id, out tempWindow);
                        }
                    }
                    else
                    {
                        if (CacheList.Count(c => c.ID == downloadItem.Id) > 0)
                        {
                            return;
                        }

                        tempWindow = new DownloadWindow();
                        var vm = new DownloadItemViewModel()
                        {
                            FullPath      = downloadItem.FullPath,
                            ID            = downloadItem.Id,
                            ReceivedBytes = downloadItem.ReceivedBytes,
                            TotalBytes    = downloadItem.TotalBytes,
                            Url           = downloadItem.Url
                        };

                        tempWindow.Closed += (s, e) =>
                        {
                            CacheList.Add(new CacheModel()
                            {
                                ID = downloadItem.Id, AddTime = DateTime.Now
                            });
                            downloadItem.IsCancelled = true;
                            tempWindow.DataContext   = null;
                            tempWindow.Close();
                            callback.Dispose();
                            DownloadWindows.TryRemove(downloadItem.Id, out tempWindow);

                            Application.Current.Dispatcher.Invoke(new Action(() =>
                            {
                                if (hideWindow != null)
                                {
                                    hideWindow.Close();
                                }
                            }));
                        };
                        tempWindow.DataContext = vm;
                        tempWindow.Show();
                        tempWindow.Activate();

                        DownloadWindows.TryAdd(downloadItem.Id, tempWindow);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
Exemple #22
0
 // Remove
 public void Download(DownloadWindow dw)
 {
     Torrent.status = true;
     Torrent.Download(dw, hash, name, extraction + destination);
 }
Exemple #23
0
 public void Download(DownloadWindow dw, string destination)
 {
     Torrent.status = true;
     Torrent.Download(dw, hash, name, destination);
 }