using System.Collections.ObjectModel; using System.Linq; namespace Artemis.Core.Models.Profile.LayerProperties { public class LayerProperty : BaseLayerProperty { public LayerProperty(Layer layer, BaseLayerProperty parent, string id, string name, string description) : base(layer, parent, id, name, description, typeof(T)) { } /// /// The value of the property without any keyframes applied /// public T Value { get => BaseValue != null ? (T) BaseValue : default; set => BaseValue = value; } /// /// The value of the property with keyframes applied /// public T CurrentValue => KeyframeEngine != null ? (T) KeyframeEngine.GetCurrentValue() : Value; /// /// A list of keyframes defining different values of the property in time, this list contains the strongly typed /// /// public ReadOnlyCollection> Keyframes => BaseKeyframes.Cast>().ToList().AsReadOnly(); /// /// Adds a keyframe to the property. /// /// The keyframe to remove public void AddKeyframe(Keyframe keyframe) { BaseKeyframes.Add(keyframe); } /// /// Removes a keyframe from the property. /// /// The keyframe to remove public void RemoveKeyframe(Keyframe keyframe) { BaseKeyframes.Remove(keyframe); } /// /// Gets the current value using the keyframes /// /// public T GetCurrentValue() { if (KeyframeEngine == null || !Keyframes.Any()) return Value; return (T) KeyframeEngine.GetCurrentValue(); } } }