/// <summary> /// Sets the duration of the animation. /// </summary> /// <param name="duration"></param> /// <param name="timeType"></param> /// <returns></returns> public virtual IAnimator For(double duration, OrSo timeType) { _duration = new Duration(GetTimeSpan(duration, timeType)); _durationDefined = true; return(this); }
protected TimeSpan GetTimeSpan(double duration, OrSo timeType) { switch (timeType) { case OrSo.Ticks: return(TimeSpan.FromTicks((long)duration)); case OrSo.Seconds: return(TimeSpan.FromSeconds(duration)); default: throw new Exception("Improper time type specified"); } }
/// <summary> /// <para>Executes the user code after a specified duration.</para> /// <para>Note: This method produces a working EventToken</para> /// </summary> /// <param name="duration"></param> /// <param name="timeType"></param> /// <returns>A token representing the animation</returns> public override EventToken After(double duration, OrSo timeType) { DispatcherTimer timer = new DispatcherTimer(); EventToken placeholder = EventToken.PlaceholderToken(); timer.Interval = GetTimeSpan(duration, timeType); timer.Tick += (s, e) => { timer.Stop(); placeholder.PassOn(Now()); }; timer.Start(); return placeholder; }
/// <summary> /// <para>Executes the user code after a specified duration.</para> /// <para>Note: This method produces a working EventToken</para> /// </summary> /// <param name="duration"></param> /// <param name="timeType"></param> /// <returns>A token representing the animation</returns> public override EventToken After(double duration, OrSo timeType) { DispatcherTimer timer = new DispatcherTimer(); EventToken placeholder = EventToken.PlaceholderToken(); timer.Interval = GetTimeSpan(duration, timeType); timer.Tick += (s, e) => { timer.Stop(); placeholder.PassOn(Now()); }; timer.Start(); return(placeholder); }
/// <summary> /// Executes the animation after a specified duration after the animation represented by the specified token. /// </summary> /// <param name="token"></param> /// <param name="duration"></param> /// <param name="timeType"></param> /// <returns>A token representing the animation</returns> public virtual EventToken After(EventToken token, double duration, OrSo timeType) { if (_storyboard == null) { CreateStoryboard(); } _storyboard.AutoReverse = _reverse; token.AddChildAnimator(this, GetTimeSpan(duration, timeType)); if (_eventToken == null) { _eventToken = new EventToken(_animation, _storyboard); } return(_eventToken); }
/// <summary> /// Executes the animation after a specified duration. /// </summary> /// <param name="duration"></param> /// <param name="timeType"></param> /// <returns>A token representing the animation</returns> public virtual EventToken After(double duration, OrSo timeType) { if (_storyboard == null) { CreateStoryboard(); } _animation.BeginTime = GetTimeSpan(duration, timeType); _storyboard.AutoReverse = _reverse; _storyboard.Begin(); if (_eventToken == null) { _eventToken = new EventToken(_animation, _storyboard); } return _eventToken; }
/// <summary> /// Executes the animation after a specified duration. /// </summary> /// <param name="duration"></param> /// <param name="timeType"></param> /// <returns>A token representing the animation</returns> public virtual EventToken After(double duration, OrSo timeType) { if (_storyboard == null) { CreateStoryboard(); } _animation.BeginTime = GetTimeSpan(duration, timeType); _storyboard.AutoReverse = _reverse; _storyboard.Begin(); if (_eventToken == null) { _eventToken = new EventToken(_animation, _storyboard); } return(_eventToken); }
/// <summary> /// <para>Executes the user code a specified duration after /// the animation represented by the specified token.</para> /// <para>Note: This method produces a working EventToken</para> /// </summary> /// <param name="token"></param> /// <param name="duration"></param> /// <param name="timeType"></param> /// <returns>A token representing the animation</returns> public override EventToken After(EventToken token, double duration, OrSo timeType) { EventToken placeholder = EventToken.PlaceholderToken(); // Separate the delay into stages // Use another CodeAnimator to trigger the timer after // the original animation var afterTokenAnimator = new CodeAnimator(() => { DispatcherTimer timer = new DispatcherTimer(); timer.Interval = GetTimeSpan(duration, timeType); timer.Tick += (s, e) => { timer.Stop(); placeholder.PassOn(Now()); }; timer.Start(); }); afterTokenAnimator.After(token); return(placeholder); }
/// <summary> /// Executes the animation after a specified duration after the animation represented by the specified token. /// </summary> /// <param name="token"></param> /// <param name="duration"></param> /// <param name="timeType"></param> /// <returns>A token representing the animation</returns> public virtual EventToken After(EventToken token, double duration, OrSo timeType) { if (_storyboard == null) { CreateStoryboard(); } _storyboard.AutoReverse = _reverse; token.AddChildAnimator(this, GetTimeSpan(duration, timeType)); if (_eventToken == null) { _eventToken = new EventToken(_animation, _storyboard); } return _eventToken; }
protected TimeSpan GetTimeSpan(double duration, OrSo timeType) { switch (timeType) { case OrSo.Ticks: return TimeSpan.FromTicks((long)duration); case OrSo.Seconds: return TimeSpan.FromSeconds(duration); default: throw new Exception("Improper time type specified"); } }
/// <summary> /// Sets the duration of the animation. /// </summary> /// <param name="duration"></param> /// <param name="timeType"></param> /// <returns></returns> public virtual IAnimator For(double duration, OrSo timeType) { _duration = new Duration(GetTimeSpan(duration, timeType)); _durationDefined = true; return this; }
/// <summary> /// <para>Executes the user code a specified duration after /// the animation represented by the specified token.</para> /// <para>Note: This method produces a working EventToken</para> /// </summary> /// <param name="token"></param> /// <param name="duration"></param> /// <param name="timeType"></param> /// <returns>A token representing the animation</returns> public override EventToken After(EventToken token, double duration, OrSo timeType) { EventToken placeholder = EventToken.PlaceholderToken(); // Separate the delay into stages // Use another CodeAnimator to trigger the timer after // the original animation var afterTokenAnimator = new CodeAnimator(() => { DispatcherTimer timer = new DispatcherTimer(); timer.Interval = GetTimeSpan(duration, timeType); timer.Tick += (s, e) => { timer.Stop(); placeholder.PassOn(Now()); }; timer.Start(); }); afterTokenAnimator.After(token); return placeholder; }
/// <summary> /// Dummy method. Does nothing. /// </summary> /// <param name="duration"></param> /// <param name="timeType"></param> /// <returns></returns> public override IAnimator For(double duration, OrSo timeType) { return this; }
/// <summary> /// Dummy method. Does nothing. /// </summary> /// <param name="duration"></param> /// <param name="timeType"></param> /// <returns></returns> public override IAnimator For(double duration, OrSo timeType) { return(this); }