Exemplo n.º 1
0
        private void BtnSetShutdownTime_Click(object sender, EventArgs e)
        {
            if (this.btnSetShutdownTime.Tag == null)
            {
                var isCancel = false;
                if (script == null || script.Context.Status != Status.Running)
                {
                    isCancel = DialogResult.Yes != MessageBox.Show(this, "当前未执行任务,确定要设定自动关机吗?", "提示", MessageBoxButtons.YesNo);
                }

                if (isCancel)
                {
                    return;
                }

                this.btnSetShutdownTime.Tag  = true;
                this.btnSetShutdownTime.Text = "取消";
                this.nudTime.Enabled         = false;
                var hours   = (int)nudTime.Value;
                var seconds = hours * 3600;
                var date    = DateTime.Now.AddHours(hours);
                this.label4.Text = $"将于 {date:HH:mm:ss} 自动关机";
                SystemApi.ShutDownAt(seconds);
            }
            else
            {
                this.btnSetShutdownTime.Tag  = null;
                this.btnSetShutdownTime.Text = "定时关机";
                this.nudTime.Enabled         = true;
                this.label4.Text             = "未设定";
                SystemApi.CancelShutDown();
            }
        }
Exemplo n.º 2
0
 private void Script_Broken(object sender, BrokenArgs e)
 {
     SystemApi.TurnOn();
     this.Log("-->暂停:" + e.Reason);
     script.Pause();
     btnPause.Text = CONTINUE_BUTTON_TEXT;
     SetScriptState();
 }
Exemplo n.º 3
0
 private void BtnShutScreen_Click(object sender, EventArgs e)
 {
     SystemApi.TurnOff();
 }