Ejemplo n.º 1
0
        private void Delay_timer_Tick(object sender, EventArgs e)
        {
            try
            {
                if (ScheduleStore.scheduleType == ScheduleType.OnIdle)
                {
                    var      set_idle_total_second = ScheduleStore.hour * 60 * 60 + ScheduleStore.minute * 60;
                    var      remaining             = set_idle_total_second - ((int)GetSystemIdleTime.GetIdleTime()) / 1000;
                    TimeSpan time = TimeSpan.FromSeconds(remaining);
                    ShowInfoLabel(time);

                    if (((int)remaining) == SHUTDOWN_STATE)
                    {
                        this.mainForm.SetEndShutDown();
                        delay_timer.Stop();
                        this.mainForm.ExecuteCommand();
                        //MessageBox.Show("Shutdown");
                        this.Close();
                    }
                }
                else
                {
                    var      now       = DateTime.Now;
                    TimeSpan remaining = _setTime - now;
                    ShowInfoLabel(remaining);

                    if (((int)remaining.TotalSeconds) == SHUTDOWN_STATE)
                    {
                        if (ScheduleStore.scheduleType == ScheduleType.Daily)
                        {
                            this.mainForm.SetTimeAgainDaily();
                        }
                        else
                        {
                            this.mainForm.SetEndShutDown();
                        }
                        delay_timer.Stop();
                        this.mainForm.ExecuteCommand();
                        //MessageBox.Show("Shutdown");
                        this.Close();
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
        private void Shutdown_timer_Tick(object sender, EventArgs e)
        {
            try
            {
                if (ScheduleStore.scheduleType == ScheduleType.OnIdle)
                {
                    var      set_idle_total_second = ScheduleStore.hour * 60 * 60 + ScheduleStore.minute * 60;
                    var      remaining             = set_idle_total_second - ((int)GetSystemIdleTime.GetIdleTime()) / 1000;
                    TimeSpan time = TimeSpan.FromSeconds(remaining);
                    ShowInfoLabel(time);
                    test_label.Text = "" + Convert.ToString(remaining) + "";

                    if (ScheduleStore.MessageNoticeShow)
                    {
                        if (((int)remaining) == DelayMinutes * 60)
                        //if (((int)remaining) == 50)
                        {
                            this.shutdown_timer.Stop();
                            MessageNoticeShow messageNoticeShow = new MessageNoticeShow(this);
                            messageNoticeShow.ShowDialog();
                        }
                    }

                    if (((int)remaining) == SHUTDOWN_STATE)
                    {
                        SetEndShutDown();
                        shutdown_timer.Stop();
                        ExecuteCommand();
                        //MessageBox.Show("Shutdown");
                    }
                }
                else
                {
                    var      now       = DateTime.Now;
                    TimeSpan remaining = _setTime - now;
                    ShowInfoLabel(remaining);
                    test_label.Text = Convert.ToString(remaining.TotalSeconds) + ": notice " + ScheduleStore.MessageNoticeShow + "";

                    if (ScheduleStore.MessageNoticeShow)
                    {
                        if (((int)remaining.TotalSeconds) == DelayMinutes * 60)
                        //if (((int)remaining.TotalSeconds) == 50)
                        {
                            this.shutdown_timer.Stop();
                            MessageNoticeShow messageNoticeShow = new MessageNoticeShow(this);
                            messageNoticeShow.ShowDialog();
                        }
                    }

                    if (((int)remaining.TotalSeconds) == SHUTDOWN_STATE)
                    {
                        if (ScheduleStore.scheduleType == ScheduleType.Daily)
                        {
                            SetTimeAgainDaily();
                        }
                        else
                        {
                            SetEndShutDown();
                        }
                        shutdown_timer.Stop();
                        ExecuteCommand();
                        //MessageBox.Show("Shutdown");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }