Пример #1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            SetControls(false);

            if (btnStart.Text == "Start")
            {
                ActionType?at   = GetActionType();
                bool       doit = true;
                if (nUPHour.Value == 0 && nUPMinute.Value == 0)
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure to perform Action immediatly?", at.ToString(), MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.No)
                    {
                        doit = false;
                    }
                }
                if (doit == true)
                {
                    if (at != null)
                    {
                        BLShutdwn.CountdownChanged += (sender1, e1) => lbCountdown.Text = BLShutdwn.Countdown.ToString();
                        BLShutdwn.CountdownChanged += (sender1, e1) => windowsTaskbar.SetProgressValue(BLShutdwn.ProgressCountdown, 100);

                        BLShutdwn.EndCountdown = ActionTime(rBIn.Checked, Convert.ToInt32(nUPHour.Value), Convert.ToInt32(nUPMinute.Value));
                        BLShutdwn.Type         = at;
                        BLShutdwn.SaveSettings(rBIn.Checked, Convert.ToInt32(nUPHour.Value), Convert.ToInt32(nUPMinute.Value), at);
                        BLShutdwn.Action();

                        btnStart.Text   = "Pause";
                        btnStop.Enabled = true;
                    }
                    else
                    {
                        MessageBox.Show("You have not choosen an Action");
                    }
                }
            }
            else if (btnStart.Text == "Pause")
            {
                BLShutdwn.PauseCountdown = true;
                btnStart.Text            = "Resume";
            }
            else if (btnStart.Text == "Resume")
            {
                BLShutdwn.PauseCountdown = false;
                btnStart.Text            = "Pause";
            }
        }
Пример #2
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            bool       UseInTime = false;
            int        hour      = 0;
            int        minute    = 0;
            ActionType?at        = new ActionType();
            string     LastDate  = "";

            BLShutdwn.LoadSettings(ref UseInTime, ref hour, ref minute, ref at, ref LastDate);
            if (LastDate != "")
            {
                if (UseInTime == true)
                {
                    rBIn.Checked = true;
                }
                else
                {
                    rbAt.Checked = true;
                }

                nUPHour.Value   = hour;
                nUPMinute.Value = minute;

                switch (at)
                {
                case ActionType.Shutdown:
                    rBSD.Checked = true;
                    break;

                case ActionType.Logoff:
                    rBLO.Checked = true;
                    break;

                case ActionType.Restart:
                    rBRS.Checked = true;
                    break;

                default:
                    break;
                }
            }
        }