|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- using Common.system;
-
- using System;
- using System.Threading;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media.Imaging;
- using System.Windows.Threading;
-
- namespace XHWK.WKTool
- {
- /// <summary>
- /// 录屏等待 CountdownWindow.xaml 的交互逻辑
- /// </summary>
- public partial class CountdownWindow : Window
- {
- public CountdownWindow()
- {
- InitializeComponent();
- }
- /// <summary>
- /// 计时器
- /// </summary>
- System.Timers.Timer timer;
- int ImgNum = 21;
- public void Initialize(bool ShowlblShortcut=false, int changeTime=2100)
- {
- if (ShowlblShortcut)
- {
- lblShortcut.Visibility = Visibility.Visible;
- }
- else
- {
- lblShortcut.Visibility = Visibility.Hidden;
- }
- ImgNum = 21;
- bool IsStart = true;
- new Thread(new ThreadStart(new Action(() =>
- {
- while (IsStart)
- {
- try
- {
- if (ImgNum >= 1)
- {
- loadingImg(ImgNum);
- LogHelper.WriteInfoLog("【" + ImgNum + "】");
- ImgNum--;
- Thread.Sleep(changeTime / 21);
- }
- else
- {
- IsStart = false;
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() =>
- {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_1.png"));
- Hide();
- }));
- }
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【录屏等待】(Initialize)" + ex.Message, ex);
- }
- }
- }))).Start();
- //timer = new System.Timers.Timer(changeTime/21);//设置执行一次(false)还是一直执行(true)
- //timer.AutoReset = true;//设置是否执行System.Timers.Timer.Elapsed事件
- //timer.Elapsed +=new System.Timers.ElapsedEventHandler(Timer_Elapsed);
- ////timer.Interval = changeTime/21;
- //timer.Enabled = true; //启动计时器
- //ImgNum = 21;
- }
-
- private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
- {
- if (ImgNum >= 1)
- {
- loadingImg(ImgNum);
- ImgNum--;
- LogHelper.WriteInfoLog("【"+ImgNum+"】");
- }
- else
- {
- timer.Enabled = false;
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() =>
- {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_1.png"));
- Hide();
- }));
- }
- }
- /// <summary>
- /// 加载图片
- /// </summary>
- /// <param name="num"></param>
- void loadingImg(int num)
- {
- switch (num)
- {
- case 1:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_5.png"));
- }));
- break;
- case 2:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_4.png"));
- }));
- break;
- case 3:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_3.png"));
- }));
- break;
- case 4:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_2.png"));
- }));
- break;
- case 5:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown1_1.png"));
- }));
- break;
- case 6:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_7.png"));
- }));
- break;
- case 7:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_6.png"));
- }));
- break;
- case 8:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_5.png"));
- }));
- break;
- case 9:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_4.png"));
- }));
- break;
- case 10:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_3.png"));
- }));
- break;
- case 11:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_2.png"));
- }));
- break;
- case 12:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown2_1.png"));
- }));
- break;
- case 13:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_9.png"));
- }));
- break;
- case 14:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_8.png"));
- }));
- break;
- case 15:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_7.png"));
- }));
- break;
- case 16:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_6.png"));
- }));
- break;
- case 17:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_5.png"));
- }));
- break;
- case 18:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_4.png"));
- }));
- break;
- case 19:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_3.png"));
- }));
- break;
- case 20:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_2.png"));
- }));
- break;
- case 21:
- Dispatcher.Invoke(
- DispatcherPriority.Send,
- new Action(() => {
- imgLoding.Source = new BitmapImage(new Uri("pack://application:,,/Images/countdown3_1.png"));
- }));
- break;
- default:
- break;
- }
- }
-
- private void Window_ContentRendered(object sender, EventArgs e)
- {
-
- }
-
- }
- }
|