Skip to content

Commit 111022f

Browse files
author
WithoutCaps
committed
added onStart/onEnd animation delegates and added way to disable autodetect monitor refresh rate
1 parent 79055a4 commit 111022f

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

LimitlessUI/AnimatorTimer_WOC.cs

+16-6
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ public class AnimatorTimer_WOC
4747

4848
private int _interval;
4949
private int _neededValue;
50+
private int _animationFps = 30;
5051
private float _progress;
5152
private float _speed = 0;
5253

5354
private AutoResetEvent reset = new AutoResetEvent(false);
5455
private Control _invokeControl;
55-
56+
private bool _checkFps = false;
5657

5758
public AnimatorTimer_WOC(Control control)
5859
{
@@ -63,13 +64,13 @@ public AnimatorTimer_WOC(Control control)
6364
int frequency = Utils_WOC.getMonitorFrequency();
6465
_displayRefreshRate = frequency != -1 ? frequency : 60;
6566
}
66-
_interval = (int)Math.Round(1000 / _displayRefreshRate);
67+
_interval = 1000 / _animationFps;
6768
}
6869

6970
public void start()
7071
{
7172
Enabled = true;
72-
73+
7374
new Thread(() =>
7475
{
7576
while (_isEnabled)
@@ -105,7 +106,7 @@ public void setValueRange(int neededProgress, Int32 progress, int milis, bool st
105106
{
106107
if (!Enabled)
107108
{
108-
_speed = (neededProgress - _progress) / (milis / (1000 / _displayRefreshRate));
109+
_speed = (neededProgress - _progress) / (milis / (1000 / _animationFps));
109110
_progress = progress;
110111
}
111112

@@ -116,7 +117,7 @@ public void setValueRange(int neededProgress, int milis, bool start)
116117
{
117118
if (!Enabled)
118119
{
119-
float a = (milis / (1000 / _displayRefreshRate));
120+
float a = (milis / (1000 / _animationFps));
120121
float b = (neededProgress - _progress);
121122
_speed = (b / a);
122123
}
@@ -139,6 +140,15 @@ public bool Enabled
139140
get { return _isEnabled; }
140141
set { _isEnabled = value; }
141142
}
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+
}
143153
}
144154
}

LimitlessUI/Animator_WOC.cs

+18-9
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,15 @@ public enum Animations
5858

5959
public Animator_WOC()
6060
{
61-
61+
6262

6363
}
6464
private void animationTimer_Tick(int progress)
6565
{
6666
if (_control != null)
6767
{
68-
// _control.FindForm().SuspendLayout();
68+
if (_onAnimationStart_del != null)
69+
_onAnimationStart_del.Invoke(_control);
6970

7071
switch (_animation)
7172
{
@@ -80,7 +81,8 @@ private void animationTimer_Tick(int progress)
8081
_onHeightChanged_del.Invoke(_control, _animatorTimer.Speed, progress);
8182
break;
8283
}
83-
// _control.FindForm().ResumeLayout();
84+
if (_onAnimationEnd_del != null)
85+
_onAnimationEnd_del.Invoke(_control);
8486
}
8587
else Debug.WriteLine("Animator_WOC CONTROL IS EQUAL TO NULL!!!!!!!!!!!!!!!!!!!!!!");
8688
if (_onAnimationTick_del != null)
@@ -100,20 +102,27 @@ public Animations Animation
100102
set { _animation = value; }
101103
}
102104

105+
public bool CheckMonitorFps
106+
{
107+
get { return _animatorTimer != null ? _animatorTimer.CheckMonitorFps : false; }
108+
set
109+
{
110+
if (_animatorTimer != null)
111+
_animatorTimer.CheckMonitorFps = value;
112+
}
113+
}
114+
103115

104116
public Control Controls
105117
{
106118
get { return _control; }
107-
set { _control = value;
119+
set
120+
{
121+
_control = value;
108122
_animatorTimer = new AnimatorTimer_WOC(_control);
109123
_animatorTimer.onAnimationTimerTick += animationTimer_Tick;
110124
}
111125
}
112-
113-
public int Delay
114-
{
115-
get { return (int)_animatorTimer.Interval; }
116-
}
117126
}
118127
}
119128

0 commit comments

Comments
 (0)