private async void DownloadAsync() { IsSkipButtonVisible = false; IsDownloadButtonVisible = false; IsCancelButtonVisible = false; IsInterruptButtonVisible = true; string downloadFilePath = null; MainModel.DownloadFileResult?result = null; try { string downloadDirectory = Path.Combine(Environment.AppDataDirectory, "Updates"); if (!Directory.Exists(downloadDirectory)) { Directory.CreateDirectory(downloadDirectory); } downloadFilePath = Path.Combine(downloadDirectory, updateCheckResult.FileName); Progress <object> downloadProgressHandler = new Progress <object>(HandleDownloadProgress); result = await MainModel.DownloadFileAsync(updateCheckResult.DownloadUrl, downloadFilePath, downloadProgressHandler, cancellationTokenSource.Token); } catch (Exception exception) { ShowErrorWindow(exception, CurrentWindowContext); error = true; } if (!error && result != MainModel.DownloadFileResult.COMPLETED) { if (result == MainModel.DownloadFileResult.INCOMPLETE) { ShowMessage(Localization.Error, Localization.IncompleteDownload); } error = true; } IsInterruptButtonVisible = false; IsCloseButtonVisible = true; if (!error) { if (Environment.IsInPortableMode) { Process.Start("explorer.exe", $@"/select, ""{downloadFilePath}"""); CurrentWindowContext.CloseDialog(false); } else { Process.Start(downloadFilePath); CurrentWindowContext.CloseDialog(false); ApplicationShutdownRequested?.Invoke(this, EventArgs.Empty); } } }
private async void DownloadAsync() { IsSkipButtonVisible = false; IsDownloadButtonVisible = false; IsCancelButtonVisible = false; IsInterruptButtonVisible = true; Updater.UpdateDownloadResult result = null; try { Progress <object> downloadProgressHandler = new Progress <object>(HandleDownloadProgress); result = await MainModel.Updater.DownloadUpdateAsync(updateCheckResult, downloadProgressHandler, cancellationTokenSource.Token); } catch (Exception exception) { ShowErrorWindow(exception, CurrentWindowContext); error = true; } if (!error && result.DownloadResult != DownloadUtils.DownloadResult.COMPLETED) { if ((result.DownloadResult == DownloadUtils.DownloadResult.INCOMPLETE) || (result.DownloadResult == DownloadUtils.DownloadResult.ERROR)) { ShowMessage(Localization.Error, Localization.IncompleteDownload); } error = true; } IsInterruptButtonVisible = false; IsCloseButtonVisible = true; if (!error) { if (Environment.IsInPortableMode) { Process.Start("explorer.exe", $@"/select, ""{result.DownloadFilePath}"""); CurrentWindowContext.CloseDialog(false); } else { Process.Start(result.DownloadFilePath); CurrentWindowContext.CloseDialog(false); ApplicationShutdownRequested?.Invoke(this, EventArgs.Empty); } } }