Skip to content

Commit

Permalink
added onStart/onEnd animation delegates and added way to disable auto…
Browse files Browse the repository at this point in the history
…detect monitor refresh rate
  • Loading branch information
WithoutCaps committed Jun 22, 2017
1 parent 79055a4 commit 111022f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
22 changes: 16 additions & 6 deletions LimitlessUI/AnimatorTimer_WOC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ public class AnimatorTimer_WOC

private int _interval;
private int _neededValue;
private int _animationFps = 30;
private float _progress;
private float _speed = 0;

private AutoResetEvent reset = new AutoResetEvent(false);
private Control _invokeControl;

private bool _checkFps = false;

public AnimatorTimer_WOC(Control control)
{
Expand All @@ -63,13 +64,13 @@ public AnimatorTimer_WOC(Control control)
int frequency = Utils_WOC.getMonitorFrequency();
_displayRefreshRate = frequency != -1 ? frequency : 60;
}
_interval = (int)Math.Round(1000 / _displayRefreshRate);
_interval = 1000 / _animationFps;
}

public void start()
{
Enabled = true;

new Thread(() =>
{
while (_isEnabled)
Expand Down Expand Up @@ -105,7 +106,7 @@ public void setValueRange(int neededProgress, Int32 progress, int milis, bool st
{
if (!Enabled)
{
_speed = (neededProgress - _progress) / (milis / (1000 / _displayRefreshRate));
_speed = (neededProgress - _progress) / (milis / (1000 / _animationFps));
_progress = progress;
}

Expand All @@ -116,7 +117,7 @@ public void setValueRange(int neededProgress, int milis, bool start)
{
if (!Enabled)
{
float a = (milis / (1000 / _displayRefreshRate));
float a = (milis / (1000 / _animationFps));
float b = (neededProgress - _progress);
_speed = (b / a);
}
Expand All @@ -139,6 +140,15 @@ public bool Enabled
get { return _isEnabled; }
set { _isEnabled = value; }
}
public int Interval { get { return _interval; } }

public bool CheckMonitorFps
{
get { return _checkFps; }
set
{
_checkFps = value;
_animationFps = _checkFps ? (int)_displayRefreshRate : 30;
}
}
}
}
27 changes: 18 additions & 9 deletions LimitlessUI/Animator_WOC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ public enum Animations

public Animator_WOC()
{


}
private void animationTimer_Tick(int progress)
{
if (_control != null)
{
// _control.FindForm().SuspendLayout();
if (_onAnimationStart_del != null)
_onAnimationStart_del.Invoke(_control);

switch (_animation)
{
Expand All @@ -80,7 +81,8 @@ private void animationTimer_Tick(int progress)
_onHeightChanged_del.Invoke(_control, _animatorTimer.Speed, progress);
break;
}
// _control.FindForm().ResumeLayout();
if (_onAnimationEnd_del != null)
_onAnimationEnd_del.Invoke(_control);
}
else Debug.WriteLine("Animator_WOC CONTROL IS EQUAL TO NULL!!!!!!!!!!!!!!!!!!!!!!");
if (_onAnimationTick_del != null)
Expand All @@ -100,20 +102,27 @@ public Animations Animation
set { _animation = value; }
}

public bool CheckMonitorFps
{
get { return _animatorTimer != null ? _animatorTimer.CheckMonitorFps : false; }
set
{
if (_animatorTimer != null)
_animatorTimer.CheckMonitorFps = value;
}
}


public Control Controls
{
get { return _control; }
set { _control = value;
set
{
_control = value;
_animatorTimer = new AnimatorTimer_WOC(_control);
_animatorTimer.onAnimationTimerTick += animationTimer_Tick;
}
}

public int Delay
{
get { return (int)_animatorTimer.Interval; }
}
}
}

0 comments on commit 111022f

Please sign in to comment.