private void OnScreensaverActivated(bool active) { if (active != ScreensaverActive) { ScreensaverActive = active; if (!active) { ScreensaverActivated?.Invoke(this, new ScreensaverChange(false)); } else if ((DateTime.Now - _lastScreensaverActivated).TotalSeconds > 60) { // guard against screensaver failing, and resulting in power up and down spam to the tv _lastScreensaverActivated = DateTime.Now; ScreensaverActivated?.Invoke(this, new ScreensaverChange(true)); } } }
private bool onEvent(KodiEventMessage e) { switch (e.Sender) { case "onAbortRequested": AbortRequested?.Invoke(e.Sender, new EventArgs()); break; case "onCleanStarted": CleanStarted?.Invoke(e.Sender, new LibraryEventArgs(e.EventArgs[0])); break; case "onCleanFinished": CleanFinished?.Invoke(e.Sender, new LibraryEventArgs(e.EventArgs[0])); break; case "onDPMSActivated": DPMSActivated?.Invoke(e.Sender, new EventArgs()); break; case "onDPMSDeactivated": DPMSDeactivated?.Invoke(e.Sender, new EventArgs()); break; case "onDatabaseScanStarted": DatabaseScanStarted?.Invoke(e.Sender, new DatabaseEventArgs(e.EventArgs[0])); break; case "onDatabaseUpdated": DatabaseUpdated?.Invoke(e.Sender, new DatabaseEventArgs(e.EventArgs[0])); break; case "onNotification": Notification?.Invoke(e.Sender, new NotificationEventArgs( e.EventArgs[0], e.EventArgs[1], e.EventArgs[2] )); break; case "onScanStarted": ScanStarted?.Invoke(e.Sender, new LibraryEventArgs(e.EventArgs[0])); break; case "onScanFinished": ScanFinished?.Invoke(e.Sender, new LibraryEventArgs(e.EventArgs[0])); break; case "onScreensaverActivated": ScreensaverActivated?.Invoke(e.Sender, new EventArgs()); break; case "onScreensaverDeactivated": ScreensaverDeactivated?.Invoke(e.Sender, new EventArgs()); break; case "onSettingsChanged": SettingsChanged?.Invoke(e.Sender, new EventArgs()); break; default: PyConsole.WriteLine(string.Format("Unknown event '{0}' not handled", e.Sender)); return(false); } return(true); }