Esempio n. 1
0
 public DLMatrixAnimation(Matrix fromValue, Matrix toValue, Duration duration, Action<object> frameCallback, IEasingFunction easingFunction = null)
 {
     FrameCallback = frameCallback;
     _matrixTransform = new MatrixTransform();
     _matrixAnimation = new MatrixAnimation(fromValue, toValue, duration);
     if(easingFunction != null)
     {
         _matrixAnimation.EasingFunction = easingFunction;
     }
     _matrixAnimation.Completed += (sender, args) =>
         {
             FrameCallback(_matrixAnimation.To);
             _matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, null);
         };
 }
Esempio n. 2
0
        private void AnimatePutCardMiddleOrRight(int iLocationIndex)
        {
            Canvas targetCanves = GetCanvas(iLocationIndex);
            Point pointCanvasCorner = targetCanves.PointToScreen(new Point(0, 0));

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();

            PolyBezierSegment pBezierSegment = new PolyBezierSegment();

            pFigure.StartPoint = new Point(-pointCanvasCorner.X + this.ActualWidth / 2, -pointCanvasCorner.Y);
            pBezierSegment.Points.Add(pFigure.StartPoint);
            pBezierSegment.Points.Add(new Point(-targetCanves.ActualWidth, 0));
            pBezierSegment.Points.Add(new Point(0, 0));

            // Create a MatrixTransform. This transform will be used to move the button.
            MatrixTransform matrixTransform = new MatrixTransform();
            targetCanves.RenderTransform = matrixTransform;

            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation =
                new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(iAnimationPutCardTime);

            // Set the animation's DoesRotateWithTangent property
            // to true so that rotates the card in addition to moving it.
            matrixAnimation.DoesRotateWithTangent = true;
            matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, matrixAnimation);
        }
Esempio n. 3
0
        private void AnimatePutCard(int iLocationIndex)
        {
            Canvas targetCanves = GetCanvas(iLocationIndex);
            Point pointCanvasCorner = targetCanves.PointToScreen(new Point(0, 0));
            Point pointWindowCorner = PointToScreen(new Point(0, 0));

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();

            PolyLineSegment pLineSegment = new PolyLineSegment();
            Point pointStart = new Point();
            pointStart.X = pointWindowCorner.X - pointCanvasCorner.X + this.ActualWidth / 2 - targetCanves.ActualHeight / 4;
            pointStart.Y = pointWindowCorner.Y - pointCanvasCorner.Y - targetCanves.ActualWidth;
            pFigure.StartPoint = pointStart;
            pLineSegment.Points.Add(pFigure.StartPoint);
            pLineSegment.Points.Add(new Point(0, 0));

            // Create a MatrixTransform. This transform will be used to move the button.
            MatrixTransform matrixTransform = new MatrixTransform();
            targetCanves.RenderTransform = matrixTransform;

            pFigure.Segments.Add(pLineSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(iAnimationPutCardTime);

            DoubleAnimation doubleAnimation = new DoubleAnimation(90, 360, TimeSpan.FromSeconds(iAnimationPutCardTime));
            RotateTransform renderTransform = new RotateTransform(0, targetCanves.ActualWidth / 2, targetCanves.ActualHeight / 2);//targetCanves.ActualHeight);
            targetCanves.Children[0].RenderTransform = renderTransform;
            renderTransform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation);

            //matrixAnimation.DoesRotateWithTangent = true;
            matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, matrixAnimation);
        }
Esempio n. 4
0
        private void AnimatePutCardLeft(int iLocationIndex)
        {
            Canvas targetCanves = GetCanvas(iLocationIndex);
            Point pointCanvasCorner = targetCanves.PointToScreen(new Point(0, 0));

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();

            PolyBezierSegment pBezierSegment = new PolyBezierSegment();
            pFigure.StartPoint = new Point(-pointCanvasCorner.X + this.ActualWidth / 2, -pointCanvasCorner.Y);
            pBezierSegment.Points.Add(pFigure.StartPoint);
            pBezierSegment.Points.Add(new Point(targetCanves.ActualWidth * 2, targetCanves.ActualHeight));
            pBezierSegment.Points.Add(new Point(targetCanves.ActualWidth, targetCanves.ActualHeight));

            // Create a MatrixTransform. This transform will be used to move the button.
            MatrixTransform matrixTransform = new MatrixTransform();
            targetCanves.RenderTransform = matrixTransform;

            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation =
                new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(2 * iAnimationPutCardTime / 3);

            matrixAnimation.Completed += delegate
            {
                // the cards get reversed - there for need animation to flip it...
                DoubleAnimation doubleAnimation = new DoubleAnimation(180, 0, TimeSpan.FromSeconds(iAnimationPutCardTime / 3));
                RotateTransform rotareTransform = new RotateTransform(0, targetCanves.ActualWidth / 2, targetCanves.ActualHeight / 2);//targetCanves.ActualHeight);
                targetCanves.RenderTransform = rotareTransform;
                rotareTransform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation);
            };

            // Set the animation's DoesRotateWithTangent property
            // to true so that rotates the card in addition to moving it.
            matrixAnimation.DoesRotateWithTangent = true;
            matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, matrixAnimation);
        }
Esempio n. 5
0
        private void AnimateMoveCard(int iLocationFrom, int iLocationTo)
        {
            Canvas canvesFrom = GetCanvas(iLocationFrom);
            Point pointCanvasCornerFrom = canvesFrom.PointToScreen(new Point(0, 0));
            Canvas canvesTo = GetCanvas(iLocationTo);
            Point pointCanvasCornerTo = canvesTo.PointToScreen(new Point(0, 0));

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();

            PolyLineSegment pLineSegment = new PolyLineSegment();
            pFigure.StartPoint = new Point(0, 0);
            pLineSegment.Points.Add(pFigure.StartPoint);
            pLineSegment.Points.Add(new Point(pointCanvasCornerTo.X - pointCanvasCornerFrom.X, pointCanvasCornerTo.Y - pointCanvasCornerFrom.Y));

            // Create a MatrixTransform. This transform will be used to move the button.
            MatrixTransform matrixTransform = new MatrixTransform();

            pFigure.Segments.Add(pLineSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(iAnimationRemoveCardTime);

            canvesFrom.Children[0].RenderTransform = matrixTransform;
            matrixAnimation.Completed += delegate
            {
                MoveCard(iLocationFrom, iLocationTo);
            };

            matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, matrixAnimation);
        }