diff options
Diffstat (limited to 'win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs')
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs | 123 |
1 files changed, 87 insertions, 36 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs index 5ed36d5b9..e3dbba559 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueProgressStatus.cs @@ -18,6 +18,8 @@ namespace HandBrakeWPF.Services.Queue.Model public class QueueProgressStatus : PropertyChangedBase { + private readonly object lockObj = new object(); + private string jobStatus; private bool intermediateProgress; private double progressValue; @@ -26,6 +28,7 @@ namespace HandBrakeWPF.Services.Queue.Model public QueueProgressStatus() { + this.JobStatus = "Waiting"; } public string JobStatus @@ -47,7 +50,11 @@ namespace HandBrakeWPF.Services.Queue.Model get => this.intermediateProgress; set { - if (value == this.intermediateProgress) return; + if (value == this.intermediateProgress) + { + return; + } + this.intermediateProgress = value; this.NotifyOfPropertyChange(() => this.IntermediateProgress); } @@ -58,7 +65,11 @@ namespace HandBrakeWPF.Services.Queue.Model get => this.progressValue; set { - if (value == this.progressValue) return; + if (value == this.progressValue) + { + return; + } + this.progressValue = value; this.NotifyOfPropertyChange(() => this.ProgressValue); } @@ -72,50 +83,91 @@ namespace HandBrakeWPF.Services.Queue.Model public void Update(EncodeProgressEventArgs e) { - progressEventArgs = e; - this.IntermediateProgress = false; + lock (lockObj) + { + progressEventArgs = e; + this.IntermediateProgress = false; - string totalHrsLeft = e.EstimatedTimeLeft.Days >= 1 ? string.Format(@"{0:d\:hh\:mm\:ss}", e.EstimatedTimeLeft) : string.Format(@"{0:hh\:mm\:ss}", e.EstimatedTimeLeft); - string elapsedTimeHrs = e.ElapsedTime.Days >= 1 ? string.Format(@"{0:d\:hh\:mm\:ss}", e.ElapsedTime) : string.Format(@"{0:hh\:mm\:ss}", e.ElapsedTime); + string totalHrsLeft = e.EstimatedTimeLeft.Days >= 1 ? string.Format(@"{0:d\:hh\:mm\:ss}", e.EstimatedTimeLeft) : string.Format(@"{0:hh\:mm\:ss}", e.EstimatedTimeLeft); + string elapsedTimeHrs = e.ElapsedTime.Days >= 1 ? string.Format(@"{0:d\:hh\:mm\:ss}", e.ElapsedTime) : string.Format(@"{0:hh\:mm\:ss}", e.ElapsedTime); - if (e.IsSubtitleScan) - { - this.JobStatus = string.Format(Resources.MainViewModel_EncodeStatusChanged_SubScan_StatusLabel, - e.Task, - e.TaskCount, - e.PercentComplete, - totalHrsLeft, - elapsedTimeHrs, - null); - - this.ProgressValue = e.PercentComplete; - } - else if (e.IsMuxing) - { - this.JobStatus = Resources.MainView_Muxing; - this.IntermediateProgress = true; - } - else if (e.IsSearching) - { - this.JobStatus = string.Format(Resources.MainView_ProgressStatusWithTask, Resources.MainView_Searching, e.PercentComplete, e.EstimatedTimeLeft, null); - this.ProgressValue = e.PercentComplete; - } - else - { - this.JobStatus = - string.Format(Resources.QueueViewModel_EncodeStatusChanged_StatusLabel, + if (e.IsSubtitleScan) + { + this.JobStatus = string.Format(Resources.MainViewModel_EncodeStatusChanged_SubScan_StatusLabel, e.Task, e.TaskCount, e.PercentComplete, - e.CurrentFrameRate, - e.AverageFrameRate, totalHrsLeft, elapsedTimeHrs, null); - this.ProgressValue = e.PercentComplete; + + this.ProgressValue = e.PercentComplete; + } + else if (e.IsMuxing) + { + this.JobStatus = Resources.MainView_Muxing; + this.IntermediateProgress = true; + } + else if (e.IsSearching) + { + this.JobStatus = string.Format(Resources.MainView_ProgressStatusWithTask, Resources.MainView_Searching, e.PercentComplete, e.EstimatedTimeLeft, null); + this.ProgressValue = e.PercentComplete; + } + else + { + this.JobStatus = + string.Format(Resources.QueueViewModel_EncodeStatusChanged_StatusLabel, + e.Task, + e.TaskCount, + e.PercentComplete, + e.CurrentFrameRate, + e.AverageFrameRate, + totalHrsLeft, + elapsedTimeHrs, + null); + this.ProgressValue = e.PercentComplete; + } } } + public void Update(EncodeCompletedEventArgs e) + { + lock (lockObj) + { + if (e.Successful) + { + this.JobStatus = Resources.QueueView_JobStatus_Complete; + } + else + { + switch (e.ErrorInformation) + { + case "1": // HB_ERROR_CANCELED + this.JobStatus = Resources.QueueView_JobStatus_Cancelled; + break; + case "2": // HB_ERROR_WRONG_INPUT + this.JobStatus = Resources.QueueView_JobStatus_InvalidInput; + break; + case "3": // HB_ERROR_INIT + this.JobStatus = Resources.QueueView_JobStatus_InitFailed; + break; + case "4": // HB_ERROR_UNKNOWN + this.JobStatus = Resources.QueueView_JobStatus_Unknown; + break; + case "5": // HB_ERROR_READ + this.JobStatus = Resources.QueueView_JobStatus_ReadError; + break; + case "-11": // Worker Crash + this.JobStatus = Resources.QueueView_JobStatus_WorkerCrash; + break; + default: + this.JobStatus = Resources.QueueView_JobStatus_NoErrorCode; + break; + } + } + } + } + public void SetPaused() { this.ClearStatusDisplay(); @@ -124,7 +176,6 @@ namespace HandBrakeWPF.Services.Queue.Model public void ClearStatusDisplay() { - this.JobStatus = string.Empty; this.ProgressValue = 0; this.IntermediateProgress = false; } |