本文整理汇总了C#中Windows.UI.Xaml.Media.Animation.Storyboard.Pause方法的典型用法代码示例。如果您正苦于以下问题:C# Storyboard.Pause方法的具体用法?C# Storyboard.Pause怎么用?C# Storyboard.Pause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Media.Animation.Storyboard
的用法示例。
在下文中一共展示了Storyboard.Pause方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefreshButtonClick
private async void RefreshButtonClick(object sender, RoutedEventArgs e)
{
ButtonPointerExited(sender, null);
var m = (MediaListViewModel)((Button)sender).DataContext;
var b = (Button)sender;
int to = 359;
CompositeTransform rotation = b.RenderTransform as CompositeTransform;
if (rotation != null)
{
to = (int)rotation.Rotation + 359;
}
var rotatingStoryboard = new Storyboard();
var opacityAnimation = new DoubleAnimation
{
To = to,
Duration = TimeSpan.FromMilliseconds(500),
RepeatBehavior = RepeatBehavior.Forever
};
rotatingStoryboard.Children.Add(opacityAnimation);
Storyboard.SetTargetProperty(opacityAnimation, "(UIElement.RenderTransform).(CompositeTransform.Rotation)");
Storyboard.SetTarget(rotatingStoryboard, b);
rotatingStoryboard.Begin();
b.IsEnabled = false;
m.IsLoaded = false;
m.CriticalNetworkErrorNotice += OnErrorNotice;
await m.Refresh();
m.CriticalNetworkErrorNotice -= OnErrorNotice;
m.IsLoaded = true;
b.IsEnabled = true;
rotatingStoryboard.Pause();
ButtonPointerExited(sender, null);
}
示例2: AddGunDanmu
/// <summary>
/// 添加滚动弹幕
/// </summary>
/// <param name="model">弹幕参数</param>
/// <param name="Myself">是否自己发送的</param>
public async void AddGunDanmu(DanMuModel model,bool Myself)
{
try
{
//创建基础控件
TextBlock tx = new TextBlock();
TextBlock tx2 = new TextBlock();
Grid grid = new Grid();
//设置控件相关信息
grid.Margin = new Thickness(0, 0, 20, 0);
grid.VerticalAlignment = VerticalAlignment.Center;
grid.HorizontalAlignment = HorizontalAlignment.Left;
if (fontFamily != "默认")
{
tx.FontFamily = new FontFamily(fontFamily);
tx2.FontFamily = new FontFamily(fontFamily);
}
tx2.Text = model.DanText;
tx.Text = model.DanText;
tx2.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
tx.Foreground = model.DanColor;
//弹幕大小
double size = double.Parse(model.DanSize);
if (size == 25)
{
tx2.FontSize = fontSize;
tx.FontSize = fontSize;
}
else
{
tx2.FontSize = fontSize - 2;
tx.FontSize = fontSize - 2;
}
//grid包含弹幕文本信息
grid.Children.Add(tx2);
grid.Children.Add(tx);
grid.VerticalAlignment = VerticalAlignment.Top;
grid.HorizontalAlignment = HorizontalAlignment.Left;
TranslateTransform moveTransform = new TranslateTransform();
moveTransform.X = grid_Danmu.ActualWidth;
grid.RenderTransform = moveTransform;
//将弹幕加载入控件中,并且设置位置
grid_Danmu.Children.Add(grid);
Grid.SetRow(grid, row);
row++;
if (row == maxRow)
{
row = 0;
}
tx2.Margin = new Thickness(1);
if (Myself)
{
grid.BorderThickness = new Thickness(2);
grid.BorderBrush = new SolidColorBrush(Colors.Gray);
}
grid.Opacity = Tran;
grid.DataContext = model;
//更新弹幕UI,不更新无法获得弹幕的ActualWidth
grid.UpdateLayout();
//创建动画
Duration duration = new Duration(TimeSpan.FromSeconds(Speed));
DoubleAnimation myDoubleAnimationX = new DoubleAnimation();
myDoubleAnimationX.Duration = duration;
//创建故事版
Storyboard justintimeStoryboard = new Storyboard();
justintimeStoryboard.Duration = duration;
myDoubleAnimationX.To = -(grid.ActualWidth);//到达
justintimeStoryboard.Children.Add(myDoubleAnimationX);
Storyboard.SetTarget(myDoubleAnimationX, moveTransform);
//故事版加入动画
Storyboard.SetTargetProperty(myDoubleAnimationX, "X");
grid_Danmu.Resources.Remove("justintimeStoryboard");
grid_Danmu.Resources.Add("justintimeStoryboard", justintimeStoryboard);
justintimeStoryboard.Begin();
//等待,暂停则暂停
await Task.Run(async () =>
{
int i = 0;
while (true)
{
if (!IsPlaying)
{
await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
justintimeStoryboard.Pause();
});
//break;
}
else
{
if (i == Speed*2)
{
break;
//.........这里部分代码省略.........