From 9a6209f50a63a9a0b4c5436b85fdb2cef0a7dc79 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 25 Jun 2024 16:08:44 -0600 Subject: [PATCH] feat: Adds basic CamerLists config structure and CameraListItems class --- .../Config/BasicConfig.cs | 4 + .../Devices/CameraListItem.cs | 76 +++++++++++++++++++ .../Devices/SourceListItem.cs | 1 + 3 files changed, 81 insertions(+) create mode 100644 src/PepperDash.Essentials.Core/Devices/CameraListItem.cs diff --git a/src/PepperDash.Essentials.Core/Config/BasicConfig.cs b/src/PepperDash.Essentials.Core/Config/BasicConfig.cs index 6df7b583..89bd7655 100644 --- a/src/PepperDash.Essentials.Core/Config/BasicConfig.cs +++ b/src/PepperDash.Essentials.Core/Config/BasicConfig.cs @@ -5,6 +5,7 @@ using System.Linq; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using PepperDash.Essentials.Core.Devices; namespace PepperDash.Essentials.Core.Config { @@ -28,6 +29,9 @@ namespace PepperDash.Essentials.Core.Config [JsonProperty("audioControlPointLists")] public Dictionary AudioControlPointLists { get; set; } + [JsonProperty("cameraLists")] + public Dictionary> CameraLists { get; set; } + [JsonProperty("tieLines")] public List TieLines { get; set; } diff --git a/src/PepperDash.Essentials.Core/Devices/CameraListItem.cs b/src/PepperDash.Essentials.Core/Devices/CameraListItem.cs new file mode 100644 index 00000000..e3fefcc8 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/CameraListItem.cs @@ -0,0 +1,76 @@ +using Newtonsoft.Json; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.Devices +{ + public class CameraListItem + { + [JsonProperty("deviceKey")] + public string DeviceKey { get; set; } + + /// + /// Returns the source Device for this, if it exists in DeviceManager + /// + [JsonIgnore] + public Device CameraDevice + { + get + { + if (_cameraDevice == null) + _cameraDevice = DeviceManager.GetDeviceForKey(DeviceKey) as Device; + return _cameraDevice; + } + } + Device _cameraDevice; + + /// + /// Gets either the source's Name or this AlternateName property, if + /// defined. If source doesn't exist, returns "Missing source" + /// + [JsonProperty("preferredName")] + public string PreferredName + { + get + { + if (string.IsNullOrEmpty(Name)) + { + if (CameraDevice == null) + return "---"; + return CameraDevice.Name; + } + return Name; + } + } + + /// + /// A name that will override the source's name on the UI + /// + [JsonProperty("name")] + public string Name { get; set; } + + + /// + /// Specifies and icon for the source list item + /// + [JsonProperty("icon")] + public string Icon { get; set; } + + /// + /// Alternate icon + /// + [JsonProperty("altIcon", NullValueHandling = NullValueHandling.Ignore)] + public string AltIcon { get; set; } + + /// + /// Indicates if the item should be included in the user facing list + /// + [JsonProperty("includeInUserList")] + public bool IncludeInUserList { get; set; } + + /// + /// Used to specify the order of the items in the source list when displayed + /// + [JsonProperty("order")] + public int Order { get; set; } + } +} diff --git a/src/PepperDash.Essentials.Core/Devices/SourceListItem.cs b/src/PepperDash.Essentials.Core/Devices/SourceListItem.cs index b0372b51..48d43c94 100644 --- a/src/PepperDash.Essentials.Core/Devices/SourceListItem.cs +++ b/src/PepperDash.Essentials.Core/Devices/SourceListItem.cs @@ -193,6 +193,7 @@ namespace PepperDash.Essentials.Core defaultDisplay, leftDisplay, rightDisplay, + centerDisplay, programAudio, codecContent }