星火微课系统客户端
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

CountdownWindow.xaml.cs 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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 System.Timers.Timer timer;
  22. private int ImgNum = 21;
  23. public void Initialize(bool ShowlblShortcut = false, int changeTime = 2100)
  24. {
  25. if (ShowlblShortcut)
  26. {
  27. lblShortcut.Visibility = Visibility.Visible;
  28. }
  29. else
  30. {
  31. lblShortcut.Visibility = Visibility.Hidden;
  32. }
  33. ImgNum = 21;
  34. bool IsStart = true;
  35. new Thread(new ThreadStart(new Action(() =>
  36. {
  37. while (IsStart)
  38. {
  39. try
  40. {
  41. if (ImgNum >= 1)
  42. {
  43. loadingImg(ImgNum);
  44. LogHelper.WriteInfoLog("【" + ImgNum + "】");
  45. ImgNum--;
  46. Thread.Sleep(changeTime / 21);
  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. LogHelper.WriteInfoLog("【" + ImgNum + "】");
  80. }
  81. else
  82. {
  83. timer.Enabled = false;
  84. Dispatcher.Invoke(
  85. DispatcherPriority.Send,
  86. new Action(() =>
  87. {
  88. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_1.png"));
  89. Hide();
  90. }));
  91. }
  92. }
  93. /// <summary>
  94. /// 加载图片
  95. /// </summary>
  96. /// <param name="num"></param>
  97. private void loadingImg(int num)
  98. {
  99. switch (num)
  100. {
  101. case 1:
  102. Dispatcher.Invoke(
  103. DispatcherPriority.Send,
  104. new Action(() =>
  105. {
  106. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_5.png"));
  107. }));
  108. break;
  109. case 2:
  110. Dispatcher.Invoke(
  111. DispatcherPriority.Send,
  112. new Action(() =>
  113. {
  114. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_4.png"));
  115. }));
  116. break;
  117. case 3:
  118. Dispatcher.Invoke(
  119. DispatcherPriority.Send,
  120. new Action(() =>
  121. {
  122. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_3.png"));
  123. }));
  124. break;
  125. case 4:
  126. Dispatcher.Invoke(
  127. DispatcherPriority.Send,
  128. new Action(() =>
  129. {
  130. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_2.png"));
  131. }));
  132. break;
  133. case 5:
  134. Dispatcher.Invoke(
  135. DispatcherPriority.Send,
  136. new Action(() =>
  137. {
  138. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_1.png"));
  139. }));
  140. break;
  141. case 6:
  142. Dispatcher.Invoke(
  143. DispatcherPriority.Send,
  144. new Action(() =>
  145. {
  146. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_7.png"));
  147. }));
  148. break;
  149. case 7:
  150. Dispatcher.Invoke(
  151. DispatcherPriority.Send,
  152. new Action(() =>
  153. {
  154. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_6.png"));
  155. }));
  156. break;
  157. case 8:
  158. Dispatcher.Invoke(
  159. DispatcherPriority.Send,
  160. new Action(() =>
  161. {
  162. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_5.png"));
  163. }));
  164. break;
  165. case 9:
  166. Dispatcher.Invoke(
  167. DispatcherPriority.Send,
  168. new Action(() =>
  169. {
  170. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_4.png"));
  171. }));
  172. break;
  173. case 10:
  174. Dispatcher.Invoke(
  175. DispatcherPriority.Send,
  176. new Action(() =>
  177. {
  178. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_3.png"));
  179. }));
  180. break;
  181. case 11:
  182. Dispatcher.Invoke(
  183. DispatcherPriority.Send,
  184. new Action(() =>
  185. {
  186. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_2.png"));
  187. }));
  188. break;
  189. case 12:
  190. Dispatcher.Invoke(
  191. DispatcherPriority.Send,
  192. new Action(() =>
  193. {
  194. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_1.png"));
  195. }));
  196. break;
  197. case 13:
  198. Dispatcher.Invoke(
  199. DispatcherPriority.Send,
  200. new Action(() =>
  201. {
  202. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_9.png"));
  203. }));
  204. break;
  205. case 14:
  206. Dispatcher.Invoke(
  207. DispatcherPriority.Send,
  208. new Action(() =>
  209. {
  210. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_8.png"));
  211. }));
  212. break;
  213. case 15:
  214. Dispatcher.Invoke(
  215. DispatcherPriority.Send,
  216. new Action(() =>
  217. {
  218. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_7.png"));
  219. }));
  220. break;
  221. case 16:
  222. Dispatcher.Invoke(
  223. DispatcherPriority.Send,
  224. new Action(() =>
  225. {
  226. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_6.png"));
  227. }));
  228. break;
  229. case 17:
  230. Dispatcher.Invoke(
  231. DispatcherPriority.Send,
  232. new Action(() =>
  233. {
  234. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_5.png"));
  235. }));
  236. break;
  237. case 18:
  238. Dispatcher.Invoke(
  239. DispatcherPriority.Send,
  240. new Action(() =>
  241. {
  242. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_4.png"));
  243. }));
  244. break;
  245. case 19:
  246. Dispatcher.Invoke(
  247. DispatcherPriority.Send,
  248. new Action(() =>
  249. {
  250. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_3.png"));
  251. }));
  252. break;
  253. case 20:
  254. Dispatcher.Invoke(
  255. DispatcherPriority.Send,
  256. new Action(() =>
  257. {
  258. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_2.png"));
  259. }));
  260. break;
  261. case 21:
  262. Dispatcher.Invoke(
  263. DispatcherPriority.Send,
  264. new Action(() =>
  265. {
  266. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_1.png"));
  267. }));
  268. break;
  269. default:
  270. break;
  271. }
  272. }
  273. private void Window_ContentRendered(object sender, EventArgs e)
  274. {
  275. }
  276. }
  277. }