private static PointKeyFrame CreatePointKeyFrmas(KeyFrames <Point> Model) { PointKeyFrame frame = null; switch (Model.Type) { case KeyFramesType.Spline: frame = new SplinePointKeyFrame() { KeySpline = Model.Spline }; break; case KeyFramesType.Linear: frame = new LinearPointKeyFrame(); break; case KeyFramesType.Easing: frame = new EasingPointKeyFrame() { EasingFunction = Model.EasingFunction }; break; case KeyFramesType.Discrete: frame = new DiscretePointKeyFrame(); break; default: break; } frame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(Model.KeyTime)); frame.Value = Model.Value; return(frame); }
public static PointAnimationUsingKeyFrames AddDiscreteKeyFrame( this PointAnimationUsingKeyFrames animation, double seconds, Point value) { var keyFrame = new DiscretePointKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(seconds)), Value = value, }; animation.KeyFrames.Add(keyFrame); #if NETFX_CORE || WINDOWS_81_PORTABLE animation.EnableDependentAnimation = true; #endif return(animation); }
public void MakeRadialAnimation(FrameworkElement animatedElement, TimeSpan timeSpan, string interactionID) { _interactionId = interactionID; _height = animatedElement.Height; _width = animatedElement.Width; double steps = 2 * (_height + _width); double tickTime = timeSpan.TotalSeconds / steps; string topCentre = Convert.ToString(_width / 2) + ",0"; string centre = Convert.ToString(_width / 2) + "," + Convert.ToString(_height / 2); frameworkElement = animatedElement; PathGeometry1 = new PathGeometry(); //Path1.Data = PathGeometry1; PathFigure1 = new PathFigure(); PathFigure1.StartPoint = ((Point) new PointConverter().ConvertFromString(centre)); PathGeometry1.Figures.Add(PathFigure1); LineSegment LineSegmentdummy = new LineSegment(); LineSegmentdummy.Point = ((Point) new PointConverter().ConvertFromString(topCentre)); PathFigure1.Segments.Add(LineSegmentdummy); LineSegmentseconcorner = new LineSegment(); LineSegmentseconcorner.Point = ((Point) new PointConverter().ConvertFromString(topCentre)); PathFigure1.Segments.Add(LineSegmentseconcorner); LineSegmentThirdcorner = new LineSegment(); LineSegmentThirdcorner.Point = ((Point) new PointConverter().ConvertFromString(topCentre)); PathFigure1.Segments.Add(LineSegmentThirdcorner); LineSegmentFourthcorner = new LineSegment(); LineSegmentFourthcorner.Point = ((Point) new PointConverter().ConvertFromString(topCentre)); PathFigure1.Segments.Add(LineSegmentFourthcorner); LineSegmentFirstcorner = new LineSegment(); LineSegmentFirstcorner.Point = ((Point) new PointConverter().ConvertFromString(topCentre)); PathFigure1.Segments.Add(LineSegmentFirstcorner); LineSegment2 = new LineSegment(); LineSegment2.Point = ((Point) new PointConverter().ConvertFromString(topCentre)); PathFigure1.Segments.Add(LineSegment2); frameworkElement.Clip = PathGeometry1; PointAnimationUsingKeyFrames pointAnimationUsingKeyFrames = new PointAnimationUsingKeyFrames(); DiscretePointKeyFrame discretePointKeyFrame = new DiscretePointKeyFrame(); discretePointKeyFrame.Value = new Point(0, 0); TimeSpan keyTime = new TimeSpan(0, 0, 1); discretePointKeyFrame.KeyTime = keyTime; _timer = new DispatcherTimer(); _timer.Interval = TimeSpan.FromSeconds(tickTime); _timer.Tick += new EventHandler(_timer_Tick); _timer.IsEnabled = true; }