星火微课系统客户端
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

CountdownWindow.xaml.cs 10KB

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