Esempio n. 1
0
        /// <summary>
        /// Create PointAnimation
        /// </summary>
        /// <param name="parentObj">Storyboard parent object</param>
        /// <param name="target">Animation target object</param>
        /// <param name="property">Property path to animate</param>
        /// <param name="beginTime">Animation begin time</param>
        /// <param name="frameTime">Frame time collection</param>
        /// <param name="values">Target value collection</param>
        /// <param name="splines">List of KeySpline</param>
        /// <returns>PointAnimationUsingKeyFrames</returns>
        internal static PointAnimationUsingKeyFrames CreatePointAnimation(FrameworkElement parentObj, DependencyObject target, String property, Double beginTime, DoubleCollection frameTime, PointCollection values, List<KeySpline> splines)
        {
            PointAnimationUsingKeyFrames da = new PointAnimationUsingKeyFrames();
            
#if WPF
            target.SetValue(FrameworkElement.NameProperty, target.GetType().Name + Guid.NewGuid().ToString().Replace('-', '_'));
            Storyboard.SetTargetName(da, target.GetValue(FrameworkElement.NameProperty).ToString());

            (parentObj as ObservableObject).Chart._rootElement.RegisterName((string)target.GetValue(FrameworkElement.NameProperty), target);
#else


            Storyboard.SetTarget(da, target);
#endif
            Storyboard.SetTargetProperty(da, new PropertyPath(property));

            da.BeginTime = TimeSpan.FromSeconds(beginTime);

            for (Int32 index = 0; index < values.Count; index++)
            {
                SplinePointKeyFrame keyFrame = new SplinePointKeyFrame();
                
                if (splines != null)
                    keyFrame.KeySpline = splines[index];

                keyFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(frameTime[index]));
                keyFrame.Value = values[index];
                da.KeyFrames.Add(keyFrame);
            }

            return da;
        }
Esempio n. 2
0
        /// <summary>
        /// CreatePointAnimation
        /// </summary>
        /// <param name="target">Target object to animate</param>
        /// <param name="property">Property to animate</param>
        /// <param name="beginTime">Animation begin time</param>
        /// <param name="frameTimes">Animation frame times</param>
        /// <param name="values">List of values</param>
        /// <param name="splines">List of animation splines</param>
        /// <returns>PointAnimationUsingKeyFrames</returns>
        private static PointAnimationUsingKeyFrames CreatePointAnimation(DataSeries currentDataSeries, DataPoint currentDataPoint, DependencyObject target, String property, Double beginTime, List<Double> frameTimes, List<Point> values, List<KeySpline> splines)
        {
            PointAnimationUsingKeyFrames da = new PointAnimationUsingKeyFrames();
#if WPF
            target.SetValue(FrameworkElement.NameProperty, target.GetType().Name +  Guid.NewGuid().ToString().Replace('-', '_'));
            Storyboard.SetTargetName(da, target.GetValue(FrameworkElement.NameProperty).ToString());

            currentDataSeries.Chart._rootElement.RegisterName((string)target.GetValue(FrameworkElement.NameProperty), target);
            currentDataPoint.Chart._rootElement.RegisterName((string)target.GetValue(FrameworkElement.NameProperty), target);
#else
            Storyboard.SetTarget(da, target);
#endif
            Storyboard.SetTargetProperty(da, new PropertyPath(property));

            da.BeginTime = TimeSpan.FromSeconds(beginTime);

            for (Int32 index = 0; index < splines.Count; index++)
            {
                SplinePointKeyFrame keyFrame = new SplinePointKeyFrame();
                keyFrame.KeySpline = splines[index];
                keyFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(frameTimes[index]));
                keyFrame.Value = values[index];
                da.KeyFrames.Add(keyFrame);
            }

            return da;
        }
Esempio n. 3
0
        private static void AnimateImage(MultiScaleSubImage currentImage, Point futurePosition, Storyboard _moveStoryboard)
        {
            // Create Keyframe
            SplinePointKeyFrame endKeyframe = new SplinePointKeyFrame();
            endKeyframe.Value = futurePosition;
            endKeyframe.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1));

            KeySpline ks = new KeySpline();
            ks.ControlPoint1 = new Point(0, 1);
            ks.ControlPoint2 = new Point(1, 1);
            endKeyframe.KeySpline = ks;

            // Create Animation
            PointAnimationUsingKeyFrames moveAnimation = new PointAnimationUsingKeyFrames();
            moveAnimation.KeyFrames.Add(endKeyframe);

            Storyboard.SetTarget(moveAnimation, currentImage);
            Storyboard.SetTargetProperty(moveAnimation, new PropertyPath("ViewportOrigin"));

            _moveStoryboard.Children.Add(moveAnimation);
        }