WPF 图片跑马灯

 1 public void OnFlushImage()
 2 {
 3     bool bStart = false;
 4     while (mFlush == true)
 5     {
 6         if (bStart)
 7         {
 8             Thread.Sleep(1000);
 9             continue;
10         }
11 
12         bStart = true;
13 
14         cloudTop.Dispatcher.BeginInvoke(
15         new Action(() =>
16         {
17             Duration duration = new Duration(TimeSpan.FromMilliseconds(20000));  
18             DoubleAnimation daRx = new DoubleAnimation();  
19             daRx.Duration = duration;  
20             daRx.To = 1300;
21             daRx.RepeatBehavior = RepeatBehavior.Forever;
22 
23             cloudTop_tt.BeginAnimation(TranslateTransform.XProperty, daRx);
24         }), null);
25 
26         Thread.Sleep(3000);
27 
28         cloudBottom.Dispatcher.BeginInvoke(
29         new Action(() =>
30         {
31             Duration duration = new Duration(TimeSpan.FromMilliseconds(10000));
32             DoubleAnimation daRx = new DoubleAnimation();
33             daRx.Duration = duration;
34             daRx.To = 1300;
35             daRx.RepeatBehavior = RepeatBehavior.Forever;
36 
37             cloudBottom_tt.BeginAnimation(TranslateTransform.XProperty, daRx);
38         }), null);
39     }
40 
41     // Stop 
42     cloudTop.Dispatcher.BeginInvoke(
43         new Action(() =>
44         {
45             Duration duration = new Duration(TimeSpan.FromMilliseconds(400));
46             DoubleAnimation daRx = new DoubleAnimation();
47             daRx.Duration = duration;
48             daRx.To = 1300;
49 
50             cloudTop_tt.BeginAnimation(TranslateTransform.XProperty, daRx);
51         }), null);
52 
53     cloudBottom.Dispatcher.BeginInvoke(
54     new Action(() =>
55     {
56         Duration duration = new Duration(TimeSpan.FromMilliseconds(400));
57         DoubleAnimation daRx = new DoubleAnimation();
58         daRx.Duration = duration;
59         daRx.To = 1300;
60 
61         cloudBottom_tt.BeginAnimation(TranslateTransform.XProperty, daRx);
62     }), null);
63 
64     Thread.Sleep(1000);
65 
66     // Origin 
67     cloudTop.Dispatcher.BeginInvoke(
68         new Action(() =>
69         {
70             Duration duration = new Duration(TimeSpan.FromMilliseconds(10));
71             DoubleAnimation daRx = new DoubleAnimation();
72             daRx.Duration = duration;
73             daRx.To = 0;
74 
75             cloudTop_tt.BeginAnimation(TranslateTransform.XProperty, daRx);
76         }), null);
77 
78     cloudBottom.Dispatcher.BeginInvoke(
79     new Action(() =>
80     {
81         Duration duration = new Duration(TimeSpan.FromMilliseconds(10));
82         DoubleAnimation daRx = new DoubleAnimation();
83         daRx.Duration = duration;
84         daRx.To = 0;
85 
86         cloudBottom_tt.BeginAnimation(TranslateTransform.XProperty, daRx);
87     }), null);
88 
89     System.Diagnostics.Trace.WriteLine("Flush thread end.");            
90 }

 

转载于:https://www.cnblogs.com/mymeng_feng/p/5177918.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值