Exemplo n.º 1
0
        protected override void OnConnected(UIElement targetElement)
        {
            if (targetElement == null)
            {
                return;
            }

            Compositor compositor = Window.Current.Compositor;

            // Create SpotLight and set its properties

            SpotLight spotLight = compositor.CreateSpotLight();

            spotLight.InnerConeColor = Colors.FloralWhite;
            spotLight.OuterConeColor = Colors.FloralWhite;

            spotLight.InnerConeAngleInDegrees = 0f;
            spotLight.InnerConeIntensity      = 4;
            //spotLight.OuterConeAngleInDegrees = 3f;

            spotLight.ConstantAttenuation  = 1f;
            spotLight.LinearAttenuation    = 0.253f;
            spotLight.QuadraticAttenuation = 0.58f;
            spotLight.Offset = new Vector3(0, 0, 0);

            // Associate CompositionLight with XamlLight
            this.CompositionLight = spotLight;

            // Define resting position Animation
            Vector3 restingPosition            = new Vector3(200, 200, 400);
            CubicBezierEasingFunction cbEasing = compositor.CreateCubicBezierEasingFunction(new Vector2(0.3f, 0.7f), new Vector2(0.9f, 0.5f));

            _offsetAnimation = compositor.CreateVector3KeyFrameAnimation();
            _offsetAnimation.InsertKeyFrame(1, restingPosition, cbEasing);
            _offsetAnimation.Duration = TimeSpan.FromSeconds(0.5f);

            //spotLight.Offset = restingPosition;

            // Define expression animation that relates light's offset to pointer position
            CompositionPropertySet hoverPosition = ElementCompositionPreview.GetPointerPositionPropertySet(targetElement);

            _lightPositionExpression = compositor.CreateExpressionAnimation("Vector3(hover.Position.X, hover.Position.Y, height)");
            _lightPositionExpression.SetReferenceParameter("hover", hoverPosition);
            _lightPositionExpression.SetScalarParameter("height", 150f);

            // Configure pointer entered/ exited events
            targetElement.PointerMoved  += TargetElement_PointerMoved;
            targetElement.PointerExited += TargetElement_PointerExited;

            // Add UIElement to the Light's Targets
            HoverLight.AddTargetElement(GetId(), targetElement);
            //MoveToRestingPosition();
        }
        XElement FromCubicBezierEasingFunction(CubicBezierEasingFunction obj)
        {
            return(new XElement(GetCompositionObjectName(obj), GetContents()));

            IEnumerable <XObject> GetContents()
            {
                foreach (var item in GetCompositionObjectContents(obj))
                {
                    yield return(item);
                }
            }
        }
Exemplo n.º 3
0
        public void StartEntranceEffect()
        {
            ContainerVisual container  = (ContainerVisual)ElementCompositionPreview.GetElementChildVisual(BasePage);
            Compositor      compositor = container.Compositor;

            // 设置缩放和动画
            const float               ScaleFactor = 20f;
            TimeSpan                  duration    = TimeSpan.FromMilliseconds(1200);
            LinearEasingFunction      linearEase  = compositor.CreateLinearEasingFunction();
            CubicBezierEasingFunction easeInOut   = compositor.CreateCubicBezierEasingFunction(new Vector2(.38f, 0f), new Vector2(.45f, 1f));

            // 创建淡出动画
            ScalarKeyFrameAnimation fadeOutAnimation = compositor.CreateScalarKeyFrameAnimation();

            fadeOutAnimation.InsertKeyFrame(1, 0);
            fadeOutAnimation.Duration = duration;

            // Grid的动画
            Vector2KeyFrameAnimation scaleUpGridAnimation = compositor.CreateVector2KeyFrameAnimation();

            scaleUpGridAnimation.InsertKeyFrame(0.1f, new Vector2(1 / ScaleFactor, 1 / ScaleFactor));
            scaleUpGridAnimation.InsertKeyFrame(1, new Vector2(1, 1));
            scaleUpGridAnimation.Duration = duration;

            // 初始屏动画
            Vector2KeyFrameAnimation scaleUpSplashAnimation = compositor.CreateVector2KeyFrameAnimation();

            scaleUpSplashAnimation.InsertKeyFrame(0, new Vector2(1, 1));
            scaleUpSplashAnimation.InsertKeyFrame(1, new Vector2(ScaleFactor, ScaleFactor));
            scaleUpSplashAnimation.Duration = duration;

            // 设置Grid的中心缩放视觉
            Visual gridVisual = ElementCompositionPreview.GetElementVisual(UIToShow);

            gridVisual.Size        = UIToShow.ActualSize;
            gridVisual.CenterPoint = new Vector3(gridVisual.Size.X, gridVisual.Size.Y, 0) * .5f;

            // 创建一个视觉组,当改组所有视觉执行完后不再显示
            CompositionScopedBatch batch = compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

            container.StartAnimation("Opacity", fadeOutAnimation);
            container.StartAnimation("Scale.XY", scaleUpSplashAnimation);
            gridVisual.StartAnimation("Scale.XY", scaleUpGridAnimation);

            batch.Completed += (s, a) =>
            {
                ElementCompositionPreview.SetElementChildVisual(BasePage, null);
                SurfaceLoader.Uninitialize();
                AnimationCompleted?.Invoke(this, null);
            };
            batch.End();
        }
Exemplo n.º 4
0
        private void HideCustomSplashScreen()
        {
            ContainerVisual container  = (ContainerVisual)ElementCompositionPreview.GetElementChildVisual(this);
            Compositor      compositor = container.Compositor;

            // Setup some constants for scaling and animating
            const float               ScaleFactor = 20f;
            TimeSpan                  duration    = TimeSpan.FromMilliseconds(1200);
            LinearEasingFunction      linearEase  = compositor.CreateLinearEasingFunction();
            CubicBezierEasingFunction easeInOut   = compositor.CreateCubicBezierEasingFunction(new Vector2(.38f, 0f), new Vector2(.45f, 1f));

            // Create the fade animation which will target the opacity of the outgoing splash screen
            ScalarKeyFrameAnimation fadeOutAnimation = compositor.CreateScalarKeyFrameAnimation();

            fadeOutAnimation.InsertKeyFrame(1, 0);
            fadeOutAnimation.Duration = duration;

            // Create the scale up animation for the grid
            Vector2KeyFrameAnimation scaleUpGridAnimation = compositor.CreateVector2KeyFrameAnimation();

            scaleUpGridAnimation.InsertKeyFrame(0.1f, new Vector2(1 / ScaleFactor, 1 / ScaleFactor));
            scaleUpGridAnimation.InsertKeyFrame(1, new Vector2(1, 1));
            scaleUpGridAnimation.Duration = duration;

            // Create the scale up animation for the Splash screen visuals
            Vector2KeyFrameAnimation scaleUpSplashAnimation = compositor.CreateVector2KeyFrameAnimation();

            scaleUpSplashAnimation.InsertKeyFrame(0, new Vector2(1, 1));
            scaleUpSplashAnimation.InsertKeyFrame(1, new Vector2(ScaleFactor, ScaleFactor));
            scaleUpSplashAnimation.Duration = duration;

            // Configure the grid visual to scale from the center
            Visual gridVisual = ElementCompositionPreview.GetElementVisual(MainFrame);

            gridVisual.Size        = new Vector2((float)MainFrame.ActualWidth, (float)MainFrame.ActualHeight);
            gridVisual.CenterPoint = new Vector3(gridVisual.Size.X, gridVisual.Size.Y, 0) * .5f;


            //
            // Create a scoped batch for the animations.  When the batch completes, we can dispose of the
            // splash screen visuals which will no longer be visible.
            //

            CompositionScopedBatch batch = compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

            container.StartAnimation("Opacity", fadeOutAnimation);
            container.StartAnimation("Scale.XY", scaleUpSplashAnimation);
            gridVisual.StartAnimation("Scale.XY", scaleUpGridAnimation);

            batch.Completed += Batch_Completed;
            batch.End();
        }
Exemplo n.º 5
0
        public override async Task <CompositionDrawingSurface> LoadResources()
        {
            var graphicsEffect = new ArithmeticCompositeEffect
            {
                Name          = "Arithmetic",
                Source1       = new CompositionEffectSourceParameter("ImageSource"),
                Source1Amount = .1f,
                Source2       = new Transform2DEffect
                {
                    Name   = "LightMapTransform",
                    Source = new CompositionEffectSourceParameter("LightMap")
                },
                Source2Amount  = 0,
                MultiplyAmount = 1
            };

            _effectFactory = _compositor.CreateEffectFactory(graphicsEffect, new[] { "LightMapTransform.TransformMatrix" });

            // Create the image
            _lightMap = await ImageLoader.Instance.LoadFromUriAsync(new Uri("ms-appx:///Assets/NormalMapsAndMasks/pointmap.jpg"));

            // Create the animations
            CubicBezierEasingFunction easeIn = _compositor.CreateCubicBezierEasingFunction(new Vector2(0.0f, 0.51f), new Vector2(1.0f, 0.51f));

            _enterAnimation = _compositor.CreateScalarKeyFrameAnimation();
            _enterAnimation.InsertKeyFrame(0.33f, 1.25f, easeIn);
            _enterAnimation.InsertKeyFrame(0.66f, 0.75f, easeIn);
            _enterAnimation.InsertKeyFrame(1.0f, 1.0f, easeIn);
            _enterAnimation.Duration          = TimeSpan.FromMilliseconds(5000);
            _enterAnimation.IterationBehavior = AnimationIterationBehavior.Forever;

            _exitAnimation = _compositor.CreateVector2KeyFrameAnimation();
            _exitAnimation.InsertKeyFrame(1.0f, new Vector2(0, 0));
            _exitAnimation.Duration          = TimeSpan.FromMilliseconds(750);
            _exitAnimation.IterationBehavior = AnimationIterationBehavior.Count;
            _exitAnimation.IterationCount    = 1;

            var propsNode = ExpressionValues.Reference.CreatePropertySetReference("props");
            var propsCenterPointOffset = propsNode.GetVector2Property("CenterPointOffset");
            var propsTranslate         = propsNode.GetVector2Property("Translate");
            var propsScale             = propsNode.GetScalarProperty("Scale");

            _transformExpressionNode = EF.Matrix3x2(propsScale,
                                                    0,
                                                    0,
                                                    propsScale,
                                                    propsCenterPointOffset.X * (1 - propsScale) + (propsTranslate.X * propsCenterPointOffset.X * 2),
                                                    propsCenterPointOffset.Y * (1 - propsScale) + (propsTranslate.Y * propsCenterPointOffset.Y * 2));

            return(null);
        }
Exemplo n.º 6
0
        private void EnsureImplicitAnimations(FrameworkElement element)
        {
            if (_implicitAnimations == null)
            {
                Compositor compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;

                CubicBezierEasingFunction easeIn = compositor.CreateCubicBezierEasingFunction(new Vector2(0.215f, 0.61f), new Vector2(0.355f, 1f));

                Vector3KeyFrameAnimation offsetAnimation = compositor.CreateVector3KeyFrameAnimation();
                offsetAnimation.Target = nameof(Visual.Offset);
                offsetAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue", easeIn);
                offsetAnimation.Duration = TimeSpan.FromMilliseconds(500);

                CompositionAnimationGroup animationGroup = compositor.CreateAnimationGroup();
                animationGroup.Add(offsetAnimation);

                _implicitAnimations = compositor.CreateImplicitAnimationCollection();
                _implicitAnimations[nameof(Visual.Offset)] = animationGroup;
            }
        }
Exemplo n.º 7
0
        public override async Task <CompositionDrawingSurface> LoadResources()
        {
            var graphicsEffect = new ArithmeticCompositeEffect
            {
                Name          = "Arithmetic",
                Source1       = new CompositionEffectSourceParameter("ImageSource"),
                Source1Amount = .1f,
                Source2       = new Transform2DEffect
                {
                    Name   = "LightMapTransform",
                    Source = new CompositionEffectSourceParameter("LightMap")
                },
                Source2Amount  = 0,
                MultiplyAmount = 1
            };

            _effectFactory = _compositor.CreateEffectFactory(graphicsEffect, new[] { "LightMapTransform.TransformMatrix" });

            // Create the image
            _lightMap = await SurfaceLoader.LoadFromUri(new Uri("ms-appx:///Samples/SDK 10586/PointerEnterEffects/pointmap.jpg"));

            // Create the animations
            CubicBezierEasingFunction easeIn = _compositor.CreateCubicBezierEasingFunction(new Vector2(0.0f, 0.51f), new Vector2(1.0f, 0.51f));

            _enterAnimation = _compositor.CreateScalarKeyFrameAnimation();
            _enterAnimation.InsertKeyFrame(0.33f, 1.25f, easeIn);
            _enterAnimation.InsertKeyFrame(0.66f, 0.75f, easeIn);
            _enterAnimation.InsertKeyFrame(1.0f, 1.0f, easeIn);
            _enterAnimation.Duration          = TimeSpan.FromMilliseconds(5000);
            _enterAnimation.IterationBehavior = AnimationIterationBehavior.Forever;

            _exitAnimation = _compositor.CreateVector2KeyFrameAnimation();
            _exitAnimation.InsertKeyFrame(1.0f, new Vector2(0, 0));
            _exitAnimation.Duration          = TimeSpan.FromMilliseconds(750);
            _exitAnimation.IterationBehavior = AnimationIterationBehavior.Count;
            _exitAnimation.IterationCount    = 1;

            _transformExpression = _compositor.CreateExpressionAnimation("Matrix3x2(props.Scale, 0, 0, props.Scale, props.CenterPointOffset.X * (1-props.Scale) + (props.Translate.X * props.CenterPointOffset.X * 2), props.CenterPointOffset.Y * (1-props.Scale) + (props.Translate.Y * props.CenterPointOffset.Y * 2))");

            return(null);
        }
Exemplo n.º 8
0
 CubicBezierEasingFunction CubicBezierEasingFunction_4()
 {
     return(_cubicBezierEasingFunction_4 = _c.CreateCubicBezierEasingFunction(new Vector2(0.850000024F, 0), new Vector2(0.666999996F, 1)));
 }
Exemplo n.º 9
0
 CubicBezierEasingFunction CubicBezierEasingFunction_1()
 {
     return(_cubicBezierEasingFunction_1 = _c.CreateCubicBezierEasingFunction(new Vector2(0.600000024F, 0F), new Vector2(0.833000004F, 0.833000004F)));
 }
Exemplo n.º 10
0
 CubicBezierEasingFunction CubicBezierEasingFunction_2()
 {
     return(_cubicBezierEasingFunction_2 = _c.CreateCubicBezierEasingFunction(new Vector2(0.649999976F, 0), new Vector2(0.349999994F, 1)));
 }
Exemplo n.º 11
0
 CubicBezierEasingFunction CubicBezierEasingFunction_3()
 {
     return(_cubicBezierEasingFunction_3 = _c.CreateCubicBezierEasingFunction(new Vector2(0.166999996F, 0.166999996F), new Vector2(0.833000004F, 0.833000004F)));
 }
Exemplo n.º 12
0
 CubicBezierEasingFunction CubicBezierEasingFunction_2()
 {
     return(_cubicBezierEasingFunction_2 = _c.CreateCubicBezierEasingFunction(new Vector2(0.419999987F, 0), new Vector2(0.579999983F, 1)));
 }
Exemplo n.º 13
0
 CubicBezierEasingFunction CubicBezierEasingFunction_3()
 {
     return(_cubicBezierEasingFunction_3 = _c.CreateCubicBezierEasingFunction(new Vector2(0.479999989F, 0.0399999991F), new Vector2(0.519999981F, 0.959999979F)));
 }
Exemplo n.º 14
0
 CubicBezierEasingFunction CubicBezierEasingFunction_0()
 {
     return(_cubicBezierEasingFunction_0 = _c.CreateCubicBezierEasingFunction(new Vector2(0.400000006F, 0.800000012F), new Vector2(0.74000001F, 1)));
 }
Exemplo n.º 15
0
 CubicBezierEasingFunction CubicBezierEasingFunction_1()
 {
     return(_cubicBezierEasingFunction_1 = _c.CreateCubicBezierEasingFunction(new Vector2(0.839999974F, 0), new Vector2(0.159999996F, 1)));
 }
Exemplo n.º 16
0
        void InitConpositionResources()
        {
            easing  = compositor.CreateCubicBezierEasingFunction(new Vector2(0.215f, 0.61f), new Vector2(0.355f, 1f));
            steping = compositor.CreateStepEasingFunction(2);

            ProgressAnimation = compositor.CreateScalarKeyFrameAnimation();
            ProgressAnimation.InsertExpressionKeyFrame(0f, "This.StartingValue", easing);
            ProgressAnimation.InsertExpressionKeyFrame(1f, "propSet.newvalue", easing);
            ProgressAnimation.SetReferenceParameter("propSet", propSet);
            ProgressAnimation.Duration = TimeSpan.FromSeconds(0.3d);
            ProgressAnimation.Target   = "progress";

            //ImplicitAnimations = compositor.CreateImplicitAnimationCollection();
            //ImplicitAnimations["progress"] = ProgressAnimation;

            //propSet.ImplicitAnimations = ImplicitAnimations;

            TopBorderVisual     = ElementCompositionPreview.GetElementVisual(TopBorder);
            BottomBorderVisual  = ElementCompositionPreview.GetElementVisual(BottomBorder);
            CenterBorderVisual  = ElementCompositionPreview.GetElementVisual(CenterBorder);
            ContentBorderVisual = ElementCompositionPreview.GetElementVisual(ContentBorder);

            TopBorderVisual.CenterPoint     = new Vector3(38f, 36f, 0f);
            BottomBorderVisual.CenterPoint  = new Vector3(39f, 36f, 0f);
            CenterBorderVisual.CenterPoint  = new Vector3(36f, 36f, 0f);
            ContentBorderVisual.CenterPoint = new Vector3(36, 36, 0);

            TopRotationAnimation = compositor.CreateExpressionAnimation("0.25 * Pi * propSet.progress");
            TopRotationAnimation.SetReferenceParameter("propSet", propSet);

            BottomRotationAnimation = compositor.CreateExpressionAnimation("-0.25 * Pi * propSet.progress");
            BottomRotationAnimation.SetReferenceParameter("propSet", propSet);

            IconRotationAnimation = compositor.CreateExpressionAnimation("propSet.isopened == 1 ? -Pi * propSet.progress : Pi * propSet.progress");
            IconRotationAnimation.SetReferenceParameter("propSet", propSet);

            ExternalScaleXAnimation = compositor.CreateExpressionAnimation(" 1 - 0.4 * propSet.progress");
            ExternalScaleXAnimation.SetReferenceParameter("propSet", propSet);

            InternalScaleXAnimation = compositor.CreateExpressionAnimation(" 1 - 0.04 * propSet.progress");
            InternalScaleXAnimation.SetReferenceParameter("propSet", propSet);

            IsOpenedAnimation = compositor.CreateScalarKeyFrameAnimation();
            IsOpenedAnimation.InsertExpressionKeyFrame(0f, "This.StartingValue", steping);
            IsOpenedAnimation.InsertKeyFrame(1f, 1f, steping);
            IsOpenedAnimation.Duration  = TimeSpan.FromSeconds(0.001d);
            IsOpenedAnimation.DelayTime = TimeSpan.FromSeconds(0.3d);

            IsNotOpenedAnimation = compositor.CreateScalarKeyFrameAnimation();
            IsNotOpenedAnimation.InsertExpressionKeyFrame(0f, "This.StartingValue", steping);
            IsNotOpenedAnimation.InsertKeyFrame(1f, 0f, steping);
            IsNotOpenedAnimation.Duration  = TimeSpan.FromSeconds(0.001d);
            IsNotOpenedAnimation.DelayTime = TimeSpan.FromSeconds(0.3d);

            TopBorderVisual.StartAnimation("RotationAngle", TopRotationAnimation);
            BottomBorderVisual.StartAnimation("RotationAngle", BottomRotationAnimation);
            ContentBorderVisual.StartAnimation("RotationAngle", IconRotationAnimation);

            TopBorderVisual.StartAnimation("Scale.X", ExternalScaleXAnimation);
            BottomBorderVisual.StartAnimation("Scale.X", ExternalScaleXAnimation);
            CenterBorderVisual.StartAnimation("Scale.X", InternalScaleXAnimation);
        }
        private int AddAdjacent(int start, int end, int delta)
        {
            int doubledVal = 0;
            int totalBonus = -1; //If it returns -1 then no additions happened regardless of whether they were bonus worthy
            int cur        = start;

            for (int i = 0; i < _boardSize - 1; i++)
            {
                if ((Cells[cur + delta].IntVal != 0) && (Cells[cur].IntVal > 0) && (Cells[cur].IntVal == Cells[cur + delta].IntVal))
                {
                    ///Animate cell movement
                    var slideToCellVisual   = ElementCompositionPreview.GetElementVisual(Buttons[cur]);
                    var compositor          = slideToCellVisual.Compositor;
                    var slideFromCellVisual = ElementCompositionPreview.GetElementVisual(Buttons[cur + delta]);

                    //very brittle way to get visuals for the text fields inside the cell template
                    var lvp        = VisualTreeHelper.GetChild(Buttons[cur], 0);
                    var border     = VisualTreeHelper.GetChild(lvp, 0);
                    var grid       = VisualTreeHelper.GetChild(border, 0);
                    var cellText   = VisualTreeHelper.GetChild(grid, 0);
                    var answerText = VisualTreeHelper.GetChild(grid, 1);

                    var answerTextVisual = ElementCompositionPreview.GetElementVisual(answerText as FrameworkElement);
                    var cellTextVisual   = ElementCompositionPreview.GetElementVisual(cellText as FrameworkElement);

                    CubicBezierEasingFunction easing = compositor.CreateCubicBezierEasingFunction(new Vector2(.86f, 0.0f), new Vector2(.07f, 1.00f));

                    ///Scale the ToCell to breifly be twice the size and then back down to regular size
                    ///
                    slideToCellVisual.CenterPoint = new System.Numerics.Vector3(slideToCellVisual.Size.X / 2, slideToCellVisual.Size.Y / 2, 0f);
                    var scaleUpAnimation = compositor.CreateVector3KeyFrameAnimation();
                    scaleUpAnimation.InsertKeyFrame(0f, new System.Numerics.Vector3(1.0f, 1.0f, 0f), easing);
                    scaleUpAnimation.InsertKeyFrame(0.5f, new System.Numerics.Vector3(1.2f, 1.2f, 0f), easing);
                    scaleUpAnimation.InsertKeyFrame(1f, new System.Numerics.Vector3(1.0f, 1.0f, 0f), easing);
                    scaleUpAnimation.Duration = TimeSpan.FromMilliseconds(_AddSpeed);

                    ///Slide the ToCell back from the FromCell position
                    ///Be sure to return it to its original position afterwards
                    var initialFromOffset = new Vector3(slideFromCellVisual.Offset.X, slideFromCellVisual.Offset.Y, slideFromCellVisual.Offset.Z);
                    var initialToOffset   = new Vector3(slideToCellVisual.Offset.X, slideToCellVisual.Offset.Y, slideToCellVisual.Offset.Z);
                    var slideAnimation    = compositor.CreateVector3KeyFrameAnimation();
                    slideAnimation.InsertKeyFrame(0, initialFromOffset);
                    slideAnimation.InsertKeyFrame(1, initialToOffset, easing);
                    slideAnimation.Duration = TimeSpan.FromMilliseconds(_SlideSpeed / 2);

                    //show cell text
                    var showCellTextAnimation = compositor.CreateScalarKeyFrameAnimation();
                    showCellTextAnimation.InsertKeyFrame(0, 0f);
                    showCellTextAnimation.InsertKeyFrame(1, 1f);
                    showCellTextAnimation.Duration = TimeSpan.FromMilliseconds(_AddSpeed * 2);

                    //Show answer
                    var showAnswerAnimation = compositor.CreateScalarKeyFrameAnimation();
                    showAnswerAnimation.InsertKeyFrame(0, 1f);
                    showAnswerAnimation.InsertKeyFrame(1, 0.0f);
                    showAnswerAnimation.Duration = TimeSpan.FromMilliseconds(_AddSpeed * 3);

                    var scaleAnswerAnimation = compositor.CreateVector3KeyFrameAnimation();
                    scaleAnswerAnimation.InsertKeyFrame(0f, new System.Numerics.Vector3(1.0f, 1.0f, 0f), easing);
                    scaleAnswerAnimation.InsertKeyFrame(0.5f, new System.Numerics.Vector3(1.5f, 1.5f, 0f), easing);
                    scaleAnswerAnimation.InsertKeyFrame(1f, new System.Numerics.Vector3(1.0f, 1.0f, 0f), easing);
                    scaleAnswerAnimation.Duration = TimeSpan.FromMilliseconds(_AddSpeed);

                    slideToCellVisual.StartAnimation(nameof(slideToCellVisual.Offset), slideAnimation);

                    _slideBatchAnimation.Suspend();
                    _addAdjacentBatchAnimation.Suspend();
                    slideToCellVisual.StartAnimation(nameof(slideToCellVisual.Scale), scaleUpAnimation);
                    if (_boardSpeed == BoardSpeed.Slow)
                    {
                        answerTextVisual.StartAnimation(nameof(answerTextVisual.Opacity), showAnswerAnimation);
                        answerTextVisual.StartAnimation(nameof(answerTextVisual.Scale), scaleAnswerAnimation);
                        cellTextVisual.StartAnimation(nameof(cellTextVisual.Opacity), showCellTextAnimation);
                    }
                    _addAdjacentBatchAnimation.Resume();
                    _slideBatchAnimation.Resume();

                    Canvas.SetZIndex(Buttons[cur], GetHighestButtonIndex() + 1);

                    if (_boardSpeed == BoardSpeed.Slow)
                    {
                        Cells[cur].AnswerString = Cells[cur].IntVal.ToString() + " + " + Cells[cur + delta].IntVal.ToString();
                    }

                    Cells[cur].IntVal += Cells[cur + delta].IntVal;

                    doubledVal = Cells[cur].IntVal;
                    if (totalBonus > -1)
                    {
                        totalBonus += MilestoneBonus(doubledVal);
                    }
                    else
                    {
                        totalBonus  = 0;
                        totalBonus += MilestoneBonus(doubledVal);
                    }

                    if (doubledVal > HighTile)
                    {
                        HighTile = doubledVal;
                    }

                    Cells[cur + delta].IntVal = 0;
                    Score += Cells[cur].IntVal;
                }
                cur += delta;
            }
            return(totalBonus);
        }
 CubicBezierEasingFunction CubicBezierEasingFunction_5()
 {
     return(_cubicBezierEasingFunction_5 = _c.CreateCubicBezierEasingFunction(new Vector2(0.333000004F, 0), new Vector2(0.301999986F, 1)));
 }
Exemplo n.º 19
0
        private void Scroller4_ZoomAnimationStarting(muxc.ScrollViewer sender, muxc.ZoomAnimationStartingEventArgs args)
        {
            try
            {
                ScalarKeyFrameAnimation stockKeyFrameAnimation = args.Animation as ScalarKeyFrameAnimation;

                if (stockKeyFrameAnimation != null)
                {
                    ScalarKeyFrameAnimation customKeyFrameAnimation = stockKeyFrameAnimation;

                    if (nameof(ZoomAnimationOptions.Default) != (string)cbZoomAnimation.SelectedItem)
                    {
                        float targetZoomFactor = (float)zoomFactorSlider.Value;

                        customKeyFrameAnimation = stockKeyFrameAnimation.Compositor.CreateScalarKeyFrameAnimation();
                        float deltaZoomFactor = (float)(targetZoomFactor - sender.ZoomFactor);

                        switch ((string)cbZoomAnimation.SelectedItem)
                        {
                        case nameof(ZoomAnimationOptions.Custom1):
                            // "Accordion" case
                            for (int step = 0; step < 3; step++)
                            {
                                customKeyFrameAnimation.InsertKeyFrame(
                                    1.0f - (0.4f / (float)Math.Pow(2, step)),
                                    targetZoomFactor + 0.1f * deltaZoomFactor);
                                deltaZoomFactor /= -2.0f;
                            }

                            customKeyFrameAnimation.InsertKeyFrame(1.0f, targetZoomFactor);
                            break;

                        case nameof(ZoomAnimationOptions.Custom2):
                            // "Teleportation" case

                            CubicBezierEasingFunction cubicBezierStart = stockKeyFrameAnimation.Compositor.CreateCubicBezierEasingFunction(
                                new Vector2(1.0f, 0.0f),
                                new Vector2(1.0f, 0.0f));

                            StepEasingFunction stepEasingFunc = stockKeyFrameAnimation.Compositor.CreateStepEasingFunction(1);

                            CubicBezierEasingFunction cubicBezierEnd = stockKeyFrameAnimation.Compositor.CreateCubicBezierEasingFunction(
                                new Vector2(0.0f, 1.0f),
                                new Vector2(0.0f, 1.0f));

                            customKeyFrameAnimation.InsertKeyFrame(
                                0.499999f,
                                targetZoomFactor - 0.75f * deltaZoomFactor,
                                cubicBezierStart);
                            customKeyFrameAnimation.InsertKeyFrame(
                                0.5f,
                                targetZoomFactor - 0.25f * deltaZoomFactor,
                                stepEasingFunc);
                            customKeyFrameAnimation.InsertKeyFrame(
                                1.0f,
                                targetZoomFactor,
                                cubicBezierEnd);
                            break;

                        default:
                            break;
                        }

                        customKeyFrameAnimation.Duration = stockKeyFrameAnimation.Duration;
                        args.Animation = customKeyFrameAnimation;
                    }

                    if (!string.IsNullOrWhiteSpace(tbZoomDuration.Text))
                    {
                        double durationOverride = Convert.ToDouble(tbZoomDuration.Text);
                        customKeyFrameAnimation.Duration = TimeSpan.FromMilliseconds(durationOverride);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 20
0
        private void Scroller4_ScrollAnimationStarting(muxc.ScrollViewer sender, muxc.ScrollAnimationStartingEventArgs args)
        {
            try
            {
                Vector3KeyFrameAnimation stockKeyFrameAnimation = args.Animation as Vector3KeyFrameAnimation;

                if (stockKeyFrameAnimation != null)
                {
                    Vector3KeyFrameAnimation customKeyFrameAnimation = stockKeyFrameAnimation;

                    if (nameof(ScrollAnimationOptions.Default) != (string)cbAnimation.SelectedItem)
                    {
                        double targetHorizontalOffset   = args.EndPosition.X;
                        float  targetHorizontalPosition = ComputeHorizontalPositionFromOffset(sender.Content, targetHorizontalOffset, sender.ZoomFactor);

                        double targetVerticalOffset   = args.EndPosition.Y;
                        float  targetVerticalPosition = ComputeVerticalPositionFromOffset(sender.Content, targetVerticalOffset, sender.ZoomFactor);

                        customKeyFrameAnimation = stockKeyFrameAnimation.Compositor.CreateVector3KeyFrameAnimation();

                        float deltaHorizontalPosition = (float)(targetHorizontalOffset - sender.HorizontalOffset);
                        float deltaVerticalPosition   = (float)(targetVerticalOffset - sender.VerticalOffset);

                        switch ((string)cbAnimation.SelectedItem)
                        {
                        case nameof(ScrollAnimationOptions.Custom1):
                            // "Accordion" case
                            for (int keyframe = 0; keyframe < 3; keyframe++)
                            {
                                customKeyFrameAnimation.InsertKeyFrame(
                                    1.0f - (0.4f / (float)Math.Pow(2, keyframe)),
                                    new Vector3(targetHorizontalPosition + 0.1f * deltaHorizontalPosition, targetVerticalPosition + 0.1f * deltaVerticalPosition, 0.0f));

                                deltaHorizontalPosition /= -2.0f;
                                deltaVerticalPosition   /= -2.0f;
                            }

                            customKeyFrameAnimation.InsertKeyFrame(1.0f, new Vector3(targetHorizontalPosition, targetVerticalPosition, 0.0f));
                            break;

                        case nameof(ScrollAnimationOptions.Custom2):
                            // "Teleportation" case
                            CubicBezierEasingFunction cubicBezierStart = stockKeyFrameAnimation.Compositor.CreateCubicBezierEasingFunction(
                                new Vector2(1.0f, 0.0f),
                                new Vector2(1.0f, 0.0f));

                            StepEasingFunction step = stockKeyFrameAnimation.Compositor.CreateStepEasingFunction(1);

                            CubicBezierEasingFunction cubicBezierEnd = stockKeyFrameAnimation.Compositor.CreateCubicBezierEasingFunction(
                                new Vector2(0.0f, 1.0f),
                                new Vector2(0.0f, 1.0f));

                            customKeyFrameAnimation.InsertKeyFrame(
                                0.499999f,
                                new Vector3(targetHorizontalPosition - 0.75f * deltaHorizontalPosition, targetVerticalPosition - 0.75f * deltaVerticalPosition, 0.0f),
                                cubicBezierStart);
                            customKeyFrameAnimation.InsertKeyFrame(
                                0.5f,
                                new Vector3(targetHorizontalPosition - 0.25f * deltaHorizontalPosition, targetVerticalPosition - 0.25f * deltaVerticalPosition, 0.0f),
                                step);
                            customKeyFrameAnimation.InsertKeyFrame(
                                1.0f,
                                new Vector3(targetHorizontalPosition, targetVerticalPosition, 0.0f),
                                cubicBezierEnd);
                            break;

                        default:
                            break;
                        }

                        customKeyFrameAnimation.Duration = stockKeyFrameAnimation.Duration;
                    }

                    if (!string.IsNullOrWhiteSpace(tbAnimDuration.Text))
                    {
                        // Override animation duration
                        double durationOverride = Convert.ToDouble(tbAnimDuration.Text);
                        customKeyFrameAnimation.Duration = TimeSpan.FromMilliseconds(durationOverride);
                    }

                    args.Animation = customKeyFrameAnimation;
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 21
0
 CubicBezierEasingFunction CubicBezierEasingFunction_1()
 {
     return(_cubicBezierEasingFunction_1 = _c.CreateCubicBezierEasingFunction(new Vector2(0.166999996F, 0.166999996F), new Vector2(0.600000024F, 1F)));
 }
Exemplo n.º 22
0
 CubicBezierEasingFunction CubicBezierEasingFunction_2()
 {
     return(_cubicBezierEasingFunction_2 = _c.CreateCubicBezierEasingFunction(new Vector2(0.400000006F, 0F), new Vector2(0.833000004F, 0.833000004F)));
 }
 CubicBezierEasingFunction CubicBezierEasingFunction_6()
 {
     return(_cubicBezierEasingFunction_6 = _c.CreateCubicBezierEasingFunction(new Vector2(0.333000004F, 0), new Vector2(0.666999996F, 1)));
 }
Exemplo n.º 24
0
        /// <summary>
        /// Creates the default backwards composition animation
        /// </summary>
        /// <param name="outElement"></param>
        /// <param name="inElement"></param>
        /// <returns></returns>
        CompositionStoryboard CreateCompositionExpoZoomBackward(FrameworkElement outElement, FrameworkElement inElement)
        {
            Compositor compositor = ElementCompositionPreview.GetElementVisual(outElement).Compositor;

            Visual outVisual = ElementCompositionPreview.GetElementVisual(outElement);
            Visual inVisual  = ElementCompositionPreview.GetElementVisual(inElement);

            CompositionAnimationGroup outgroup = compositor.CreateAnimationGroup();
            CompositionAnimationGroup ingroup  = compositor.CreateAnimationGroup();

            TimeSpan outDuration = TimeSpan.FromSeconds(0.3);
            TimeSpan inDuration  = TimeSpan.FromSeconds(0.4);

            CubicBezierEasingFunction ease = compositor.CreateCubicBezierEasingFunction(
                new Vector2(0.95f, 0.05f),
                new Vector2(0.79f, 0.04f));

            CubicBezierEasingFunction easeOut = compositor.CreateCubicBezierEasingFunction(
                new Vector2(0.19f, 1.0f),
                new Vector2(0.22f, 1.0f));


            // OUT ELEMENT
            {
                outVisual.CenterPoint = outVisual.Size.X > 0
                    ? new Vector3(outVisual.Size / 2f, 0f)
                    : new Vector3((float)this.ActualWidth / 2f, (float)this.ActualHeight / 2f, 0f);

                // SCALE OUT
                var sO = compositor.CreateVector3KeyFrameAnimation();
                sO.Duration = outDuration;
                sO.Target   = nameof(outVisual.Scale);
                sO.InsertKeyFrame(1, new Vector3(0.7f, 0.7f, 1.0f), ease);
                outgroup.Add(sO);

                // FADE OUT
                var op = compositor.CreateScalarKeyFrameAnimation();
                op.Duration = outDuration;
                op.Target   = nameof(outVisual.Opacity);
                op.InsertKeyFrame(1, 0f, ease);
                outgroup.Add(op);
            }

            // IN ELEMENT
            {
                inVisual.CenterPoint = inVisual.Size.X > 0
                     ? new Vector3(inVisual.Size / 2f, 0f)
                     : new Vector3((float)this.ActualWidth / 2f, (float)this.ActualHeight / 2f, 0f);


                // SCALE IN
                ingroup.Add(
                    inVisual.CreateVector3KeyFrameAnimation(nameof(Visual.Scale))
                    .AddScaleKeyFrame(0, 1.3f)
                    .AddScaleKeyFrame(1, 1f, easeOut)
                    .SetDuration(inDuration)
                    .SetDelayTime(outDuration)
                    .SetDelayBehavior(AnimationDelayBehavior.SetInitialValueBeforeDelay));

                // FADE IN
                inVisual.Opacity = 0f;
                var op = inVisual.Compositor.CreateScalarKeyFrameAnimation();
                op.DelayTime = outDuration;
                op.Duration  = inDuration;
                op.Target    = nameof(outVisual.Opacity);
                op.InsertKeyFrame(1, 0f, easeOut);
                op.InsertKeyFrame(1, 1f, easeOut);
                ingroup.Add(op);
            }

            CompositionStoryboard group = new CompositionStoryboard();

            group.Add(new CompositionTimeline(outVisual, outgroup, ease));
            group.Add(new CompositionTimeline(inVisual, ingroup, easeOut));
            return(group);
        }
Exemplo n.º 25
0
 CubicBezierEasingFunction CubicBezierEasingFunction_0()
 {
     return(_cubicBezierEasingFunction_0 = _c.CreateCubicBezierEasingFunction(new Vector2(0.600000024F, 0F), new Vector2(0.400000006F, 1F)));
 }
 CubicBezierEasingFunction CubicBezierEasingFunction_2()
 {
     return(_cubicBezierEasingFunction_2 = _c.CreateCubicBezierEasingFunction(new Vector2(0.370999992F, 0), new Vector2(0.340999991F, 1)));
 }