星火微课系统客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

CountdownWindow.xaml.cs 11KB

4 年前
4 年前
4 年前
4 年前
4 年前
4 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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 = 21;
  22. public void Initialize(bool ShowlblShortcut = false, int changeTime = 2100)
  23. {
  24. //if (ShowlblShortcut)
  25. //{
  26. // lblShortcut.Visibility = Visibility.Visible;
  27. //}
  28. //else
  29. //{
  30. // lblShortcut.Visibility = Visibility.Hidden;
  31. //}
  32. ImgNum = 21;
  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. LogHelper.WriteInfoLog("【" + ImgNum + "】");
  44. ImgNum--;
  45. Thread.Sleep(changeTime / 21);
  46. }
  47. else
  48. {
  49. IsStart = false;
  50. Dispatcher.Invoke(
  51. DispatcherPriority.Send,
  52. new Action(() =>
  53. {
  54. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_1.png"));
  55. Hide();
  56. }));
  57. }
  58. }
  59. catch (Exception ex)
  60. {
  61. LogHelper.WriteErrLog("【录屏等待】(Initialize)" + ex.Message, ex);
  62. }
  63. }
  64. }))).Start();
  65. //timer = new System.Timers.Timer(changeTime/21);//设置执行一次(false)还是一直执行(true)
  66. //timer.AutoReset = true;//设置是否执行System.Timers.Timer.Elapsed事件
  67. //timer.Elapsed +=new System.Timers.ElapsedEventHandler(Timer_Elapsed);
  68. ////timer.Interval = changeTime/21;
  69. //timer.Enabled = true; //启动计时器
  70. //ImgNum = 21;
  71. }
  72. private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  73. {
  74. if (ImgNum >= 1)
  75. {
  76. loadingImg(ImgNum);
  77. ImgNum--;
  78. LogHelper.WriteInfoLog("【" + 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_5.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_4.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_3.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_2.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_1.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/countdown2_7.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/countdown2_6.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_5.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_4.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_3.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_2.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_1.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/countdown3_9.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/countdown3_8.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_7.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_6.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_5.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_4.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_3.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_2.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_1.png"));
  266. }));
  267. break;
  268. default:
  269. break;
  270. }
  271. }
  272. private void Window_ContentRendered(object sender, EventArgs e)
  273. {
  274. }
  275. }
  276. }