Пример #1
0
        public void UpdateProgress(LifFile.ExtractionProgress progress)
        {
            float percentage = progress.TotalBytes > 0 ?
                               (progress.BytesExtracted / (float)progress.TotalBytes) * 100f : 0f;

            ExtractionProgressBar.Value    = (int)percentage;
            FileProgressValueLabel.Text    = $"{progress.ExtractedFiles} / {progress.TotalFiles}";
            ProgressPercentValueLabel.Text = $"{percentage:0}%";

            var timeElapsed = TimeSpan.Zero; // (DateTime.Now - ExtractionStart);

            if (ExtractionStart != default(DateTime))
            {
                timeElapsed = (DateTime.Now - ExtractionStart);
            }

            ElapsedTimeValueLabel.Text = timeElapsed.ToString("hh\\:mm\\:ss");

            var remainingTime = TimeSpan.Zero;

            if (progress.BytesExtracted > 0)
            {
                var avgTime        = timeElapsed.TotalMilliseconds / (double)progress.BytesExtracted;
                var remainingBytes = (double)(progress.TotalBytes - progress.BytesExtracted);
                remainingTime = TimeSpan.FromMilliseconds(avgTime * remainingBytes);
            }

            RemainingTimeValueLabel.Text = remainingTime.ToString("hh\\:mm\\:ss");

            CurrentFileLabel.Text = progress.TargetPath;
        }
Пример #2
0
        private void ExtractionProgressTimer_Tick(object sender, EventArgs e)
        {
            LifFile.ExtractionProgress currentProgress = null;
            lock (UpdateLock)
                currentProgress = LastestProgress;

            if (currentProgress != null)
            {
                extractProgressPanel1.UpdateProgress(currentProgress);
            }
        }
Пример #3
0
 private void OnExtractionProgress(object sender, LifFile.ExtractionProgress progress)
 {
     lock (UpdateLock)
         LastestProgress = progress;
 }