X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FLibCecTray%2Fcontroller%2Fapplications%2FApplicationController.cs;h=f36bd6ae7efaeda194fba55558400e6073fe26ba;hb=f4729954da8ed049a6bc5ea6bbd72e30f158ddc9;hp=4d23071946db8ecfff2e61d5fc32c9a4e5240581;hpb=324a4cb1d256252a4cd506e90e158828e160b0ed;p=deb_libcec.git diff --git a/src/LibCecTray/controller/applications/ApplicationController.cs b/src/LibCecTray/controller/applications/ApplicationController.cs index 4d23071..f36bd6a 100644 --- a/src/LibCecTray/controller/applications/ApplicationController.cs +++ b/src/LibCecTray/controller/applications/ApplicationController.cs @@ -42,6 +42,8 @@ using Timer = System.Timers.Timer; namespace LibCECTray.controller.applications { + public delegate void OnApplicationRunningChanged(bool running); + /// /// Controls an application on the PC: send key presses, open the application, close it, etc. /// @@ -190,12 +192,24 @@ namespace LibCECTray.controller.applications public virtual void Initialise() { Timer timer = new Timer { Interval = 1000, AutoReset = true }; - timer.Elapsed += delegate { UiControl.SetStartButtonEnabled(true); }; + timer.Elapsed += delegate { CheckApplicationEnabled(); }; timer.Start(); if (AutoStartApplication.Value) Start(false); } + + public event OnApplicationRunningChanged ApplicationRunningChanged; + + private void CheckApplicationEnabled() + { + var isRunning = IsRunning(); + if (isRunning != _applicationRunning && ApplicationRunningChanged != null) + ApplicationRunningChanged(isRunning); + + _applicationRunning = isRunning; + UiControl.SetStartButtonEnabled(isRunning && !SuppressApplicationStart); + } #endregion #region Send input to the application @@ -377,6 +391,9 @@ namespace LibCECTray.controller.applications return !IsInternal; } } + + private bool _applicationRunning; + #endregion } }