コード例 #1
0
ファイル: Program.cs プロジェクト: androidhacker/DotNetProjs
		public void ReadProgress(object sender, ReadProgressArgs e)
		{
			CDDriveReader audioSource = (CDDriveReader)sender;
			int processed = e.Position - e.PassStart;
			TimeSpan elapsed = DateTime.Now - e.PassTime;
			double speed = elapsed.TotalSeconds > 0 ? processed / elapsed.TotalSeconds / 75 : 1.0;
			TimeSpan totalElapsed = DateTime.Now - realStart;
			TimeSpan totalEstimated = TimeSpan.FromMilliseconds(totalElapsed.TotalMilliseconds / Math.Max(1, (e.PassStart + (processed + e.Pass * (e.PassEnd - e.PassStart)) / (audioSource.CorrectionQuality + 1))) * audioSource.TOC.AudioLength);

			// if ((elapsed - lastPrint).TotalMilliseconds > 60) ;
			Console.Write("\r{9} : {0:00}%; {1:00.00}x; {2} ({10:0.00}%) errors; {3:d2}:{4:d2}:{5:d2}/{6:d2}:{7:d2}:{8:d2}        ",
				100.0 * e.Position / audioSource.TOC.AudioLength,
				speed,
				e.ErrorsCount,
				totalElapsed.Hours, totalElapsed.Minutes, totalElapsed.Seconds,
				totalEstimated.Hours, totalEstimated.Minutes, totalEstimated.Seconds,
				e.Pass < 1 ? "Progress   " : string.Format("Retry {0:00}   ", e.Pass),
				processed > 0 ? 100.0 * e.ErrorsCount / processed / (4 * 588) : 0
			);
			//lastPrint = elapsed;
		}
コード例 #2
0
		private void CDReadProgress(object sender, ReadProgressArgs e)
		{		
			CheckStop();

			ICDRipper audioSource = sender as ICDRipper;
			int processed = e.Position - e.PassStart;
			TimeSpan elapsed = DateTime.Now - e.PassTime;
			double speed = elapsed.TotalSeconds > 0 ? processed / elapsed.TotalSeconds / 75 : 1.0;

			double percentTrck = (double)(e.Position - e.PassStart) / (e.PassEnd - e.PassStart);
			string retry = e.Pass > 0 ? " (" + Properties.Resources.Retry + " " + e.Pass.ToString() + ")" : "";
			string status = (elapsed.TotalSeconds > 0 && e.Pass >= 0) ?
				string.Format("{0} @{1:00.00}x{2}...", e.Action, speed, retry) :
				string.Format("{0}{1}...", e.Action, retry);
			this.BeginInvoke((MethodInvoker)delegate()
			{
				toolStripStatusLabel1.Text = status;
				toolStripProgressBar1.Value = Math.Max(0, Math.Min(100, (int)(percentTrck * 100)));

				progressBarErrors.Maximum = (int)(Math.Log(e.PassEnd - e.PassStart + 1) * 10);
				progressBarErrors.Value = Math.Min(progressBarErrors.Maximum, (int)(Math.Log(e.ErrorsCount + 1) * 10));
				progressBarErrors.Enabled = e.Pass >= audioSource.CorrectionQuality;

				progressBarCD.Maximum = (int) audioSource.TOC.AudioLength;
				progressBarCD.Value = Math.Max(0, Math.Min(progressBarCD.Maximum, (int)e.PassStart + (e.PassEnd - e.PassStart) * (Math.Min(e.Pass, audioSource.CorrectionQuality) + 1) / (audioSource.CorrectionQuality + 1)));
			});
		}