1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="QueueProgressStatus.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
// Defines the QueueProgressStatus type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Services.Queue.Model
{
using System;
using Caliburn.Micro;
using HandBrakeWPF.Properties;
using HandBrakeWPF.Services.Encode.EventArgs;
public class QueueProgressStatus : PropertyChangedBase
{
private string jobStatus;
private bool intermediateProgress;
private double progressValue;
private EncodeProgressEventArgs progressEventArgs;
public QueueProgressStatus()
{
}
public string JobStatus
{
get
{
return this.jobStatus;
}
set
{
this.jobStatus = value;
this.NotifyOfPropertyChange(() => this.JobStatus);
}
}
public bool IntermediateProgress
{
get => this.intermediateProgress;
set
{
if (value == this.intermediateProgress) return;
this.intermediateProgress = value;
this.NotifyOfPropertyChange(() => this.IntermediateProgress);
}
}
public double ProgressValue
{
get => this.progressValue;
set
{
if (value == this.progressValue) return;
this.progressValue = value;
this.NotifyOfPropertyChange(() => this.ProgressValue);
}
}
public int? Task => this.progressEventArgs?.Task ?? 0;
public int? TaskCount => this.progressEventArgs?.TaskCount ?? 0;
public TimeSpan? EstimatedTimeLeft => this.progressEventArgs?.EstimatedTimeLeft ?? null;
public void Update(EncodeProgressEventArgs e)
{
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);
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,
e.Task,
e.TaskCount,
e.PercentComplete,
e.CurrentFrameRate,
e.AverageFrameRate,
totalHrsLeft,
elapsedTimeHrs,
null);
this.ProgressValue = e.PercentComplete;
}
}
public void SetPaused()
{
this.ClearStatusDisplay();
this.JobStatus = Resources.QueueViewModel_QueuePaused;
}
public void ClearStatusDisplay()
{
this.JobStatus = string.Empty;
this.ProgressValue = 0;
this.IntermediateProgress = false;
}
}
}
|