星火微课系统客户端
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 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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 = 3000)
  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 >= 0)
  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. }
  67. private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  68. {
  69. if (ImgNum >= 1)
  70. {
  71. loadingImg(ImgNum);
  72. ImgNum--;
  73. }
  74. else
  75. {
  76. //timer.Enabled = false;
  77. Dispatcher.Invoke(
  78. DispatcherPriority.Send,
  79. new Action(() =>
  80. {
  81. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_1.png"));
  82. Hide();
  83. }));
  84. }
  85. }
  86. /// <summary>
  87. /// 加载图片
  88. /// </summary>
  89. /// <param name="num"></param>
  90. private void loadingImg(int num)
  91. {
  92. switch (num)
  93. {
  94. case 1:
  95. Dispatcher.Invoke(
  96. DispatcherPriority.Send,
  97. new Action(() =>
  98. {
  99. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_7.png"));
  100. }));
  101. break;
  102. case 2:
  103. Dispatcher.Invoke(
  104. DispatcherPriority.Send,
  105. new Action(() =>
  106. {
  107. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_6.png"));
  108. }));
  109. break;
  110. case 3:
  111. Dispatcher.Invoke(
  112. DispatcherPriority.Send,
  113. new Action(() =>
  114. {
  115. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_5.png"));
  116. }));
  117. break;
  118. case 4:
  119. Dispatcher.Invoke(
  120. DispatcherPriority.Send,
  121. new Action(() =>
  122. {
  123. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_4.png"));
  124. }));
  125. break;
  126. case 5:
  127. Dispatcher.Invoke(
  128. DispatcherPriority.Send,
  129. new Action(() =>
  130. {
  131. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_3.png"));
  132. }));
  133. break;
  134. case 6:
  135. Dispatcher.Invoke(
  136. DispatcherPriority.Send,
  137. new Action(() =>
  138. {
  139. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_2.png"));
  140. }));
  141. break;
  142. case 7:
  143. Dispatcher.Invoke(
  144. DispatcherPriority.Send,
  145. new Action(() =>
  146. {
  147. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_1.png"));
  148. }));
  149. break;
  150. case 8:
  151. Dispatcher.Invoke(
  152. DispatcherPriority.Send,
  153. new Action(() =>
  154. {
  155. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_7.png"));
  156. }));
  157. break;
  158. case 9:
  159. Dispatcher.Invoke(
  160. DispatcherPriority.Send,
  161. new Action(() =>
  162. {
  163. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_6.png"));
  164. }));
  165. break;
  166. case 10:
  167. Dispatcher.Invoke(
  168. DispatcherPriority.Send,
  169. new Action(() =>
  170. {
  171. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_5.png"));
  172. }));
  173. break;
  174. case 11:
  175. Dispatcher.Invoke(
  176. DispatcherPriority.Send,
  177. new Action(() =>
  178. {
  179. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_4.png"));
  180. }));
  181. break;
  182. case 12:
  183. Dispatcher.Invoke(
  184. DispatcherPriority.Send,
  185. new Action(() =>
  186. {
  187. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_3.png"));
  188. }));
  189. break;
  190. case 13:
  191. Dispatcher.Invoke(
  192. DispatcherPriority.Send,
  193. new Action(() =>
  194. {
  195. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_2.png"));
  196. }));
  197. break;
  198. case 14:
  199. Dispatcher.Invoke(
  200. DispatcherPriority.Send,
  201. new Action(() =>
  202. {
  203. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_1.png"));
  204. }));
  205. break;
  206. case 15:
  207. Dispatcher.Invoke(
  208. DispatcherPriority.Send,
  209. new Action(() =>
  210. {
  211. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_8.png"));
  212. }));
  213. break;
  214. case 16:
  215. Dispatcher.Invoke(
  216. DispatcherPriority.Send,
  217. new Action(() =>
  218. {
  219. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_7.png"));
  220. }));
  221. break;
  222. case 17:
  223. Dispatcher.Invoke(
  224. DispatcherPriority.Send,
  225. new Action(() =>
  226. {
  227. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_6.png"));
  228. }));
  229. break;
  230. case 18:
  231. Dispatcher.Invoke(
  232. DispatcherPriority.Send,
  233. new Action(() =>
  234. {
  235. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_5.png"));
  236. }));
  237. break;
  238. case 19:
  239. Dispatcher.Invoke(
  240. DispatcherPriority.Send,
  241. new Action(() =>
  242. {
  243. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_4.png"));
  244. }));
  245. break;
  246. case 20:
  247. Dispatcher.Invoke(
  248. DispatcherPriority.Send,
  249. new Action(() =>
  250. {
  251. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_3.png"));
  252. }));
  253. break;
  254. case 21:
  255. Dispatcher.Invoke(
  256. DispatcherPriority.Send,
  257. new Action(() =>
  258. {
  259. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_2.png"));
  260. }));
  261. break;
  262. case 22:
  263. Dispatcher.Invoke(
  264. DispatcherPriority.Send,
  265. new Action(() =>
  266. {
  267. imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_1.png"));
  268. }));
  269. break;
  270. default:
  271. break;
  272. }
  273. }
  274. private void Window_ContentRendered(object sender, EventArgs e)
  275. {
  276. }
  277. }
  278. }