本文整理汇总了C#中System.Windows.Media.MatrixTransform.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# MatrixTransform.BeginAnimation方法的具体用法?C# MatrixTransform.BeginAnimation怎么用?C# MatrixTransform.BeginAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.MatrixTransform
的用法示例。
在下文中一共展示了MatrixTransform.BeginAnimation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DLMatrixAnimation
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);
};
}
示例2: AnimatePutCardMiddleOrRight
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);
}
示例3: AnimatePutCard
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);
}
示例4: AnimatePutCardLeft
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);
}
示例5: AnimateMoveCard
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);
}