当前位置: 首页>>代码示例>>C#>>正文


C# Storyboard.Resume方法代码示例

本文整理汇总了C#中Windows.UI.Xaml.Media.Animation.Storyboard.Resume方法的典型用法代码示例。如果您正苦于以下问题:C# Storyboard.Resume方法的具体用法?C# Storyboard.Resume怎么用?C# Storyboard.Resume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.UI.Xaml.Media.Animation.Storyboard的用法示例。


在下文中一共展示了Storyboard.Resume方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddGunDanmu


//.........这里部分代码省略.........
                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;
                            }
                            i++;
                            await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
                                justintimeStoryboard.Resume();
                            });
                        }
                        await Task.Delay(500);
                    }
                });
                grid_Danmu.Children.Remove(grid);
            }
            catch (Exception)
            {
            }
        }
开发者ID:GeminiLab,项目名称:BiliBili-UWP,代码行数:101,代码来源:MyDanmaku.xaml.cs


注:本文中的Windows.UI.Xaml.Media.Animation.Storyboard.Resume方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。