X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FLibCecTray%2Fcontroller%2Fapplications%2FApplicationController.cs;h=7d0b23d3dc46fca2dc149f7725117a1b53eb4983;hb=74f184d2359c37740931c62cb7b755e1c59dfd4b;hp=310f30f8ef05e12f25dbf04ecb3ae320912fb895;hpb=cf3303fcf1e227b331e915a0397440bd1be3ca7f;p=deb_libcec.git diff --git a/src/LibCecTray/controller/applications/ApplicationController.cs b/src/LibCecTray/controller/applications/ApplicationController.cs index 310f30f..7d0b23d 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 @@ -353,18 +367,7 @@ namespace LibCECTray.controller.applications private CecButtonConfig _buttonConfig; public CecButtonConfig ButtonConfig { - get - { - if (_buttonConfig == null) - { - _buttonConfig = new CecButtonConfig(this); - foreach (CecUserControlCode key in Enum.GetValues(typeof(CecUserControlCode))) - _buttonConfig.Add(new CecButtonConfigItem(this, (new CecKeypress { Keycode = key }))); - - _buttonConfig.Load(); - } - return _buttonConfig; - } + get { return _buttonConfig ?? (_buttonConfig = new CecButtonConfig(this)); } } public CECSettings Settings; @@ -388,6 +391,9 @@ namespace LibCECTray.controller.applications return !IsInternal; } } + + private bool _applicationRunning; + #endregion } }