Exemple #1
0
        // ====================
        // SATURATE
        // ====================

        internal static void SaturateTo(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
                                   animGroup.CreateEffectAnimation <SaturateAnimation, double>(
                                       element,
                                       settings,
                                       to: settings.Saturation));
        }
Exemple #2
0
        // ====================
        // TINT
        // ====================

        internal static void TintTo(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
                                   animGroup.CreateEffectAnimation <TintAnimation, Color>(
                                       element,
                                       settings,
                                       to: settings.Tint));
        }
Exemple #3
0
 internal static void ScaleYTo(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
 {
     group.CreateAnimations(element, settings,
                            animGroup =>
                            animGroup.CreateScalarAnimation <ScaleYAnimation>(
                                element,
                                settings,
                                to: (float)settings.ScaleY));
 }
Exemple #4
0
        // ====================
        // ROTATE
        // ====================

        internal static void RotateTo(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
                                   animGroup.CreateScalarAnimation <RotateAnimation>(
                                       element,
                                       settings,
                                       to: settings.Rotation));
        }
 internal static void SwivelYTo(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
 {
     group.CreateAnimations(element, settings,
                            animGroup =>
                            animGroup.CreatePerspectiveAnimation <SwivelYAnimation>(
                                element,
                                settings,
                                to: settings.SwivelY));
 }
Exemple #6
0
 internal static void TranslateZTo(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
 {
     group.CreateAnimations(element, settings,
                            animGroup =>
                            animGroup.CreateScalarAnimation <TranslateZAnimation>(
                                element,
                                settings,
                                to: (float)settings.OffsetZ));
 }
Exemple #7
0
 internal static void TranslateYTo(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
 {
     group.CreateAnimations(element, settings,
                            animGroup =>
                            animGroup.CreateScalarAnimation <TranslateYAnimation>(
                                element,
                                settings,
                                to: settings.OffsetY.GetCalculatedOffset(element, OffsetTarget.Y)));
 }
Exemple #8
0
        // ====================
        // BLUR
        // ====================

        internal static void BlurTo(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
                                   animGroup.CreateEffectAnimation <BlurAnimation, double>(
                                       element,
                                       settings,
                                       to: settings.BlurRadius));
        }
Exemple #9
0
        internal static void FadeFrom(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
            {
                ElementCompositionPreview.GetElementVisual(element).Opacity = (float)settings.Opacity;

                return(animGroup.CreateScalarAnimation <FadeAnimation>(
                           element,
                           settings,
                           to: 1));
            });
        }
        internal static void RotateFrom(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
            {
                var visual = ElementCompositionPreview.GetElementVisual(element);

                visual.RotationAngleInDegrees = (float)settings.Rotation;

                return(animGroup.CreateScalarAnimation <RotateAnimation>(
                           element,
                           settings,
                           to: 0));
            });
        }
        internal static void ScaleZFrom(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
            {
                var visual = ElementCompositionPreview.GetElementVisual(element);

                visual.Scale = new Vector3(visual.Scale.X, visual.Scale.Y, (float)settings.ScaleZ);

                return(animGroup.CreateScalarAnimation <ScaleZAnimation>(
                           element,
                           settings,
                           to: 1f));
            });
        }
Exemple #12
0
        internal static void TintFrom(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
            {
                animGroup.CreateEffectAnimation <TintAnimation, Color>(
                    element,
                    settings,
                    to: settings.Tint,
                    duration: 1,
                    isFrom: true);

                return(animGroup.CreateEffectAnimation <TintAnimation, Color>(
                           element,
                           settings,
                           to: AnimationSettings.DEFAULT_TINT));
            });
        }
Exemple #13
0
        internal static void SaturateFrom(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
            {
                animGroup.CreateEffectAnimation <SaturateAnimation, double>(
                    element,
                    settings,
                    to: settings.Saturation,
                    duration: 1,
                    isFrom: true);

                return(animGroup.CreateEffectAnimation <SaturateAnimation, double>(
                           element,
                           settings,
                           to: AnimationSettings.DEFAULT_SATURATION));
            });
        }
Exemple #14
0
        internal static void BlurFrom(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
            {
                animGroup.CreateEffectAnimation <BlurAnimation, double>(
                    element,
                    settings,
                    to: settings.BlurRadius,
                    duration: 1,
                    isFrom: true);

                return(animGroup.CreateEffectAnimation <BlurAnimation, double>(
                           element,
                           settings,
                           to: 0));
            });
        }
        internal static void FadeFrom(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
            {
                animGroup.CreateScalarAnimation <FadeAnimation>(
                    element,
                    settings,
                    to: settings.Opacity,
                    duration: 1,
                    isFrom: true);

                return(animGroup.CreateScalarAnimation <FadeAnimation>(
                           element,
                           settings,
                           to: 1));
            });
        }
        internal static void TranslateXFrom(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
            {
                animGroup.CreateScalarAnimation <TranslateXAnimation>(
                    element,
                    settings,
                    to: (float)settings.OffsetX,
                    duration: 1,
                    isFrom: true);

                return(animGroup.CreateScalarAnimation <TranslateXAnimation>(
                           element,
                           settings,
                           to: 0f));
            });
        }
        internal static void ScaleZFrom(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
            {
                animGroup.CreateScalarAnimation <ScaleZAnimation>(
                    element,
                    settings,
                    to: (float)settings.ScaleZ,
                    duration: 1,
                    isFrom: true);

                return(animGroup.CreateScalarAnimation <ScaleZAnimation>(
                           element,
                           settings,
                           to: 1f));
            });
        }
        internal static void SwivelYFrom(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
            {
                var visual = ElementCompositionPreview.GetElementVisual(element);

                animGroup.CreatePerspectiveAnimation <SwivelYAnimation>(
                    element,
                    settings,
                    to: settings.SwivelY,
                    duration: 1,
                    isFrom: true);

                return(animGroup.CreatePerspectiveAnimation <SwivelYAnimation>(
                           element,
                           settings,
                           to: 0));
            });
        }
Exemple #19
0
        internal static void TranslateXFrom(this FrameworkElement element, AnimationSettings settings, ref AnimationGroup group)
        {
            group.CreateAnimations(element, settings,
                                   animGroup =>
            {
                var visual = ElementCompositionPreview.GetElementVisual(element);

                // Since Translation doesn't exist as a property on Visual, we try to fetch it from the PropertySet
                if (visual.Properties.TryGetVector3(TargetProperties.Translation, out var translation) == CompositionGetValueStatus.Succeeded)
                {
                    visual.Properties.InsertVector3(TargetProperties.Translation, new Vector3((float)settings.OffsetX.GetCalculatedOffset(element, OffsetTarget.X), translation.Y, translation.Z));
                }
                else
                {
                    visual.Properties.InsertVector3(TargetProperties.Translation, new Vector3((float)settings.OffsetX.GetCalculatedOffset(element, OffsetTarget.X), 0f, 0f));
                }

                return(animGroup.CreateScalarAnimation <TranslateXAnimation>(
                           element,
                           settings,
                           to: 0f));
            });
        }