private static ColorKeyFrame CreateColorKeyFrmas(KeyFrames<Color> Model) { ColorKeyFrame frame = null; switch (Model.Type) { case KeyFramesType.Spline: frame = new SplineColorKeyFrame() { KeySpline = Model.Spline }; break; case KeyFramesType.Linear: frame = new LinearColorKeyFrame(); break; case KeyFramesType.Easing: frame = new EasingColorKeyFrame() { EasingFunction = Model.EasingFunction }; break; case KeyFramesType.Discrete: frame = new DiscreteColorKeyFrame(); break; default: break; } frame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(Model.KeyTime)); frame.Value = Model.Value; return frame; }
private ColorAnimationUsingKeyFrames getColorAnimationFrames(Color firstColor, Color secondColor) { ColorAnimationUsingKeyFrames animationFrames = new ColorAnimationUsingKeyFrames(); for (int i = 1; i < 6; i++) { if (i % 2 == 0) { DiscreteColorKeyFrame frame=new DiscreteColorKeyFrame(); frame.KeyTime=new TimeSpan(0,0,0,0,i*250); frame.Value=firstColor; animationFrames.KeyFrames.Add(frame); } else { DiscreteColorKeyFrame frame = new DiscreteColorKeyFrame(); frame.KeyTime = new TimeSpan(0, 0, 0, 0, i * 250); frame.Value = secondColor; animationFrames.KeyFrames.Add(frame); } } return animationFrames; }