mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-08 09:15:06 +00:00
changed event names and added saved event
This commit is contained in:
@@ -36,7 +36,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
_tunerPresets.SetFileName(_config.PresetsFileName);
|
||||
|
||||
_tunerPresets.PresetChanged += TunerPresetsOnPresetChanged;
|
||||
_tunerPresets.PresetRecalled += TunerPresetsOnPresetRecalled;
|
||||
|
||||
_tuners = GetDevices<IRSetTopBoxBase>(_config.Tuners);
|
||||
_displays = GetDevices<TwoWayDisplayBase>(_config.Displays);
|
||||
@@ -78,7 +78,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
#endregion
|
||||
|
||||
private void TunerPresetsOnPresetChanged(ISetTopBoxNumericKeypad device, string channel)
|
||||
private void TunerPresetsOnPresetRecalled(ISetTopBoxNumericKeypad device, string channel)
|
||||
{
|
||||
if (!_currentPresets.ContainsKey(device.Key))
|
||||
{
|
||||
|
||||
@@ -16,12 +16,14 @@ namespace PepperDash.Essentials.Core.Presets
|
||||
/// </summary>
|
||||
public class DevicePresetsModel : Device
|
||||
{
|
||||
public delegate void PresetChangedCallback(ISetTopBoxNumericKeypad device, string channel);
|
||||
public delegate void PresetRecalledCallback(ISetTopBoxNumericKeypad device, string channel);
|
||||
|
||||
public delegate void PresetsSavedCallback(List<PresetChannel> presets);
|
||||
|
||||
private readonly CCriticalSection _fileOps = new CCriticalSection();
|
||||
private readonly bool _initSuccess;
|
||||
|
||||
private ISetTopBoxNumericKeypad _setTopBox;
|
||||
private readonly ISetTopBoxNumericKeypad _setTopBox;
|
||||
|
||||
/// <summary>
|
||||
/// The methods on the STB device to call when dialing
|
||||
@@ -83,7 +85,8 @@ namespace PepperDash.Essentials.Core.Presets
|
||||
_initSuccess = true;
|
||||
}
|
||||
|
||||
public event PresetChangedCallback PresetChanged;
|
||||
public event PresetRecalledCallback PresetRecalled;
|
||||
public event PresetsSavedCallback PresetsSaved;
|
||||
|
||||
public int PulseTime { get; set; }
|
||||
public int DigitSpacingMs { get; set; }
|
||||
@@ -188,7 +191,7 @@ namespace PepperDash.Essentials.Core.Presets
|
||||
|
||||
if (_setTopBox == null) return;
|
||||
|
||||
OnPresetChanged(_setTopBox, chanNum);
|
||||
OnPresetRecalled(_setTopBox, chanNum);
|
||||
}
|
||||
|
||||
public void Dial(int presetNum, ISetTopBoxNumericKeypad setTopBox)
|
||||
@@ -218,14 +221,14 @@ namespace PepperDash.Essentials.Core.Presets
|
||||
|
||||
_enterFunction = setTopBox.KeypadEnter;
|
||||
|
||||
OnPresetChanged(setTopBox, chanNum);
|
||||
OnPresetRecalled(setTopBox, chanNum);
|
||||
|
||||
Dial(chanNum);
|
||||
}
|
||||
|
||||
private void OnPresetChanged(ISetTopBoxNumericKeypad setTopBox, string channel)
|
||||
private void OnPresetRecalled(ISetTopBoxNumericKeypad setTopBox, string channel)
|
||||
{
|
||||
var handler = PresetChanged;
|
||||
var handler = PresetRecalled;
|
||||
|
||||
if (handler == null)
|
||||
{
|
||||
@@ -265,6 +268,8 @@ namespace PepperDash.Essentials.Core.Presets
|
||||
{
|
||||
file.Write(json, Encoding.UTF8);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -273,6 +278,15 @@ namespace PepperDash.Essentials.Core.Presets
|
||||
|
||||
}
|
||||
|
||||
private void OnPresetsSaved()
|
||||
{
|
||||
var handler = PresetsSaved;
|
||||
|
||||
if (handler == null) return;
|
||||
|
||||
handler(PresetsList);
|
||||
}
|
||||
|
||||
private void Pulse(Action<bool> act)
|
||||
{
|
||||
act(true);
|
||||
|
||||
Reference in New Issue
Block a user