本文整理汇总了C#中System.Windows.Media.Animation.DoubleAnimationUsingKeyFrames.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleAnimationUsingKeyFrames.Freeze方法的具体用法?C# DoubleAnimationUsingKeyFrames.Freeze怎么用?C# DoubleAnimationUsingKeyFrames.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Animation.DoubleAnimationUsingKeyFrames
的用法示例。
在下文中一共展示了DoubleAnimationUsingKeyFrames.Freeze方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupAnimationForGear
private void SetupAnimationForGear(Canvas gearBox, double ratio, SweepDirection direction)
{
var duration = TimeSpan.FromMilliseconds(30000*ratio);
var animationRotation = new DoubleAnimationUsingKeyFrames
{
Duration = new Duration(duration),
RepeatBehavior = RepeatBehavior.Forever
};
animationRotation.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromPercent(0)));
animationRotation.KeyFrames.Add(new LinearDoubleKeyFrame(
direction == SweepDirection.Clockwise ? 360 : -360,
KeyTime.FromPercent(1)));
var rotateTransform = new RotateTransform();
gearBox.RenderTransform = rotateTransform;
gearBox.RenderTransformOrigin = new Point(0.5, 0.5);
Storyboard.SetTarget(animationRotation, rotateTransform);
Storyboard.SetTargetProperty(animationRotation, new PropertyPath(RotateTransform.AngleProperty));
animationRotation.Freeze();
_storyBoard.Children.Add(animationRotation);
}
示例2: InitializeRotations
private void InitializeRotations()
{
_storyBoard.RepeatBehavior = RepeatBehavior.Forever;
var duration = TimeSpan.FromSeconds(10);
var animationRotation = new DoubleAnimationUsingKeyFrames
{
Duration = new Duration(duration),
RepeatBehavior = RepeatBehavior.Forever
};
var animationTranslate = new PennerDoubleAnimation
{
Equation = PennerDoubleAnimation.Equations.QuadEaseInOut,
Duration = TimeSpan.FromSeconds(5),
RepeatBehavior = RepeatBehavior.Forever,
From = 0,
To = 610,
AutoReverse = true
};
animationRotation.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromPercent(0)));
animationRotation.KeyFrames.Add(new LinearDoubleKeyFrame(360, KeyTime.FromPercent(1)));
var rotateTransform = new RotateTransform();
PullPoint.RenderTransform = rotateTransform;
PullPoint.RenderTransformOrigin = new Point(0.5, 0.5);
var translateTransform = new TranslateTransform();
Yoke.RenderTransform = translateTransform;
Yoke.RenderTransformOrigin = new Point(0.5,0.5);
Storyboard.SetTarget(animationRotation, rotateTransform);
Storyboard.SetTargetProperty(animationRotation, new PropertyPath(RotateTransform.AngleProperty));
Storyboard.SetTarget(animationTranslate, translateTransform);
Storyboard.SetTargetProperty(animationTranslate, new PropertyPath(TranslateTransform.XProperty));
animationTranslate.Freeze();
animationRotation.Freeze();
_storyBoard.Children.Add(animationTranslate);
_storyBoard.Children.Add(animationRotation);
}