UCWaitingProgress.xaml.cs 901 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Media.Animation;
  4. namespace ClickOnceSetup
  5. {
  6. /// <summary>
  7. /// UCWaitingProgress.xaml 的交互逻辑
  8. /// </summary>
  9. public partial class UCWaitingProgress
  10. {
  11. private Storyboard storyboard;
  12. public UCWaitingProgress()
  13. {
  14. InitializeComponent();
  15. storyboard = (Resources["waiting"] as Storyboard);
  16. }
  17. private void Image_Loaded(object sender, RoutedEventArgs e)
  18. {
  19. Begin();
  20. }
  21. public void Begin()
  22. {
  23. Dispatcher.BeginInvoke(new Action(() =>
  24. {
  25. storyboard.Begin(image, true);
  26. }));
  27. }
  28. public void Stop()
  29. {
  30. Dispatcher.BeginInvoke(new Action(() =>
  31. {
  32. storyboard.Pause(image);
  33. }));
  34. }
  35. }
  36. }