本文整理匯總了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;
//.........這裏部分代碼省略.........