Ejemplo n.º 1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            in_commission = true;
            Console.Write("倒數  被啟動 , timer1  被啟動  ");

            label18.Text = "" + second;
            label17.Text = "" + minute;
            label14.Text = "" + hour;

            if (second < 10)
                label16.Visible = true;
            else
                label16.Visible = false;

            if (minute < 10)
                label15.Visible = true;
            else
                label15.Visible = false;


            //倒數設定
            if (second == 0)
            {
                second = 60;
                minute--;
            }


            if (second == 60 && hour == 0 && minute == 0)
            { minute = 0; }

            if (hour > 0 && minute < 0)
            { minute = 59; hour--; }

            second--;

            //1分鐘前提醒
            if (hour == 0 && minute < 1 && checkBox1.Checked && first)
            {
                first = false;
                Clock_show cs = new Clock_show(second);
                cs.buttonClickedEvent += form2ButtonClicked;
                cs.Show();
            }


            //倒數關機
            if (minute == 0 && hour == 0 && second == 0
                && radioButton1.Checked && radioButton6.Checked)
            {
                Console.Write("倒數關機");
                ProcessStartInfo info = new ProcessStartInfo(FileLink, "-s -f -t 0 ");
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process shutDown = Process.Start(info);
                label18.Text = "0";
            }

            //倒數重新開機
            if (minute == 0 && hour == 0 && second == 0
                 && radioButton2.Checked && radioButton6.Checked)
            {
                Console.Write("重新開機");
                ProcessStartInfo info = new ProcessStartInfo(FileLink, "-r  ");
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process shutDown = Process.Start(info);
                label18.Text = "0";
            }

            //倒數休眠
            if (minute == 0 && hour == 0 && second == 0
                 && radioButton3.Checked && radioButton6.Checked)
            {
                Console.Write("倒數休眠");
                ProcessStartInfo info = new ProcessStartInfo(FileLink, " -h  ");
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process shutDown = Process.Start(info);
                label18.Text = "0";
            }

            //倒數登出
            if (minute == 0 && hour == 0 && second == 0
                && radioButton4.Checked && radioButton6.Checked)
            {
                Console.Write("倒數登出");
                ProcessStartInfo info = new ProcessStartInfo(FileLink, "-l ");
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process shutDown = Process.Start(info);
                label18.Text = "0";
            }

            //倒數鬧鐘
            if (minute == 0 && hour == 0 && second == 0
                && radioButton8.Checked && radioButton6.Checked)
            {
                Console.Write("倒數鬧鐘");

                //播放音樂
                string play_file = power_APP.Properties.Settings.Default.clock_user;

                if (play_file.Contains(".mp3"))
                {
                    wplayer.URL = play_file;
                    wplayer.controls.play();
                }
                else
                {
                    SoundPlayer myMusic = new SoundPlayer(play_file);
                    myMusic.Play();
                }

                Timeup TP = new Timeup();
                TP.Show();
                label18.Text = "0";
            }

            //倒數訊息
            if (minute == 0 && hour == 0 && second == 0
                && radioButton9.Checked && radioButton6.Checked)
            {
                Console.Write("倒數訊息");
                Message_show MS = new Message_show();
                MS.Show();
                label18.Text = "0";
            }

            //倒數執行程式
            if (minute == 0 && hour == 0 && second == 0
                && radioButton7.Checked && radioButton6.Checked)
            {
                string exe_pro = power_APP.Properties.Settings.Default.exe_user;
                ProcessStartInfo info = new ProcessStartInfo(exe_pro);
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process exe = Process.Start(info);
                label18.Text = "0";
            }

            //倒數關閉螢幕
            if (minute == 0 && hour == 0 && second == 0
                && radioButton10.Checked && radioButton6.Checked)
            {
                SendMessage(this.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, 2);//DLL function
                label18.Text = "0";
            }

            if (hour == 0 && minute == 0 && second == 0)
            {
                timer1.Stop();
            }
        }
Ejemplo n.º 2
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            Console.Write("指定時間  timer2  被啟動    ");
            in_commission = true;

            Console.WriteLine("hour:" + power_APP.Properties.Settings.Default.point_hour);
            Console.WriteLine("minute:" + power_APP.Properties.Settings.Default.point_minute);


            //1分鐘前提醒
            if (Convert.ToInt32(power_APP.Properties.Settings.Default.point_hour) == Convert.ToInt32(DateTime.Now.ToString("HH"))
               && Convert.ToInt32(power_APP.Properties.Settings.Default.point_minute) - 1 == Convert.ToInt32(DateTime.Now.ToString("mm"))
               && Convert.ToInt32(power_APP.Properties.Settings.Default.point_second) == Convert.ToInt32(DateTime.Now.ToString("ss"))
               && checkBox1.Checked && first
               && DateTime.Now.Year.ToString() == power_APP.Properties.Settings.Default.year
               && DateTime.Now.Month.ToString() == power_APP.Properties.Settings.Default.month
               && DateTime.Now.Day.ToString() == power_APP.Properties.Settings.Default.day
                )
            {
                first = false;
                Clock_show cs = new Clock_show(60);
                cs.buttonClickedEvent += form2ButtonClicked;
                cs.Show();
            }


            //指定關機
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.point_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.point_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.point_second
               && radioButton1.Checked && radioButton5.Checked
               && DateTime.Now.Year.ToString() == power_APP.Properties.Settings.Default.year
               && DateTime.Now.Month.ToString() == power_APP.Properties.Settings.Default.month
               && DateTime.Now.Day.ToString() == power_APP.Properties.Settings.Default.day
                )
            {
                Console.Write("指定關機");
                ProcessStartInfo info = new ProcessStartInfo(FileLink, "-s -f -t 0 ");
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process shutDown = Process.Start(info);
                timer2.Stop();
            }

            //指定重新開機
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.point_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.point_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.point_second
                && radioButton2.Checked && radioButton5.Checked
                && DateTime.Now.Year.ToString() == power_APP.Properties.Settings.Default.year
               && DateTime.Now.Month.ToString() == power_APP.Properties.Settings.Default.month
               && DateTime.Now.Day.ToString() == power_APP.Properties.Settings.Default.day)
            {
                Console.Write("指定重新開機");
                ProcessStartInfo info = new ProcessStartInfo(FileLink, "-r  ");
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process shutDown = Process.Start(info);
                timer2.Stop();
            }

            //指定休眠
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.point_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.point_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.point_second
                && radioButton3.Checked && radioButton5.Checked
                && DateTime.Now.Year.ToString() == power_APP.Properties.Settings.Default.year
               && DateTime.Now.Month.ToString() == power_APP.Properties.Settings.Default.month
               && DateTime.Now.Day.ToString() == power_APP.Properties.Settings.Default.day)
            {
                Console.Write("指定休眠");
                ProcessStartInfo info = new ProcessStartInfo(FileLink, " -h  ");
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process shutDown = Process.Start(info);
                timer2.Stop();
            }
            // 指定登出
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.point_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.point_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.point_second
                && radioButton4.Checked && radioButton5.Checked
                && DateTime.Now.Year.ToString() == power_APP.Properties.Settings.Default.year
               && DateTime.Now.Month.ToString() == power_APP.Properties.Settings.Default.month
               && DateTime.Now.Day.ToString() == power_APP.Properties.Settings.Default.day)
            {
                Console.Write("指定登出");
                ProcessStartInfo info = new ProcessStartInfo(FileLink, "-l ");
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process shutDown = Process.Start(info);
                timer2.Stop();
            }

            // 指定時間啟動鬧鐘
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.point_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.point_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.point_second
                && radioButton8.Checked && radioButton5.Checked
                && DateTime.Now.Year.ToString() == power_APP.Properties.Settings.Default.year
               && DateTime.Now.Month.ToString() == power_APP.Properties.Settings.Default.month
               && DateTime.Now.Day.ToString() == power_APP.Properties.Settings.Default.day)
            {
                //播放音樂
                string play_file = power_APP.Properties.Settings.Default.clock_user;

                if (play_file.Contains(".mp3"))
                {
                    wplayer.URL = play_file;
                    wplayer.controls.play();
                }
                else
                {
                    SoundPlayer myMusic = new SoundPlayer(play_file);
                    myMusic.Play();
                }

                Timeup TP = new Timeup();
                TP.Show();

                timer2.Stop();
            }

            // 指定時間啟動文字訊息
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.point_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.point_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.point_second
                && radioButton9.Checked && radioButton5.Checked
                && DateTime.Now.Year.ToString() == power_APP.Properties.Settings.Default.year
               && DateTime.Now.Month.ToString() == power_APP.Properties.Settings.Default.month
               && DateTime.Now.Day.ToString() == power_APP.Properties.Settings.Default.day)
            {
                Console.Write("倒數訊息");
                Message_show MS = new Message_show();
                MS.Show();
                timer2.Stop();
            }

            // 指定時間啟動程式
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.point_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.point_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.point_second
                && radioButton7.Checked && radioButton5.Checked
                && DateTime.Now.Year.ToString() == power_APP.Properties.Settings.Default.year
               && DateTime.Now.Month.ToString() == power_APP.Properties.Settings.Default.month
               && DateTime.Now.Day.ToString() == power_APP.Properties.Settings.Default.day)
            {
                Console.Write("倒數啟動程式");
                string exe_pro = power_APP.Properties.Settings.Default.exe_user;
                ProcessStartInfo info = new ProcessStartInfo(exe_pro);
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process exe = Process.Start(info);
                timer2.Stop();
            }


            // 指定時間關閉螢幕
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.point_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.point_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.point_second
                && radioButton10.Checked && radioButton5.Checked
                && DateTime.Now.Year.ToString() == power_APP.Properties.Settings.Default.year
               && DateTime.Now.Month.ToString() == power_APP.Properties.Settings.Default.month
               && DateTime.Now.Day.ToString() == power_APP.Properties.Settings.Default.day)
            {
                Console.Write("倒數關閉螢幕");
                SendMessage(this.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, 2);//DLL function
                timer2.Stop();
            }


            try
            {
                if (show_title)
                {
                    show_title = false;
                    Form1.ActiveForm.Text = "只動時間自動排程-執行中";
                }
            }
            catch
            {

            }
        }
Ejemplo n.º 3
0
        private void timer3_Tick(object sender, EventArgs e)
        {
            Console.Write("每天排程   timer3   被啟動    ");


            //1分鐘前提醒
            if (Convert.ToInt32(power_APP.Properties.Settings.Default.everyday_hour) == Convert.ToInt32(DateTime.Now.ToString("HH"))
               && Convert.ToInt32(power_APP.Properties.Settings.Default.everyday_minute) - 1 == Convert.ToInt32(DateTime.Now.ToString("mm"))
               && Convert.ToInt32(power_APP.Properties.Settings.Default.everyday_second) == Convert.ToInt32(DateTime.Now.ToString("ss"))
               && checkBox1.Checked && first
                )
            {
                first = false;
                Clock_show cs = new Clock_show(60);
                cs.buttonClickedEvent += form2ButtonClicked;
                cs.Show();
            }


            //每天 關機
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.everyday_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.everyday_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.everyday_second
               && power_APP.Properties.Settings.Default.Shutdown
                )
            {
                Console.Write("指定關機");
                ProcessStartInfo info = new ProcessStartInfo(FileLink, "-s -f -t 0 ");
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process shutDown = Process.Start(info);
                timer3.Stop();
            }

            //每天 重新開機
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.everyday_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.everyday_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.everyday_second
                && power_APP.Properties.Settings.Default.Reboot
         )
            {
                Console.Write("指定重新開機");
                ProcessStartInfo info = new ProcessStartInfo(FileLink, "-r  ");
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process shutDown = Process.Start(info);
                timer3.Stop();
            }

            //每天  休眠
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.everyday_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.everyday_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.everyday_second
                && power_APP.Properties.Settings.Default.Sleep
         )
            {
                Console.Write("指定休眠");
                ProcessStartInfo info = new ProcessStartInfo(FileLink, " -h  ");
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process shutDown = Process.Start(info);
                timer3.Stop();
            }

            // 每天  登出
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.everyday_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.everyday_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.everyday_second
                && power_APP.Properties.Settings.Default.Signout
         )
            {
                Console.Write("指定登出");
                ProcessStartInfo info = new ProcessStartInfo(FileLink, "-l ");
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process shutDown = Process.Start(info);
                timer3.Stop();
            }

            // 每天  啟動鬧鐘
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.everyday_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.everyday_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.everyday_second
                && power_APP.Properties.Settings.Default.AlarmClock
         )
            {
                //播放音樂
                string play_file = power_APP.Properties.Settings.Default.clock_user;

                if (play_file.Contains(".mp3"))
                {
                    wplayer.URL = play_file;
                    wplayer.controls.play();
                }
                else
                {
                    SoundPlayer myMusic = new SoundPlayer(play_file);
                    myMusic.Play();
                }

                Timeup TP = new Timeup();
                TP.Show();

                timer3.Stop();
            }

            // 每天  啟動文字訊息
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.everyday_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.everyday_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.everyday_second
                && power_APP.Properties.Settings.Default.ShowMessage
         )
            {
                Console.Write("倒數訊息");
                Message_show MS = new Message_show();
                MS.Show();
                timer3.Stop();
            }

            // 每天  啟動程式
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.everyday_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.everyday_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.everyday_second
                && power_APP.Properties.Settings.Default.Perform_tasks
         )
            {
                Console.Write("倒數啟動程式");
                string exe_pro = power_APP.Properties.Settings.Default.exe_user;
                ProcessStartInfo info = new ProcessStartInfo(exe_pro);
                info.WindowStyle = ProcessWindowStyle.Normal;
                Process exe = Process.Start(info);

                timer3.Stop();
            }


            // 每天  關閉螢幕
            if (
                   DateTime.Now.ToString("mm") == power_APP.Properties.Settings.Default.everyday_minute
                && DateTime.Now.ToString("HH") == power_APP.Properties.Settings.Default.everyday_hour
                && DateTime.Now.ToString("ss") == power_APP.Properties.Settings.Default.everyday_second
                && power_APP.Properties.Settings.Default.OffScreen
           )
            {
                Console.Write("倒數關閉螢幕");
                SendMessage(this.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, 2);//DLL function

                timer3.Stop();
            }

            try
            {
                if (show_title)
                {
                    show_title = false;
                    Form1.ActiveForm.Text = "每天自動排程-執行中";
                }
            }
            catch
            {

            }

        }