mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-04 07:14:58 +00:00
46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Newtonsoft.Json;
|
|
using PepperDash.Core;
|
|
|
|
|
|
namespace PepperDash.Essentials.Core
|
|
{
|
|
public class PresetListItem : AudioControlListItemBase
|
|
{
|
|
[JsonIgnore]
|
|
public IKeyName Preset
|
|
{
|
|
get
|
|
{
|
|
if (_preset == null)
|
|
{
|
|
var parent = DeviceManager.GetDeviceForKey(ParentDeviceKey) as IDspPresets;
|
|
if (parent == null || !parent.Presets.ContainsKey(ItemKey))
|
|
return null;
|
|
_preset = parent.Presets[ItemKey];
|
|
}
|
|
return _preset;
|
|
}
|
|
}
|
|
private IKeyName _preset;
|
|
|
|
/// <summary>
|
|
/// Gets the name from the device if it implements IKeyName or else returns the Name property
|
|
/// </summary>
|
|
[JsonProperty("preferredName")]
|
|
public string PreferredName
|
|
{
|
|
get
|
|
{
|
|
if (!string.IsNullOrEmpty(Name)) return Name;
|
|
|
|
else return Preset.Name;
|
|
}
|
|
}
|
|
}
|
|
}
|