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
{
if (!Settings.ContainsKey(ProcessName + "_autostart"))
{
- CECSettingBool setting = new CECSettingBool(ProcessName + "_autostart", "Autostart application", true, null);
+ CECSettingBool setting = new CECSettingBool(ProcessName + "_autostart", "Autostart application", false, null);
Settings.Load(setting);
Settings[ProcessName + "_autostart"] = setting;
}
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;
return !IsInternal;
}
}
+
+ private bool _applicationRunning;
+
#endregion
}
}