/// <summary> /// Updates the slide animation. /// </summary> /// <param name="control">The control for which the animation needs to be updated.</param> /// <param name="storyboard">Storyvoard that needs to be updated.</param> /// <param name="target">The targeted element of the animation.</param> /// <param name="args"></param> /// <remarks> /// Currently the method sets the SpeedRatio of the storyboard to /// the global <strong>AnimationSpeedRatio</strong> if the local SpeedRatio is null. /// If the local SpeedRatio value is set, it will be used. /// </remarks> protected override void UpdateAnimationOverride(FrameworkElement control, Storyboard storyboard, FrameworkElement target, params object[] args) { var orientation = this.Orientation; var slideMode = this.SlideMode; if (args.Length > 0 && args[0] is Orientation) { orientation = (Orientation)args[0]; } if (args.Length > 1 && args[1] is SlideMode) { slideMode = (SlideMode)args[1]; } var value = this.GetPixelsToAnimate(); var valueCoeficient = slideMode == SlideMode.Top ? -1 : 1; var fromValue = this.GetValueDependingOnDirection(value * valueCoeficient, 0.0); var endValue = this.GetValueDependingOnDirection(0.0, value * valueCoeficient); var delay = this.GetDelay(target); var duration = this.GetAnimationDuration() + delay; if (orientation == Orientation.Vertical) { storyboard.Update() .Animate(target) .SingleProperty(ClipStartXProperty, 0, 0, delay, 0, duration, 0) .SingleProperty(ClipStartYProperty, 0, -fromValue, delay, -fromValue, duration, -endValue) .Easings(this.GetEasing()) .MoveX(0, 0, delay, 0, duration, 0) .MoveY(0, fromValue, delay, fromValue, duration, endValue) .Easings(this.GetEasing()); } else { storyboard.Update() .Animate(target) .SingleProperty(ClipStartXProperty, 0, -fromValue, delay, -fromValue, duration, -endValue) .SingleProperty(ClipStartYProperty, 0, 0, delay, 0, duration, 0) .Easings(this.GetEasing()) .MoveX(0, fromValue, delay, fromValue, duration, endValue) .MoveY(0, 0, delay, 0, duration, 0) .Easings(this.GetEasing()); } ClipControlWhileAnimationIsRunning(target, storyboard); //DisableControlWhileAnimationIsRunning(target, storyboard); }
/// <summary> /// Updates the slide animation. /// </summary> /// <param name="control">The control for which the animation needs to be updated.</param> /// <param name="storyboard">Storyvoard that needs to be updated.</param> /// <param name="target">The targeted element of the animation.</param> /// <param name="args"></param> /// <remarks> /// Currently the method sets the SpeedRatio of the storyboard to /// the global <strong>AnimationSpeedRatio</strong> if the local SpeedRatio is null. /// If the local SpeedRatio value is set, it will be used. /// </remarks> protected override void UpdateAnimationOverride(FrameworkElement control, Storyboard storyboard, FrameworkElement target, params object[] args) { this.UpdateSlideMode(target, args); if (target.ActualHeight == 0) { // TODO: Discuss LayoutUpdate here. target.UpdateLayout(); } var value = target.ActualHeight; var nonZeroValue = this.SlideMode == SlideMode.Top ? 1.0 : -1.0; var relativeFrom = this.GetValueDependingOnDirection(nonZeroValue, 0.0); var relatoveTo = this.GetValueDependingOnDirection(0.0, nonZeroValue); value *= -1 * nonZeroValue; var fromValue = this.GetValueDependingOnDirection(value, 0.0); var endValue = this.GetValueDependingOnDirection(0.0, value); var duration = RadAnimation.GetDurationSecondsForLength(Math.Abs(value)); var splineToUse = this.GetValueDependingOnDirection(Easings.SlideDown1, Easings.SlideUp1); storyboard.Update() .Animate(target) .OpacityMaskRelativeMoveY(0, relativeFrom, duration, relatoveTo) .Easings(splineToUse) .MoveY(0, fromValue, duration, endValue) .Easings(splineToUse); DisableControlWhileAnimationIsRunning(target, storyboard); }
/// <summary> /// Updates the slide animation. /// </summary> /// <param name="control">The control for which the animation needs to be updated.</param> /// <param name="storyboard">Storyvoard that needs to be updated.</param> /// <param name="target">The targeted element of the animation.</param> /// <param name="args"></param> /// <remarks> /// Currently the method sets the SpeedRatio of the storyboard to /// the global <strong>AnimationSpeedRatio</strong> if the local SpeedRatio is null. /// If the local SpeedRatio value is set, it will be used. /// </remarks> protected override void UpdateAnimationOverride(FrameworkElement control, Storyboard storyboard, FrameworkElement target, params object[] args) { var relativeFrom = this.GetValueDependingOnDirection(this.MinOpacity, this.MaxOpacity); var relativeTo = this.GetValueDependingOnDirection(this.MaxOpacity, this.MinOpacity); var duration = RadAnimation.GetDurationSecondsForLength(200.0); storyboard.Update() .Animate(target) .Opacity(0, relativeFrom, duration, relativeTo) .Easings(this.Easing) .AdjustSpeed(); }
/// <summary> /// Updates the slide animation. /// </summary> /// <param name="control">The control for which the animation needs to be updated.</param> /// <param name="storyboard">Storyvoard that needs to be updated.</param> /// <param name="target">The targeted element of the animation.</param> /// <param name="args"></param> /// <remarks> /// Currently the method sets the SpeedRatio of the storyboard to /// the global <strong>AnimationSpeedRatio</strong> if the local SpeedRatio is null. /// If the local SpeedRatio value is set, it will be used. /// </remarks> protected override void UpdateAnimationOverride(FrameworkElement control, Storyboard storyboard, FrameworkElement target, params object[] args) { var relativeFrom = this.GetValueDependingOnDirection(this.MinScale, this.MaxScale); var relativeTo = this.GetValueDependingOnDirection(this.MaxScale, this.MinScale); var duration = RadAnimation.GetDurationSecondsForLength(100.0); storyboard.Update() .Animate(target) .EnsureDefaultTransforms() .ScaleX(0, relativeFrom, duration, relativeTo) .Easings(this.Easing) .ScaleY(0, relativeFrom, duration, relativeTo) .Easings(this.Easing) .AdjustSpeed(); }