using System; using Artemis.Core.Services; using Ninject; namespace Artemis.Core.LayerBrushes { /// /// A class that describes a layer brush /// public class LayerBrushDescriptor { internal LayerBrushDescriptor(string displayName, string description, string icon, Type layerBrushType, LayerBrushProvider layerBrushProvider) { DisplayName = displayName; Description = description; Icon = icon; LayerBrushType = layerBrushType; LayerBrushProvider = layerBrushProvider; } /// /// 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 brush /// public Type LayerBrushType { get; } /// /// The plugin that provided this /// public LayerBrushProvider LayerBrushProvider { get; } /// /// Creates an instance of the described brush and applies it to the layer /// internal void CreateInstance(Layer layer) { if (layer.LayerBrush != null) throw new ArtemisCoreException("Layer already has an instantiated layer brush"); var brush = (BaseLayerBrush) CoreService.Kernel.Get(LayerBrushType); brush.Layer = layer; brush.Descriptor = this; brush.Initialize(); brush.Update(0); layer.LayerBrush = brush; layer.OnLayerBrushUpdated(); } public bool MatchesLayerBrushReference(LayerBrushReference reference) { if (reference == null) return false; return LayerBrushProvider.PluginInfo.Guid == reference.BrushPluginGuid && LayerBrushType.Name == reference.BrushType; } } }