using System; using Artemis.Core.Services; namespace Artemis.Core.LayerBrushes { /// /// For internal use only, please use or or instead /// public abstract class PropertiesLayerBrush : BaseLayerBrush where T : LayerPropertyGroup { private T _properties; /// /// Gets whether all properties on this brush are initialized /// public bool PropertiesInitialized { get; internal set; } /// public override LayerPropertyGroup BaseProperties => Properties; /// /// Gets the properties of this brush. /// public T Properties { get { // I imagine a null reference here can be confusing, so lets throw an exception explaining what to do if (_properties == null) throw new ArtemisPluginException("Cannot access brush properties until OnPropertiesInitialized has been called"); return _properties; } internal set => _properties = value; } internal void InitializeProperties(IRenderElementService renderElementService) { Properties = Activator.CreateInstance(); Properties.LayerBrush = this; Properties.InitializeProperties(renderElementService, Layer, "LayerBrush."); PropertiesInitialized = true; EnableLayerBrush(); } } }