using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.LayerBrush.Abstract;
namespace Artemis.Core.Plugins.Abstract
{
///
///
/// Allows you to create one or more s usable by profile layers.
///
public abstract class LayerBrushProvider : Plugin
{
private readonly List _layerBrushDescriptors;
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");
_layerBrushDescriptors.Add(new LayerBrushDescriptor(displayName, description, icon, typeof(T), this));
}
private void OnPluginDisabled(object sender, EventArgs e)
{
_layerBrushDescriptors.Clear();
}
}
}