@@ -47,12 +47,13 @@ public class AnimatorTimer_WOC
47
47
48
48
private int _interval ;
49
49
private int _neededValue ;
50
+ private int _animationFps = 30 ;
50
51
private float _progress ;
51
52
private float _speed = 0 ;
52
53
53
54
private AutoResetEvent reset = new AutoResetEvent ( false ) ;
54
55
private Control _invokeControl ;
55
-
56
+ private bool _checkFps = false ;
56
57
57
58
public AnimatorTimer_WOC ( Control control )
58
59
{
@@ -63,13 +64,13 @@ public AnimatorTimer_WOC(Control control)
63
64
int frequency = Utils_WOC . getMonitorFrequency ( ) ;
64
65
_displayRefreshRate = frequency != - 1 ? frequency : 60 ;
65
66
}
66
- _interval = ( int ) Math . Round ( 1000 / _displayRefreshRate ) ;
67
+ _interval = 1000 / _animationFps ;
67
68
}
68
69
69
70
public void start ( )
70
71
{
71
72
Enabled = true ;
72
-
73
+
73
74
new Thread ( ( ) =>
74
75
{
75
76
while ( _isEnabled )
@@ -105,7 +106,7 @@ public void setValueRange(int neededProgress, Int32 progress, int milis, bool st
105
106
{
106
107
if ( ! Enabled )
107
108
{
108
- _speed = ( neededProgress - _progress ) / ( milis / ( 1000 / _displayRefreshRate ) ) ;
109
+ _speed = ( neededProgress - _progress ) / ( milis / ( 1000 / _animationFps ) ) ;
109
110
_progress = progress ;
110
111
}
111
112
@@ -116,7 +117,7 @@ public void setValueRange(int neededProgress, int milis, bool start)
116
117
{
117
118
if ( ! Enabled )
118
119
{
119
- float a = ( milis / ( 1000 / _displayRefreshRate ) ) ;
120
+ float a = ( milis / ( 1000 / _animationFps ) ) ;
120
121
float b = ( neededProgress - _progress ) ;
121
122
_speed = ( b / a ) ;
122
123
}
@@ -139,6 +140,15 @@ public bool Enabled
139
140
get { return _isEnabled ; }
140
141
set { _isEnabled = value ; }
141
142
}
142
- public int Interval { get { return _interval ; } }
143
+
144
+ public bool CheckMonitorFps
145
+ {
146
+ get { return _checkFps ; }
147
+ set
148
+ {
149
+ _checkFps = value ;
150
+ _animationFps = _checkFps ? ( int ) _displayRefreshRate : 30 ;
151
+ }
152
+ }
143
153
}
144
154
}
0 commit comments