星火微课系统客户端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

CountdownWindow.xaml.cs 11KB

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