星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CountdownWindow.xaml.cs 11KB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. using Common.system;
  2. using System;
  3. using System.Threading;
  4. using System.Windows;
  5. using System.Windows.Media.Imaging;
  6. using System.Windows.Threading;
  7. namespace XHWK.WKTool
  8. {
  9. /// <summary>
  10. /// 录屏等待 CountdownWindow.xaml 的交互逻辑
  11. /// </summary>
  12. public partial class CountdownWindow : Window
  13. {
  14. public CountdownWindow()
  15. {
  16. InitializeComponent();
  17. }
  18. /// <summary>
  19. /// 计时器
  20. /// </summary>
  21. private int ImgNum = 22;
  22. public void Initialize(bool ShowlblShortcut = false, int changeTime = 2000)
  23. {
  24. if (ShowlblShortcut)
  25. {
  26. lblShortcut.Visibility = Visibility.Visible;
  27. borShortcut.Visibility = Visibility.Visible;
  28. }
  29. else
  30. {
  31. lblShortcut.Visibility = Visibility.Hidden;
  32. borShortcut.Visibility = Visibility.Hidden;
  33. }
  34. ImgNum = 22;
  35. bool IsStart = true;
  36. new Thread(new ThreadStart(new Action(() =>
  37. {
  38. while (IsStart)
  39. {
  40. try
  41. {
  42. if (ImgNum >= 1)
  43. {
  44. loadingImg(ImgNum);
  45. ImgNum--;
  46. Thread.Sleep(changeTime / 22);
  47. }
  48. else
  49. {
  50. IsStart = false;
  51. Dispatcher.Invoke(
  52. DispatcherPriority.Send,
  53. new Action(() =>
  54. {
  55. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_1.png"));
  56. Hide();
  57. }));
  58. }
  59. }
  60. catch (Exception ex)
  61. {
  62. LogHelper.WriteErrLog("【录屏等待】(Initialize)" + ex.Message, ex);
  63. }
  64. }
  65. }))).Start();
  66. //timer = new System.Timers.Timer(changeTime/21);//设置执行一次(false)还是一直执行(true)
  67. //timer.AutoReset = true;//设置是否执行System.Timers.Timer.Elapsed事件
  68. //timer.Elapsed +=new System.Timers.ElapsedEventHandler(Timer_Elapsed);
  69. ////timer.Interval = changeTime/21;
  70. //timer.Enabled = true; //启动计时器
  71. //ImgNum = 21;
  72. }
  73. private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  74. {
  75. if (ImgNum >= 1)
  76. {
  77. loadingImg(ImgNum);
  78. ImgNum--;
  79. }
  80. else
  81. {
  82. //timer.Enabled = false;
  83. Dispatcher.Invoke(
  84. DispatcherPriority.Send,
  85. new Action(() =>
  86. {
  87. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_1.png"));
  88. Hide();
  89. }));
  90. }
  91. }
  92. /// <summary>
  93. /// 加载图片
  94. /// </summary>
  95. /// <param name="num"></param>
  96. private void loadingImg(int num)
  97. {
  98. switch (num)
  99. {
  100. case 1:
  101. Dispatcher.Invoke(
  102. DispatcherPriority.Send,
  103. new Action(() =>
  104. {
  105. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_7.png"));
  106. }));
  107. break;
  108. case 2:
  109. Dispatcher.Invoke(
  110. DispatcherPriority.Send,
  111. new Action(() =>
  112. {
  113. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_6.png"));
  114. }));
  115. break;
  116. case 3:
  117. Dispatcher.Invoke(
  118. DispatcherPriority.Send,
  119. new Action(() =>
  120. {
  121. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_5.png"));
  122. }));
  123. break;
  124. case 4:
  125. Dispatcher.Invoke(
  126. DispatcherPriority.Send,
  127. new Action(() =>
  128. {
  129. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_4.png"));
  130. }));
  131. break;
  132. case 5:
  133. Dispatcher.Invoke(
  134. DispatcherPriority.Send,
  135. new Action(() =>
  136. {
  137. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_3.png"));
  138. }));
  139. break;
  140. case 6:
  141. Dispatcher.Invoke(
  142. DispatcherPriority.Send,
  143. new Action(() =>
  144. {
  145. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_2.png"));
  146. }));
  147. break;
  148. case 7:
  149. Dispatcher.Invoke(
  150. DispatcherPriority.Send,
  151. new Action(() =>
  152. {
  153. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_1.png"));
  154. }));
  155. break;
  156. case 8:
  157. Dispatcher.Invoke(
  158. DispatcherPriority.Send,
  159. new Action(() =>
  160. {
  161. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_7.png"));
  162. }));
  163. break;
  164. case 9:
  165. Dispatcher.Invoke(
  166. DispatcherPriority.Send,
  167. new Action(() =>
  168. {
  169. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_6.png"));
  170. }));
  171. break;
  172. case 10:
  173. Dispatcher.Invoke(
  174. DispatcherPriority.Send,
  175. new Action(() =>
  176. {
  177. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_5.png"));
  178. }));
  179. break;
  180. case 11:
  181. Dispatcher.Invoke(
  182. DispatcherPriority.Send,
  183. new Action(() =>
  184. {
  185. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_4.png"));
  186. }));
  187. break;
  188. case 12:
  189. Dispatcher.Invoke(
  190. DispatcherPriority.Send,
  191. new Action(() =>
  192. {
  193. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_3.png"));
  194. }));
  195. break;
  196. case 13:
  197. Dispatcher.Invoke(
  198. DispatcherPriority.Send,
  199. new Action(() =>
  200. {
  201. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_2.png"));
  202. }));
  203. break;
  204. case 14:
  205. Dispatcher.Invoke(
  206. DispatcherPriority.Send,
  207. new Action(() =>
  208. {
  209. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_1.png"));
  210. }));
  211. break;
  212. case 15:
  213. Dispatcher.Invoke(
  214. DispatcherPriority.Send,
  215. new Action(() =>
  216. {
  217. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_8.png"));
  218. }));
  219. break;
  220. case 16:
  221. Dispatcher.Invoke(
  222. DispatcherPriority.Send,
  223. new Action(() =>
  224. {
  225. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_7.png"));
  226. }));
  227. break;
  228. case 17:
  229. Dispatcher.Invoke(
  230. DispatcherPriority.Send,
  231. new Action(() =>
  232. {
  233. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_6.png"));
  234. }));
  235. break;
  236. case 18:
  237. Dispatcher.Invoke(
  238. DispatcherPriority.Send,
  239. new Action(() =>
  240. {
  241. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_5.png"));
  242. }));
  243. break;
  244. case 19:
  245. Dispatcher.Invoke(
  246. DispatcherPriority.Send,
  247. new Action(() =>
  248. {
  249. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_4.png"));
  250. }));
  251. break;
  252. case 20:
  253. Dispatcher.Invoke(
  254. DispatcherPriority.Send,
  255. new Action(() =>
  256. {
  257. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_3.png"));
  258. }));
  259. break;
  260. case 21:
  261. Dispatcher.Invoke(
  262. DispatcherPriority.Send,
  263. new Action(() =>
  264. {
  265. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_2.png"));
  266. }));
  267. break;
  268. case 22:
  269. Dispatcher.Invoke(
  270. DispatcherPriority.Send,
  271. new Action(() =>
  272. {
  273. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_1.png"));
  274. }));
  275. break;
  276. default:
  277. break;
  278. }
  279. }
  280. private void Window_ContentRendered(object sender, EventArgs e)
  281. {
  282. }
  283. }
  284. }