WPF 图片跑马灯

pansoso2021-04-19  26

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

相关资源:WPF 走马灯特效