Example #1
0
        private void AfterTimer_Tick(object sender, EventArgs e)
        {
            HookIdleAfterTimeTick     += AfterTimer.Interval;
            AfterProgressSpinner.Value = (int)((float)HookIdleAfterTimeTick / AfterTime / 60 / 1000 * 100);
            SpinnerAfterTimeLabel.Text = (((AfterTime * 60) - (HookIdleAfterTimeTick / 1000)) / 60).ToString("00") + ":" + (((AfterTime * 60) - (HookIdleAfterTimeTick / 1000)) % 60).ToString("00");

            if (HookIdleAfterTimeTick > AfterTime * 60 * 1000) //종료될 시간 (기준이 분이므로 *초*밀리)
            {
                AfterTimer.Stop();                             //타이머의 틱이 1초 기준이므로 중복해서 수행될 수 있으므로 타이머 정지
                MessageBox.Show("자동 절전");                      //테스트를 위한 메시지박스. 삭제가능
                switch (AfterTypeOf)
                {
                case 1:
                    SleepProcedure();
                    break;

                case 2:
                    SuspendProcedure();
                    break;

                case 3:
                    HibernateProcedure();
                    break;

                case 4:
                    ShutdownProcedure();
                    break;

                default:
                    MessageBox.Show("Error!");
                    break;
                }
            }
        }
Example #2
0
 void CommonHookMethod()
 {
     if (ConServ.IsMonOff == true)
     {
         keyboardHook.Stop();
         mouseHook.Stop();
         ConServ.WakingUp();
         LogTextBox.Text = ConServ.LogText;
     }
     if (IsHookAfter == true)
     {
         AfterTimer.Stop();
         HookIdleAfterTimeTick = 0;
         AfterTimer.Start();
     }
     if (IsHookAt == true)
     {
         AtTimer.Stop();
         HookIdleAtTimeTick = 0;
         AtTimer.Start();
     }
 }
Example #3
0
        //cancel
        private void CancleTile_Click(object sender, EventArgs e)
        {
            mouseHook.Stop();
            keyboardHook.Stop();

            IsHookAfter = false;
            AfterSpinnerDeact();
            AfterTimer.Stop();
            AfterTimeCheckBox.Checked = false;
            IsHookAt = false;
            AtSpinnerDeact();
            AtTimer.Stop();
            AtTimeCheckBox.Checked = false;



            /*easy style part stop*/
            autoDisplayoffTimer.Stop();
            autoSuspendTimer.Stop();
            mouseHook_for_easy.Stop();
            keyboardHook_for_easy.Stop();
            metroProgressBar1.Value = 0;
            metroProgressBar2.Value = 0;
        }
Example #4
0
        private void SettingsTile_Click(object sender, EventArgs e)
        {
            if (metroTabControl1.SelectedTab == EasyStyleTabPage) //탭페이지 처음 (Easy Style) 일때의 셋팅 조건
            {
            }

            if (metroTabControl1.SelectedTab == SchedulerTabPage) //스케쥴 탭페이지 셋팅
            {
                //After 체크되었을때
                if (AfterTimeCheckBox.Checked == true)
                {
                    if (AfterExcuteTypeStandardRadioButton.Checked == true) //Standard 라디오 선택시 후킹 시작
                    {
                        IsHookAfter = true;
                        mouseHook.Start();
                        keyboardHook.Start();
                    }
                    else if (AfterExcuteTypeForceRadioButton.Checked == true) //Force 라디오 선택시 후킹 시작 없음
                    {
                        IsHookAfter = false;
                    }
                    //선택한 절전 조건을 TypeOf 변수에 저장
                    if (AfterSaveTypeMonitorOffRadioButton.Checked)
                    {
                        SpinnerAfterSaveTypeLabel.Text = AfterSaveTypeMonitorOffRadioButton.Text;
                        AfterTypeOf = 1;
                    }
                    else if (AfterSaveTypeSuspendRadioButton.Checked)
                    {
                        SpinnerAfterSaveTypeLabel.Text = AfterSaveTypeSuspendRadioButton.Text;
                        AfterTypeOf = 2;
                    }
                    else if (AfterSaveTypeHibernateRadioButton.Checked)
                    {
                        SpinnerAfterSaveTypeLabel.Text = AfterSaveTypeHibernateRadioButton.Text;
                        AfterTypeOf = 3;
                    }
                    else if (AfterSaveTypeShutdownRadioButton.Checked)
                    {
                        SpinnerAfterSaveTypeLabel.Text = AfterSaveTypeShutdownRadioButton.Text;
                        AfterTypeOf = 4;
                    }
                    AfterTime = Convert.ToInt32(AfterTimeComboBox.SelectedItem); //얼마뒤에 종료할 것인지 시간을 저장
                    AfterSpinnerAct();
                    AfterTimer.Start();
                }
                else if (AfterTimeCheckBox.Checked == false) //After에 체크가 풀린 상태로 셋팅하면
                {
                    if (AtTimeCheckBox.Checked == false)     //At도 체크가 풀려있으면 후킹 해제
                    {
                        mouseHook.Stop();
                        keyboardHook.Stop();
                    }
                    IsHookAfter = false;
                    AfterSpinnerDeact();
                    AfterTimer.Stop();
                }

                //At시작 After와 반대입니다.
                if (AtTimeCheckBox.Checked == true)
                {
                    if (AtExcuteTypeStandardRadioButton.Checked == true) //if keyboard or mouse, nothing
                    {
                        IsHookAt = true;
                        mouseHook.Start();
                        keyboardHook.Start();
                    }
                    else if (AtExcuteTypeForceRadioButton.Checked == true) //force shut down
                    {
                        IsHookAt = false;
                    }

                    if (AtSaveTypeMonitorOffRadioButton.Checked)
                    {
                        SpinnerAtSaveTypeLabel.Text = AtSaveTypeMonitorOffRadioButton.Text;
                        AtTypeOf = 1;
                    }
                    else if (AtSaveTypeSuspendRadioButton.Checked)
                    {
                        SpinnerAtSaveTypeLabel.Text = AtSaveTypeSuspendRadioButton.Text;
                        AtTypeOf = 2;
                    }
                    else if (AtSaveTypeHibernateRadioButton.Checked)
                    {
                        SpinnerAtSaveTypeLabel.Text = AtSaveTypeHibernateRadioButton.Text;
                        AtTypeOf = 3;
                    }
                    else if (AtSaveTypeShutdownRadioButton.Checked)
                    {
                        SpinnerAtSaveTypeLabel.Text = AtSaveTypeShutdownRadioButton.Text;
                        AtTypeOf = 4;
                    }
                    AtTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt32(AtTimeHourComboBox.SelectedItem.ToString()), Convert.ToInt32(AtTimeMinuteComboBox.SelectedItem.ToString()), 0); //예약된 시간은 DateTime 객체를 이용하여 시간과 분을 설정
                    if ((AtTime - DateTime.Now) < TimeSpan.Zero)
                    {
                        AtTime.AddDays(1);
                    }

                    AtSpinnerAct();
                    AtTimer.Start();
                }
                else if (AtTimeCheckBox.Checked == false)
                {
                    if (AfterTimeCheckBox.Checked == false)
                    {
                        mouseHook.Stop();
                        keyboardHook.Stop();
                    }
                    IsHookAt = false;
                    AtSpinnerDeact();
                    AtTimer.Stop();
                }
            }
        }