wpf 字幕动画切换

zhantianyou zhantianyou 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我用timer计时,在第25秒切换另一个字幕,但是结果动画有点卡住了,显示位置也不正确。过10多少之后才正常
代码如下
//上翻跑马灯
private void playY()
{
this.story = new Storyboard();
this.story2 = new Storyboard();

this.marquee.Background = Brushes.Pink;
this.marquee2.Background = Brushes.Green;
this.grid.Background = Brushes.Yellow;

int intRuntime = 1;



this.textHeight = this.MeasureTextHeight();
this.marquee.Height = this.textHeight;
this.marquee2.Height = this.textHeight;
this.grid.Height = this.textHeight;
marquee2.Content = marquee.Content;

this.rowHeight = this.textHeight;
this.playFrom = this.rowHeight;
this.playTo = 0;

DoubleAnimation animation = new DoubleAnimation();
animation.Duration = TimeSpan.FromSeconds(intRuntime);
animation.From = this.playFrom;
animation.To = this.playTo;

Storyboard.SetTargetName(animation, "lab");
Storyboard.SetTargetProperty(animation, new PropertyPath(TranslateTransform.YProperty));
this.story.Duration = TimeSpan.FromSeconds(intRuntime);
this.story.Children.Add(animation);
this.story.FillBehavior = FillBehavior.Stop;
this.story.Completed += new EventHandler(story_Completed);
this.story.Begin(this, true);

this.playFrom2 = this.playFrom + this.textHeight;
this.playTo2 = this.playFrom2 - this.rowHeight;
DoubleAnimation animation2 = new DoubleAnimation();
animation2.Duration = TimeSpan.FromSeconds(intRuntime);
animation2.From = playFrom2;
animation2.To = playTo2;
Storyboard.SetTargetName(animation2, "lab2");
Storyboard.SetTargetProperty(animation2, new PropertyPath(TranslateTransform.YProperty));
this.story2.Duration = TimeSpan.FromSeconds(intRuntime);
this.story2.Children.Add(animation2);
this.story2.FillBehavior = FillBehavior.Stop;
this.story2.Completed += new EventHandler(story2_Completed);
this.story2.Begin(this, true);
}
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
zhantianyou
C# 111,128 成员 642,536 内容