Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public void CreateReversal(double startTime, Button btn, BitmapImage background)
        {
            var chgBg = new ObjectAnimationUsingKeyFrames();
            DiscreteObjectKeyFrame dk = new DiscreteObjectKeyFrame(background);

            dk.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(startTime + 0.5));
            dk.Value   = background;
            chgBg.KeyFrames.Add(dk);
            Storyboard.SetTargetName(chgBg, btn.Name);
            DependencyProperty[] propertyChain2 = new DependencyProperty[]
            {
                Button.BackgroundProperty,
                ImageBrush.ImageSourceProperty
            };
            Storyboard.SetTargetProperty(chgBg, new PropertyPath("(0).(1)", propertyChain2));

            var transformOrigin     = new PointAnimationUsingKeyFrames();
            EasingPointKeyFrame kf1 = new EasingPointKeyFrame(new System.Windows.Point(0.5, 0), KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)));
            EasingPointKeyFrame kf2 = new EasingPointKeyFrame(new System.Windows.Point(0.5, 0), KeyTime.FromTimeSpan(TimeSpan.FromSeconds(startTime)));
            EasingPointKeyFrame kf3 = new EasingPointKeyFrame(new System.Windows.Point(0.5, 0.5), KeyTime.FromTimeSpan(TimeSpan.FromSeconds(startTime + 1)));

            transformOrigin.KeyFrames.Add(kf1);
            transformOrigin.KeyFrames.Add(kf2);
            transformOrigin.KeyFrames.Add(kf3);
            Storyboard.SetTargetName(transformOrigin, btn.Name);
            DependencyProperty[] propertyChain1 = new DependencyProperty[]
            {
                Button.RenderTransformOriginProperty
            };
            Storyboard.SetTargetProperty(transformOrigin, new PropertyPath(Control.RenderTransformOriginProperty));

            var d_transform          = new DoubleAnimationUsingKeyFrames();
            EasingDoubleKeyFrame kf4 = new EasingDoubleKeyFrame(-1, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)));
            EasingDoubleKeyFrame kf5 = new EasingDoubleKeyFrame(-1, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(startTime)));
            EasingDoubleKeyFrame kf6 = new EasingDoubleKeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(startTime + 1)));

            d_transform.KeyFrames.Add(kf4);
            d_transform.KeyFrames.Add(kf5);
            d_transform.KeyFrames.Add(kf6);
            Storyboard.SetTargetName(d_transform, btn.Name);
            DependencyProperty[] propertyChain3 = new DependencyProperty[]
            {
                Control.RenderTransformProperty,
                TransformGroup.ChildrenProperty,
                ScaleTransform.ScaleXProperty
            };
            Storyboard.SetTargetProperty(d_transform, new PropertyPath("(0).(1)[0].(2)", propertyChain3));

            reversalSB.Children.Add(transformOrigin);
            reversalSB.Children.Add(d_transform);
            reversalSB.Children.Add(chgBg);
        }
Esempio n. 3
0
        public override void CreateStoryboard()
        {
            PointAnimationUsingKeyFrames dau = new PointAnimationUsingKeyFrames();

            EasingPointKeyFrame fromk = null;

            if (FromPoint.HasValue)
            {
                fromk = new EasingPointKeyFrame(FromPoint.Value, TimeSpan.FromMilliseconds(AniTime(0)));
                dau.KeyFrames.Add(fromk);
            }

            EasingPointKeyFrame tok = null;

            if (ToPoint.HasValue)
            {
                tok = new EasingPointKeyFrame(ToPoint.Value, TimeSpan.FromMilliseconds(AniTime(1)));
                dau.KeyFrames.Add(tok);
            }


            if (AniEasingFunction != null)
            {
                if (fromk != null)
                {
                    fromk.EasingFunction = AniEasingFunction;
                }
                if (tok != null)
                {
                    tok.EasingFunction = AniEasingFunction;
                }
            }
            else if (CirDefault != null)
            {
                if (fromk != null)
                {
                    fromk.EasingFunction = CirDefault;
                }
                if (tok != null)
                {
                    tok.EasingFunction = CirDefault;
                }
            }

            Storyboard.SetTarget(dau, Element);
            Storyboard.SetTargetProperty(dau, AniPropertyPath);
            Story.Children.Add(dau);
        }
        public static PointAnimationUsingKeyFrames AddEasingKeyFrame(
            this PointAnimationUsingKeyFrames animation,
            double seconds, Point value,
            EasingFunctionBase easingFunction = null)
        {
            var keyFrame = new EasingPointKeyFrame
            {
                KeyTime        = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(seconds)),
                Value          = value,
                EasingFunction = easingFunction
            };

            animation.KeyFrames.Add(keyFrame);
#if NETFX_CORE || WINDOWS_81_PORTABLE
            animation.EnableDependentAnimation = true;
#endif
            return(animation);
        }