using System; using System.Linq; using Artemis.Core.LayerBrushes; using Artemis.Storage.Entities.Profile; using Ninject; namespace Artemis.Core.LayerEffects { /// /// A class that describes a layer effect /// public class LayerEffectDescriptor { internal LayerEffectDescriptor(string displayName, string description, string icon, Type layerEffectType, LayerEffectProvider layerEffectProvider) { DisplayName = displayName; Description = description; Icon = icon; LayerEffectType = layerEffectType; LayerEffectProvider = layerEffectProvider; } /// /// The name that is displayed in the UI /// public string DisplayName { get; } /// /// The description that is displayed in the UI /// public string Description { get; } /// /// The Material icon to display in the UI, a full reference can be found /// here /// public string Icon { get; } /// /// The type of the layer effect /// public Type LayerEffectType { get; } /// /// The plugin that provided this /// public LayerEffectProvider LayerEffectProvider { get; } /// /// Gets or sets the kernel used to instantiate the described layer effect /// internal IKernel Kernel { get; set; } /// /// Creates an instance of the described effect and applies it to the render element /// internal void CreateInstance(RenderProfileElement renderElement, LayerEffectEntity entity) { // Skip effects already on the element if (renderElement.LayerEffects.Any(e => e.EntityId == entity.Id)) return; var effect = (BaseLayerEffect) Kernel.Get(LayerEffectType); effect.ProfileElement = renderElement; effect.EntityId = entity.Id; effect.Order = entity.Order; effect.Name = entity.Name; effect.Enabled = entity.Enabled; effect.Descriptor = this; effect.Initialize(); effect.Update(0); renderElement.ActivateLayerEffect(effect); } } }