本文整理汇总了C#中System.Windows.Media.ScaleTransform.ApplyAnimationClock方法的典型用法代码示例。如果您正苦于以下问题:C# ScaleTransform.ApplyAnimationClock方法的具体用法?C# ScaleTransform.ApplyAnimationClock怎么用?C# ScaleTransform.ApplyAnimationClock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.ScaleTransform
的用法示例。
在下文中一共展示了ScaleTransform.ApplyAnimationClock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScaleEasingAnimation
public void ScaleEasingAnimation(FrameworkElement element, double from, double to)
{
ScaleTransform scale = new ScaleTransform();
element.RenderTransform = scale;
element.RenderTransformOrigin = new Point(0.5, 0.5);//定义圆心位置
DoubleAnimation scaleAnimation = new DoubleAnimation()
{
From = from, //起始值
To = to, //结束值
//EasingFunction = easing, //缓动函数
Duration = new TimeSpan(0, 0, 0, 0, 200) //动画播放时间
};
AnimationClock clock = scaleAnimation.CreateClock();
scale.ApplyAnimationClock(ScaleTransform.ScaleXProperty, clock);
scale.ApplyAnimationClock(ScaleTransform.ScaleYProperty, clock);
}
示例2: ScaleEasingAnimation
public static void ScaleEasingAnimation(FrameworkElement element)
{
ScaleTransform scale = new ScaleTransform();
element.RenderTransform = scale;
element.RenderTransformOrigin = new Point(0.5, 0.5);//定义圆心位置
EasingFunctionBase easing = new ElasticEase()
{
EasingMode = EasingMode.EaseOut, //公式
Oscillations = 1, //滑过动画目标的次数
Springiness = 10 //弹簧刚度
};
DoubleAnimation scaleAnimation = new DoubleAnimation()
{
From = 0, //起始值
To = 1, //结束值
EasingFunction = easing, //缓动函数
Duration = new TimeSpan(0, 0, 0, 1, 200) //动画播放时间
};
AnimationClock clock = scaleAnimation.CreateClock();
scale.ApplyAnimationClock(ScaleTransform.ScaleXProperty, clock);
scale.ApplyAnimationClock(ScaleTransform.ScaleYProperty, clock);
}
示例3: ClearScaleTransformAnimation
private static void ClearScaleTransformAnimation( ScaleTransform transform )
{
if( transform == null )
return;
// Force a local value before removing the potential animation clock of this transform to avoid leaving the current animated value after animation is removed
transform.CenterX = 0d;
transform.ScaleX = 1d;
transform.ApplyAnimationClock( ScaleTransform.ScaleXProperty, null );
}
示例4: ScaleEasingAnimation
/// <summary>
/// 缓动缩放动画 (提升效率)Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = 20 });
/// </summary>
/// <param name="element">缩放控件</param>
/// <param name="aTime">缩放时间</param>
/// <param name="dFrom">缩放起始值(推荐1)</param>
/// <param name="dTo">缩放结束值(推荐1.5)</param>
/// <param name="aOscillations">滑过动画目标的次数(推荐5)</param>
/// <param name="aSpringiness">弹簧刚度(推荐10)</param>
/// <returns>返回动画对象</returns>
public static AnimationClock ScaleEasingAnimation(FrameworkElement element, TimeSpan aTime, double dFrom, double dTo, int aOscillations, int aSpringiness)
{
ScaleTransform scale = new ScaleTransform();
element.RenderTransform = scale;
element.RenderTransformOrigin = new Point(0.5, 0.5);//定义圆心位置
EasingFunctionBase easing = new ElasticEase()
{
EasingMode = EasingMode.EaseOut, //公式
Oscillations = aOscillations, //滑过动画目标的次数
Springiness = aSpringiness //弹簧刚度
};
DoubleAnimation scaleAnimation = new DoubleAnimation()
{
From = dFrom, //起始值
To = dTo, //结束值
EasingFunction = easing, //缓动函数
Duration = aTime //动画播放时间
};
AnimationClock clock = scaleAnimation.CreateClock();
scale.ApplyAnimationClock(ScaleTransform.ScaleXProperty, clock);
scale.ApplyAnimationClock(ScaleTransform.ScaleYProperty, clock);
return clock;
}