本文整理汇总了C#中Windows.UI.Xaml.Media.Animation.Storyboard.Seek方法的典型用法代码示例。如果您正苦于以下问题:C# Storyboard.Seek方法的具体用法?C# Storyboard.Seek怎么用?C# Storyboard.Seek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Media.Animation.Storyboard
的用法示例。
在下文中一共展示了Storyboard.Seek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCloud
public async Task<int> CreateCloud(bool isInitial) {
var cloud = new Image {
Source = new BitmapImage(new Uri("ms-appx:/Assets/BackgroundClouds.png")),
Width = Random.Next(800, 2000),
Stretch = Stretch.Uniform,
Visibility = Visibility.Collapsed
};
Children.Add(cloud);
await cloud.WaitForNonZeroSizeAsync();
var cloudYMax = (int)(ActualHeight - cloud.ActualHeight / 2);
var cloudY = TopMargin > cloudYMax
? TopMargin
: Random.Next(TopMargin, cloudYMax);
SetTop(cloud, cloudY);
SetZIndex(cloud, (int)cloud.Width);
var time = BaseTime * 1000 + (int)(Random.NextDouble() * RandomTime * 1000);
var from = (int)(-cloud.Width);
var to = (int)ActualWidth;
SetLeft(cloud, from);
var storyboard = new Storyboard();
var animation = new DoubleAnimation {
AutoReverse = false,
Duration = new Duration(TimeSpan.FromMilliseconds(time)),
RepeatBehavior = new RepeatBehavior(1),
From = from,
To = to,
EnableDependentAnimation = true,
};
animation.Completed += delegate {
Children.Remove(cloud);
};
storyboard.Children.Add(animation);
Storyboard.SetTarget(animation, cloud);
Storyboard.SetTargetProperty(animation, "(Canvas.Left)");
Resources.Add(Guid.NewGuid().ToString(), storyboard);
storyboard.Begin();
if (isInitial) {
storyboard.Seek(TimeSpan.FromMilliseconds(Random.Next(0, time)));
}
cloud.Visibility = Visibility.Visible;
return time;
}
示例2: OnBorderTapped
//.........这里部分代码省略.........
if (currentCall != _onBorderTappedCall)
{
return;
}
const double revolutionDurationInS = 30d;
foreach (var child in grid.Children)
{
child.RenderTransform = new CompositeTransform();
child.RenderTransformOrigin = new Point(0.5, 0.5);
var nc = (NamedColor)((FrameworkElement)child).DataContext;
var hsv = nc.Color.ToHsl();
var actualPosition = child.TransformToVisual(grid).TransformPoint(new Point(0, 0));
var sb = new Storyboard();
sb.RepeatBehavior = RepeatBehavior.Forever;
var minX = center.X - center.X * (0.25 + 0.75 * Math.Min(hsv.L, hsv.S)) - actualPosition.X;
var midX = center.X - actualPosition.X;
var maxX = center.X + center.X * (0.25 + 0.75 * Math.Min(hsv.L, hsv.S)) - actualPosition.X;
var minY = center.Y - center.Y * (0.25 + 0.75 * Math.Min(hsv.L, hsv.S)) - actualPosition.Y;
var midY = center.Y - actualPosition.Y;
var maxY = center.Y + center.Y * (0.25 + 0.75 * Math.Min(hsv.L, hsv.S)) - actualPosition.Y;
var xa = new DoubleAnimationUsingKeyFrames();
xa.KeyFrames.Add(new DiscreteDoubleKeyFrame { KeyTime = TimeSpan.Zero, Value = midX});
xa.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = TimeSpan.FromSeconds(revolutionDurationInS * 0.25), Value = maxX, EasingFunction = new SineEase { EasingMode = EasingMode.EaseOut } });
xa.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = TimeSpan.FromSeconds(revolutionDurationInS * 0.50), Value = midX, EasingFunction = new SineEase { EasingMode = EasingMode.EaseIn } });
xa.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = TimeSpan.FromSeconds(revolutionDurationInS * 0.75), Value = minX, EasingFunction = new SineEase { EasingMode = EasingMode.EaseOut } });
xa.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = TimeSpan.FromSeconds(revolutionDurationInS * 1.00), Value = midX, EasingFunction = new SineEase { EasingMode = EasingMode.EaseIn } });
Storyboard.SetTarget(xa, child.RenderTransform);
Storyboard.SetTargetProperty(xa, "TranslateX");
sb.Children.Add(xa);
var ya = new DoubleAnimationUsingKeyFrames();
ya.KeyFrames.Add(new DiscreteDoubleKeyFrame { KeyTime = TimeSpan.Zero, Value = minY });
ya.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = TimeSpan.FromSeconds(revolutionDurationInS * 0.25), Value = midY, EasingFunction = new SineEase { EasingMode = EasingMode.EaseIn } });
ya.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = TimeSpan.FromSeconds(revolutionDurationInS * 0.50), Value = maxY, EasingFunction = new SineEase { EasingMode = EasingMode.EaseOut } });
ya.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = TimeSpan.FromSeconds(revolutionDurationInS * 0.75), Value = midY, EasingFunction = new SineEase { EasingMode = EasingMode.EaseIn } });
ya.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = TimeSpan.FromSeconds(revolutionDurationInS * 1.00), Value = minY, EasingFunction = new SineEase { EasingMode = EasingMode.EaseOut } });
Storyboard.SetTarget(ya, child.RenderTransform);
Storyboard.SetTargetProperty(ya, "TranslateY");
sb.Children.Add(ya);
var aa = new DoubleAnimation();
aa.Duration = TimeSpan.FromSeconds(revolutionDurationInS);
aa.From = 0;
aa.To = 360;
Storyboard.SetTarget(aa, child.RenderTransform);
Storyboard.SetTargetProperty(aa, "Rotation");
sb.Children.Add(aa);
//sb.BeginTime =
// TimeSpan.FromSeconds(hsv.H * revolutionDurationInS / 360d);
sb.Begin();
sb.Seek(TimeSpan.FromSeconds(((hsv.H + 360) % 360) * revolutionDurationInS / 360d));
}
}
else
{
var sb = new Storyboard();
var beginTime = TimeSpan.Zero;
foreach (var child in grid.Children)
{
//var nc = (NamedColor)((FrameworkElement)child).DataContext;
var xa = new DoubleAnimation();
xa.BeginTime = beginTime;
xa.Duration = TimeSpan.FromSeconds(1);
xa.To = 0;
Storyboard.SetTarget(xa, child.RenderTransform);
Storyboard.SetTargetProperty(xa, "TranslateX");
sb.Children.Add(xa);
var ya = new DoubleAnimation();
ya.BeginTime = beginTime;
ya.Duration = TimeSpan.FromSeconds(1);
ya.To = 0;
Storyboard.SetTarget(ya, child.RenderTransform);
Storyboard.SetTargetProperty(ya, "TranslateY");
sb.Children.Add(ya);
var aa = new DoubleAnimation();
aa.BeginTime = beginTime;
aa.Duration = TimeSpan.FromSeconds(1);
aa.To = 0;
Storyboard.SetTarget(aa, child.RenderTransform);
Storyboard.SetTargetProperty(aa, "Rotation");
sb.Children.Add(aa);
//beginTime += TimeSpan.FromMilliseconds(5);
}
await sb.BeginAsync();
}
_isArrangedInGrid = !_isArrangedInGrid;
_inAnimation = false;
}