星火微课系统客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

CountdownWindow.xaml.cs 10KB

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