public void OnDownloadCompleted(DownloadResult result) { if (result == DownloadResult.Incomplete) { _downloadService.Cancel(); } _downloadService.Completed -= OnDownloadCompleted; _downloadService.ProgressChanged -= OnDownloadProgressChanged; }
public void Cancel() { if (_windowManager.ShowMessageBox("${WhetherCancelDownload}", "${CancelDownload}", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { _downloadService.Cancel(); } }
private void uxCancelButton_Click(object sender, EventArgs e) { DownloadService.Cancel(); if (uxCancelButton.Text != PCResource.LaunchButtongText) { CancelDownload = true; } this.Close(); }
protected override void OnViewLoaded() { var window = this.View as Window; window.Closing += (sender, e) => { if (IsDownloading && this.IsActive) { if (_windowManager.ShowMessageBox("${WhetherCancelUpdate}", "${CancelUpdate}", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { _downloadService.Cancel(); } else { e.Cancel = true; } } }; }
public void Setup(UpdateInfo info) { var download = _updateService.GetDownload(info); _downloadService = new DownloadService(download); _downloadService.ProgressChanged += progress => { DownloadProgress = (double)progress.DownloadedBytes / progress.TotalBytes; Percentage = (DownloadProgress * 100.0).ToString("0.0") + '%'; }; _downloadService.Completed += result => { if (result == DownloadResult.Incomplete) { _downloadService.Cancel(); } }; IsDownloading = false; DisplayUpdateInfo(info); }