Ejemplo n.º 1
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (StandbySuppressor.isStandbySuppressed == true)
     {
         StandbySuppressor.EnableStandby();
     }
 }
Ejemplo n.º 2
0
        private void btnToggle_Click(object sender, EventArgs e)
        {
            StandbySuppressor.SuppresionMode mode = (StandbySuppressor.SuppresionMode) this.cmbMethod.SelectedIndex;

            if (StandbySuppressor.isStandbySuppressed != true)
            {
                StandbySuppressor.isStandbySuppressed = StandbySuppressor.DisableStandby(mode, this.chbDisplay.Checked);
            }
            else
            {
                StandbySuppressor.isStandbySuppressed = !StandbySuppressor.EnableStandby();
            }


            if (StandbySuppressor.isStandbySuppressed)
            {
                this.lblStatus.Text      = "On";
                this.lblStatus.ForeColor = Color.Green;
            }
            else
            {
                this.lblStatus.Text      = "Off";
                this.lblStatus.ForeColor = Color.Red;
            }
        }
Ejemplo n.º 3
0
        public static bool DisableStandby(SuppresionMode mode = SuppresionMode.PowerAvailabilityRequests, bool keepScreenEnabled = false)
        {
            keepScreenOn = keepScreenEnabled;
            bool result = false;

            switch (mode)
            {
            case SuppresionMode.PowerAvailabilityRequests:
                if (PowerAvailabilityRequestsSupported())
                {
                    result = StandbySuppressor.DisableStandbyPowerAvailability();
                }
                break;

            case SuppresionMode.SetThreadExecutionState:
                result = StandbySuppressor.DisableStandbySetThreadExec();
                break;

            case SuppresionMode.MouseMover:
                result = StandbySuppressor.DisableStandbyMoveMouse();
                break;
            }

            if (result == true)
            {
                usedMethod = mode;
            }
            else
            {
                MessageBox.Show("Error disableing standby", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(result);
        }