using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Artemis.Core.LayerBrushes
{
///
/// Allows you to create one or more s usable by profile layers.
///
public abstract class LayerBrushProvider : Plugin
{
private readonly List _layerBrushDescriptors;
///
/// Allows you to register one or more s usable by profile layers.
///
protected LayerBrushProvider()
{
_layerBrushDescriptors = new List();
PluginDisabled += OnPluginDisabled;
}
///
/// A read-only collection of all layer brushes added with
///
public ReadOnlyCollection LayerBrushDescriptors => _layerBrushDescriptors.AsReadOnly();
///
/// Registers a layer brush descriptor for a given layer brush, so that it appears in the UI.
/// Note: You do not need to manually remove these on disable
///
/// The type of the layer brush you wish to register
/// The name to display in the UI
/// The description to display in the UI
///
/// The Material icon to display in the UI, a full reference can be found
/// here
///
protected void RegisterLayerBrushDescriptor(string displayName, string description, string icon) where T : BaseLayerBrush
{
if (!Enabled)
throw new ArtemisPluginException(PluginInfo, "Can only add a layer brush descriptor when the plugin is enabled");
var descriptor = new LayerBrushDescriptor(displayName, description, icon, typeof(T), this);
_layerBrushDescriptors.Add(descriptor);
LayerBrushStore.Add(descriptor);
}
private void OnPluginDisabled(object sender, EventArgs e)
{
// The store will clean up the registrations by itself, the plugin just needs to clear its own list
_layerBrushDescriptors.Clear();
}
}
}