public GUIAnimation(GUIAnimation a) : base(a._parentControlId, a._controlId, a._positionX, a._positionY, a._width, a._height) { _animating = false; _isFirstRender = true; _iterationCount = 0; _startTick = 0; _hidePngAnimations = false; _triggerList = a._triggerList.GetRange(0, a._triggerList.Count); _easing = a._easing; _fillBehavior = a._fillBehavior; _horizontalAlignment = a._horizontalAlignment; _textureNames = a._textureNames; _rate = a._rate; _duration = a._duration; _repeatBehavior = a._repeatBehavior; _verticalAlignment = a._verticalAlignment; _triggerNames = a._triggerNames; InitTriggerList(); }
public static PlotElementAnimation CreateAnimation(AnimationTransform transform, AnimationOrigin origin, Easing easing, bool indexDelay) { var sb = new Storyboard(); var duration = new Duration(TimeSpan.FromSeconds(0.5)); var style = new Style(); style.TargetType = typeof(PlotElement); style.Setters.Add(new Setter(PlotElement.OpacityProperty, 0.0)); if (transform == AnimationTransform.Scale) style.Setters.Add(new Setter(PlotElement.RenderTransformProperty, new ScaleTransform() { ScaleX = 0, ScaleY = 0 })); else if (transform == AnimationTransform.Rotation) style.Setters.Add(new Setter(PlotElement.RenderTransformProperty, new RotateTransform() { Angle = 180 })); var point = new Point(0.5, 0.5); switch (origin) { case AnimationOrigin.Bottom: point = new Point(0.5, 2); break; case AnimationOrigin.Top: point = new Point(0.5, -2); break; case AnimationOrigin.Left: point = new Point(-2, 0.5); break; case AnimationOrigin.Right: point = new Point(2, 0.5); break; case AnimationOrigin.TopLeft: point = new Point(2, -2); break; case AnimationOrigin.TopRight: point = new Point(-2, -2); break; case AnimationOrigin.BottomLeft: point = new Point(2, 2); break; case AnimationOrigin.BottomRight: point = new Point(-2, 2); break; default: break; } style.Setters.Add(new Setter(PlotElement.RenderTransformOriginProperty, point)); var da = new DoubleAnimation() { From = 0, To = 1, Duration = duration }; Storyboard.SetTargetProperty(da, new PropertyPath("Opacity")); sb.Children.Add(da); if (transform == AnimationTransform.Scale) { var da2 = new DoubleAnimation() { From = 0, To = 1, Duration = duration }; Storyboard.SetTargetProperty(da2, new PropertyPath("(RenderTransform).ScaleX")); var da3 = new DoubleAnimation() { From = 0, To = 1, Duration = duration }; Storyboard.SetTargetProperty(da3, new PropertyPath("(RenderTransform).ScaleY")); sb.Children.Add(da2); sb.Children.Add(da3); } else if (transform == AnimationTransform.Rotation) { var da2 = new DoubleAnimation() { To = 0, Duration = duration }; Storyboard.SetTargetProperty(da2, new PropertyPath("(RenderTransform).Angle")); sb.Children.Add(da2); } if (indexDelay) { foreach (var anim in sb.Children) PlotElementAnimation.SetIndexDelay(anim, 0.5); } #if CLR40 if (easing != Easing.None) { IEasingFunction ef = null; switch (easing) { case Easing.BackEase: ef = new BackEase(); break; case Easing.BounceEase: ef = new BounceEase(); break; case Easing.CircleEase: ef = new CircleEase(); break; case Easing.CubicEase: ef = new CubicEase(); break; case Easing.ElasticEase: ef = new ElasticEase(); break; case Easing.ExponentialEase: ef = new ExponentialEase(); break; case Easing.PowerEase: ef = new PowerEase(); break; case Easing.QuadraticEase: ef = new QuadraticEase(); break; case Easing.QuarticEase: ef = new QuarticEase(); break; case Easing.QuinticEase: ef = new QuinticEase(); break; case Easing.SineEase: ef = new SineEase(); break; default: break; } foreach (DoubleAnimation anim in sb.Children) anim.EasingFunction = ef; } #endif return new PlotElementAnimation() { Storyboard = sb, SymbolStyle = style }; }