forked from fifonik/FFBitrateViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOverallProgress.cs
133 lines (101 loc) · 3.27 KB
/
OverallProgress.cs
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
133
using System;
using System.Collections.ObjectModel;
namespace FFBitrateViewer
{
public class OverallProgress : Bindable
{
private int FilesWeightTotal = 1;
private int FilesWeightProcessed = 0;
private int CurrentFileWeight = 1;
private int FramesTotal = 0;
private int FramesProcessed = 0;
public bool IsActive { get { return Get<bool>(); } private set { Set(value); } }
public bool IsIndeterminate { get { return Get<bool>(); } private set { Set(value); } }
public int Current { get { return Get<int>(); } private set { Set(value); } }
public int Max { get { return Get<int>(); } private set { Set(value); } }
public double CurrentPercent { get { return Get<double>(); } private set { Set(value); } }
public string? Text { get { return Get<string?>(); } private set { Set(value); } }
public OverallProgress() {
//IsActive = true;
//IsIndeterminate = true;
//Text = "123";
}
public void Init()
{
FilesWeightTotal = 0;
FilesWeightProcessed = 0;
CurrentFileWeight = 1;
FramesTotal = 0;
FramesProcessed = 0;
MaxUpdate();
CurrentUpdate();
}
public void Init(int max)
{
Reset();
Max = max;
CurrentPercentUpdate();
}
public void Start()
{
IsActive = true;
}
public void Stop()
{
IsActive = false;
}
public void Show(string text)
{
Text = text;
IsIndeterminate = true;
Start();
}
public void Hide()
{
Text = null;
IsIndeterminate = false;
Stop();
}
public void Reset()
{
FilesWeightTotal = 1;
FilesWeightProcessed = 0;
CurrentFileWeight = 1;
FramesTotal = 0;
FramesProcessed = 0;
MaxUpdate();
CurrentUpdate();
}
public void Inc()
{
++Current;
CurrentPercentUpdate();
}
public void FramesTotalSet(int frames)
{
if (frames < 0) return;
FramesTotal = frames;
CurrentUpdate();
}
public void FramesProcessedSet(int frame)
{
if (frame < 0 || FramesTotal == 0) return;
FramesProcessed = frame;
CurrentUpdate();
}
private void CurrentUpdate()
{
Current = 100 * FilesWeightProcessed + ((FramesTotal != 0) ? CurrentFileWeight * (int)Math.Round((double)100 * FramesProcessed / FramesTotal) : 0);
CurrentPercentUpdate();
}
private void CurrentPercentUpdate()
{
CurrentPercent = Max == 0 ? 0 : (Current / (double)Max);
}
private void MaxUpdate()
{
Max = 100 * FilesWeightTotal;
CurrentPercentUpdate();
}
}
}