namespace LibCECTray.controller.applications
{
+ public delegate void OnApplicationRunningChanged(bool running);
+
/// <summary>
/// Controls an application on the PC: send key presses, open the application, close it, etc.
/// </summary>
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
return !IsInternal;
}
}
+
+ private bool _applicationRunning;
+
#endregion
}
}