示例#1
0
 private void Idletimer_BeforeIdleTimeReached(object sender, EventArgs e)
 {
     if (MediaWatcher.IsWindowsPlayingSound())
     {
         return;
     }
     notifyIcon1.BalloonTipText = "SystemSleep will put your system to sleep now";
     notifyIcon1.ShowBalloonTip(500);
     ScreenHelper.TurnOffScreen(this.Handle);
 }
示例#2
0
        private async void SleepNow_Click(object sender, EventArgs e)
        {
            ScreenHelper.TurnOffScreen(this.Handle);
            await Task.Delay(2000);

            var idletime = Win32Helper.GetIdleTimeInSecs();

            Trace.WriteLine($"SleepNow_Click idletime {idletime}");
            if (idletime > 0)
            {
                SystemHelper.Suspend();
            }
        }