private static void SubProgress_ProgressChanged(object sender, ScanSubProgress e) { switch (e.Step) { case ScanSubProgressStep.Check: Console.WriteLine("Verifying file checksum"); break; case ScanSubProgressStep.Download: if (e.DownloadProgress != null) { if (e.DownloadProgress.Size == 0) { Console.WriteLine("Starting download"); } else { var downloaded = BytesSizeExtension.FormatToBytesSizeThreeNonZeroDigits(e.DownloadProgress.SizeCompleted); var leftToDownload = BytesSizeExtension.FormatToBytesSizeThreeNonZeroDigits(e.DownloadProgress.Size); var downloadSpeed = double.IsInfinity(e.DownloadProgress.Speed) ? string.Empty : $"({BytesSizeExtension.FormatToBytesSizeThreeNonZeroDigits(e.DownloadProgress.Speed)}/s)"; Console.WriteLine($"Downloading {downloaded}/{leftToDownload} {downloadSpeed}"); } } break; case ScanSubProgressStep.CheckDownload: Console.WriteLine("Checking downloaded file"); break; case ScanSubProgressStep.ExtractDownload: Console.WriteLine("Extracting"); break; case ScanSubProgressStep.CheckExtractDownload: Console.WriteLine("Checking extracted file"); break; case ScanSubProgressStep.Finalize: Console.WriteLine("Finalizing"); break; } }
private void SubProgressChanged(object sender, ScanSubProgress e) { switch (e.Step) { case ScanSubProgressStep.Check: MainProgressLabel.Content = Properties.Resources.GameScannerVerifying; FileProgress.ProgressBar.IsIndeterminate = false; FileProgress.ProgressBar.Value = e.ProgressPercentage; break; case ScanSubProgressStep.Download: if (e.DownloadProgress != null) { if (e.DownloadProgress.Size == 0) { MainProgressLabel.Content = Properties.Resources.GameScannerDownloadStarting; } else { var downloaded = BytesSizeExtension.FormatToBytesSizeThreeNonZeroDigits(e.DownloadProgress.SizeCompleted); var leftToDownload = BytesSizeExtension.FormatToBytesSizeThreeNonZeroDigits(e.DownloadProgress.Size); var downloadSpeed = double.IsInfinity(e.DownloadProgress.Speed) ? string.Empty : $"({BytesSizeExtension.FormatToBytesSizeThreeNonZeroDigits(e.DownloadProgress.Speed)}/s)"; MainProgressLabel.Content = $"{Properties.Resources.GameScannerDownloading} {downloaded}/{leftToDownload} {downloadSpeed}"; } } FileProgress.ProgressBar.Value = e.ProgressPercentage; FileProgress.ProgressBar.IsIndeterminate = false; break; case ScanSubProgressStep.CheckDownload: MainProgressLabel.Content = Properties.Resources.GameScannerVerifyingDownloadedFile; FileProgress.ProgressBar.IsIndeterminate = true; break; case ScanSubProgressStep.ExtractDownload: MainProgressLabel.Content = Properties.Resources.GameScannerExtracting; FileProgress.ProgressBar.Value = e.ProgressPercentage; FileProgress.ProgressBar.IsIndeterminate = false; break; case ScanSubProgressStep.CheckExtractDownload: MainProgressLabel.Content = Properties.Resources.GameScannerVerifyingExtractedFile; FileProgress.ProgressBar.IsIndeterminate = true; break; case ScanSubProgressStep.Finalize: MainProgressLabel.Content = Properties.Resources.GameScannerFinalizing; FileProgress.ProgressBar.IsIndeterminate = true; break; case ScanSubProgressStep.End: FileProgress.ProgressBar.Value = 100; ScanTotalProgress.ProgressBar.Value = 100; TaskbarItemInfo.ProgressValue = 100; return; default: throw new ArgumentOutOfRangeException(nameof(e.Step), e.Step, null); } }
private void SubProgressChanged(object sender, ScanSubProgress e) { try { if (e.DownloadProgress != null) { lbl_ProgressDetail.Text = $"{BytesSizeExtension.FormatToBytesSizeThreeNonZeroDigits(e.DownloadProgress.SizeCompleted)}/{BytesSizeExtension.FormatToBytesSizeThreeNonZeroDigits(e.DownloadProgress.Size)}\r\n" + $"Speed: {BytesSizeExtension.FormatToBytesSizeThreeNonZeroDigits(e.DownloadProgress.Speed)}ps"; } else if (!string.IsNullOrWhiteSpace(lbl_ProgressDetail.Text)) { lbl_ProgressDetail.Text = string.Empty; } int baseProgress; int rangeMaxProgress; switch (e.Step) { case ScanSubProgressStep.Check: label1.Text = $@"[{(int) e.Step + 1}/{(int) ScanSubProgressStep.End}] Checking"; baseProgress = 0; rangeMaxProgress = 10; break; case ScanSubProgressStep.Download: label1.Text = $@"[{(int) e.Step + 1}/{(int) ScanSubProgressStep.End}] Downloading"; baseProgress = 10; rangeMaxProgress = 59; break; case ScanSubProgressStep.CheckDownload: label1.Text = $@"[{(int) e.Step + 1}/{(int) ScanSubProgressStep.End}] Checking downloaded file"; baseProgress = 69; rangeMaxProgress = 10; break; case ScanSubProgressStep.ExtractDownload: label1.Text = $@"[{(int) e.Step + 1}/{(int) ScanSubProgressStep.End}] Extracting downloaded file"; baseProgress = 79; rangeMaxProgress = 10; break; case ScanSubProgressStep.CheckExtractDownload: label1.Text = $@"[{(int) e.Step + 1}/{(int) ScanSubProgressStep.End}] Checking extracted file"; baseProgress = 89; rangeMaxProgress = 10; break; case ScanSubProgressStep.Finalize: label1.Text = $@"[{(int) e.Step + 1}/{(int) ScanSubProgressStep.End}] Finalize"; baseProgress = 99; rangeMaxProgress = 1; break; case ScanSubProgressStep.End: label1.Text = @"End"; pB_SubProgress.Value = 100; return; default: throw new ArgumentOutOfRangeException(nameof(e.Step), e.Step, null); } pB_SubProgress.Value = (int)(baseProgress + rangeMaxProgress * (e.ProgressPercentage / 100)); } catch (Exception) { // } }