using System;
using System.Collections.Generic;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
///
///
///
public enum eSourceListItemType
{
Route, Off, Other, SomethingAwesomerThanThese
}
///
/// Represents an item in a source list - can be deserialized into.
///
public class SourceListItem
{
[JsonProperty("sourceKey")]
public string SourceKey { get; set; }
///
/// Returns the source Device for this, if it exists in DeviceManager
///
[JsonIgnore]
public Device SourceDevice
{
get
{
if (_SourceDevice == null)
_SourceDevice = DeviceManager.GetDeviceForKey(SourceKey) as Device;
return _SourceDevice;
}
}
Device _SourceDevice;
///
/// 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 (SourceDevice == null)
return "---";
return SourceDevice.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")]
public string AltIcon { get; set; }
///
/// Indicates if the item should be included in the source list
///
[JsonProperty("includeInSourceList")]
public bool IncludeInSourceList { get; set; }
///
/// Used to specify the order of the items in the source list when displayed
///
[JsonProperty("order")]
public int Order { get; set; }
///
/// The key of the device for volume control
///
[JsonProperty("volumeControlKey")]
public string VolumeControlKey { get; set; }
///
/// The type of source list item
///
[JsonProperty("type")]
[JsonConverter(typeof(StringEnumConverter))]
public eSourceListItemType Type { get; set; }
///
/// The list of routes to execute for this source list item
///
[JsonProperty("routeList")]
public List RouteList { get; set; }
///
/// Indicates if this source should be disabled for sharing to the far end call participants via codec content
///
[JsonProperty("disableCodecSharing")]
public bool DisableCodecSharing { get; set; }
///
/// Indicates if this source should be disabled for routing to a shared output
///
[JsonProperty("disableRoutedSharing")]
public bool DisableRoutedSharing { get; set; }
[JsonProperty("destinations")]
public List Destinations { get; set; }
///
/// A means to reference a source list for this source item, in the event that this source has an input that can have sources routed to it
///
[JsonProperty("sourceListKey")]
public string SourceListKey { get; set; }
///
/// Indicates if the device associated with this source is controllable
///
[JsonProperty("isControllable")]
public bool IsControllable { get; set; }
///
/// Indicates that the device associated with this source has audio available
///
[JsonProperty("isAudioSource")]
public bool IsAudioSource { get; set; }
///
/// Hide source on UI when Avanced Sharing is enabled
///
[JsonProperty("disableAdvancedRouting")]
public bool DisableAdvancedRouting { get; set; }
///
/// Hide source on UI when Simpl Sharing is enabled
///
[JsonProperty("disableSimpleRouting")]
public bool DisableSimpleRouting { get; set; }
public SourceListItem()
{
Icon = "Blank";
}
public override string ToString()
{
return $"{SourceKey}:{Name}";
}
}
public class SourceRouteListItem
{
[JsonProperty("sourceKey")]
public string SourceKey { get; set; }
[JsonProperty("sourcePortKey")]
public string SourcePortKey { get; set; }
[JsonProperty("destinationKey")]
public string DestinationKey { get; set; }
[JsonProperty("destinationPortKey")]
public string DestinationPortKey { get; set; }
[JsonProperty("type")]
public eRoutingSignalType Type { get; set; }
}
///
/// Defines the valid destination types for SourceListItems in a room
///
public enum eSourceListItemDestinationTypes
{
defaultDisplay,
leftDisplay,
rightDisplay,
programAudio,
codecContent
}
}