本文整理汇总了C#中Windows.UI.Xaml.Media.Animation.EasingFunctionBase类的典型用法代码示例。如果您正苦于以下问题:C# EasingFunctionBase类的具体用法?C# EasingFunctionBase怎么用?C# EasingFunctionBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EasingFunctionBase类属于Windows.UI.Xaml.Media.Animation命名空间,在下文中一共展示了EasingFunctionBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FadeInAsync
public static async Task FadeInAsync(this UIElement element, double duration = 250, EasingFunctionBase easingFunction = null)
{
if (element.Opacity < 1.0)
{
await AnimateDoublePropertyAsync(element, "Opacity", element.Opacity, 1.0, duration, easingFunction);
}
}
示例2: Draw
public void Draw(EasingFunctionBase easingFunction)
{
canvas1.Children.Clear();
var pathSegments = new PathSegmentCollection();
for (double i = 0; i < 1; i += SamplingInterval)
{
double x = i * canvas1.Width;
double y = easingFunction.Ease(i) * canvas1.Height;
var segment = new LineSegment();
segment.Point = new Point(x, y);
pathSegments.Add(segment);
}
var p = new Path();
p.Stroke = new SolidColorBrush(Colors.Black);
p.StrokeThickness = 3;
var figures = new PathFigureCollection();
figures.Add(new PathFigure() { Segments = pathSegments });
p.Data = new PathGeometry() { Figures = figures };
canvas1.Children.Add(p);
}
示例3: AnimateHeightAsync
public static async Task AnimateHeightAsync(this FrameworkElement element, double height, double duration = 250, EasingFunctionBase easingFunction = null)
{
if (element.Height != height)
{
await AnimateDoublePropertyAsync(element, "Height", element.ActualHeight, height, duration, easingFunction);
}
}
示例4: AnimateWidthAsync
public static async Task AnimateWidthAsync(this FrameworkElement element, double width, double duration = 250, EasingFunctionBase easingFunction = null)
{
if (element.ActualWidth != width)
{
await AnimateDoublePropertyAsync(element, "Width", element.ActualWidth, width, duration, easingFunction);
}
}
示例5: BeginAnimation
/// <summary>
/// Starts animating a dependency property of a framework element to a
/// target value.
/// </summary>
/// <param name="target">The element to animate.</param>
/// <param name="animatingDependencyProperty">The dependency property to
/// animate.</param>
/// <param name="propertyPath">The path of the dependency property to
/// animate.</param>
/// <param name="targetValue">The value to animate the dependency
/// property to.</param>
/// <param name="timeSpan">The duration of the animation.</param>
/// <param name="easingFunction">The easing function to uses to
/// transition the data points.</param>
public static void BeginAnimation(
this FrameworkElement target,
DependencyProperty animatingDependencyProperty,
string propertyPath,
object targetValue,
TimeSpan timeSpan,
EasingFunctionBase easingFunction)
{
Storyboard storyBoard = target.Resources[GetStoryboardKey(propertyPath)] as Storyboard;
if (storyBoard != null)
{
// Save current value
object currentValue = target.GetValue(animatingDependencyProperty);
storyBoard.Stop();
// RestoreAsync that value so it doesn't snap back to its starting value
target.SetValue(animatingDependencyProperty, currentValue);
target.Resources.Remove(GetStoryboardKey(propertyPath));
}
storyBoard = CreateStoryboard(target, animatingDependencyProperty, propertyPath, ref targetValue, timeSpan, easingFunction);
storyBoard.Completed +=
(source, args) =>
{
storyBoard.Stop();
target.SetValue(animatingDependencyProperty, targetValue);
target.Resources.Remove(GetStoryboardKey(propertyPath));
};
target.Resources.Add(GetStoryboardKey(propertyPath), storyBoard);
storyBoard.Begin();
}
示例6: AnimateScaleXAsync
public static async Task AnimateScaleXAsync(this FrameworkElement element, double x, double duration = 150, EasingFunctionBase easingFunction = null)
{
if (element.GetScaleX() != x)
{
await AnimateDoublePropertyAsync(element.GetCompositeTransform(), "ScaleX", element.GetScaleX(), x, duration, easingFunction);
}
}
示例7: StartAnimation
private void StartAnimation(EasingFunctionBase easingFunction)
{
// show the chart
chartControl.Draw(easingFunction);
// animation
#if WPF
NameScope.SetNameScope(translate1, new NameScope());
#endif
var storyboard = new Storyboard();
var ellipseMove = new DoubleAnimation();
ellipseMove.EasingFunction = easingFunction;
ellipseMove.Duration = new Duration(TimeSpan.FromSeconds(AnimationTimeSeconds));
ellipseMove.From = 0;
ellipseMove.To = 460;
#if WPF
Storyboard.SetTargetName(ellipseMove, nameof(translate1));
Storyboard.SetTargetProperty(ellipseMove, new PropertyPath(TranslateTransform.XProperty));
#else
Storyboard.SetTarget(ellipseMove, translate1);
Storyboard.SetTargetProperty(ellipseMove, "X");
#endif
ellipseMove.BeginTime = TimeSpan.FromSeconds(0.5); // start animation in 0.5 seconds
ellipseMove.FillBehavior = FillBehavior.HoldEnd; // keep position after animation
storyboard.Children.Add(ellipseMove);
#if WPF
storyboard.Begin(this);
#else
storyboard.Begin();
#endif
}
示例8: AnimateYAsync
public static async Task AnimateYAsync(this FrameworkElement element, double y, double duration = 250, EasingFunctionBase easingFunction = null)
{
if (element.GetTranslateY() != y)
{
await AnimateDoublePropertyAsync(element.GetCompositeTransform(), "TranslateY", element.GetTranslateY(), y, duration, easingFunction);
}
}
示例9: AnimateHeight
public static Storyboard AnimateHeight(this FrameworkElement element, double height, double duration = 250, EasingFunctionBase easingFunction = null)
{
if (element.Height != height)
{
return AnimateDoubleProperty(element, "Height", element.ActualHeight, height, duration, easingFunction);
}
return null;
}
示例10: AnimateWidth
public static Storyboard AnimateWidth(this FrameworkElement element, double width, double duration = 250, EasingFunctionBase easingFunction = null)
{
if (element.ActualWidth != width)
{
return AnimateDoubleProperty(element, "Width", element.ActualWidth, width, duration, easingFunction);
}
return null;
}
示例11: AnimateScaleX
public static Storyboard AnimateScaleX(this FrameworkElement element, double x, double duration = 150, EasingFunctionBase easingFunction = null)
{
if (element.GetScaleX() != x)
{
return AnimateDoubleProperty(element.GetCompositeTransform(), "ScaleX", element.GetScaleX(), x, duration, easingFunction);
}
return null;
}
示例12: AnimateY
public static Storyboard AnimateY(this FrameworkElement element, double y, double duration = 250, EasingFunctionBase easingFunction = null)
{
if (element.GetTranslateY() != y)
{
return AnimateDoubleProperty(element.GetCompositeTransform(), "TranslateY", element.GetTranslateY(), y, duration, easingFunction);
}
return null;
}
示例13: FadeIn
public static Storyboard FadeIn(this UIElement element, double duration = 250, EasingFunctionBase easingFunction = null)
{
if (element.Opacity < 1.0)
{
return AnimateDoubleProperty(element, "Opacity", element.Opacity, 1.0, duration, easingFunction);
}
return null;
}
示例14: CreatAnimation
/// <summary>
/// 创建动画
/// </summary>
public static DoubleAnimation CreatAnimation(DependencyObject obj, string path, int duration, EasingFunctionBase easing = null)
{
DoubleAnimation da = new DoubleAnimation();
da.EasingFunction = easing;
da.Duration = TimeSpan.FromMilliseconds(duration);
Storyboard.SetTarget(da, obj);
Storyboard.SetTargetProperty(da, path);
return da;
}
示例15: CreateDoubleAnimation
public static DoubleAnimation CreateDoubleAnimation(double? from, double? to, Duration duration, string targetProperty, DependencyObject target, EasingFunctionBase easing = null)
{
var db = new DoubleAnimation();
db.To = to;
db.From = from;
db.EasingFunction = easing;
db.Duration = duration;
Storyboard.SetTarget(db, target);
Storyboard.SetTargetProperty(db, targetProperty);
return db;
}