1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00
Artemis/src/Artemis.Core/Plugins/LayerBrushes/LayerBrushDescriptor.cs
Robert 11de30318e Core - Added stores for the different register-able types
Profiles - Refactored large parts of the profile structure to use these stores
2020-09-09 19:56:06 +02:00

69 lines
2.2 KiB
C#

using System;
using Ninject;
namespace Artemis.Core.LayerBrushes
{
/// <summary>
/// A class that describes a layer brush
/// </summary>
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;
}
/// <summary>
/// The name that is displayed in the UI
/// </summary>
public string DisplayName { get; }
/// <summary>
/// The description that is displayed in the UI
/// </summary>
public string Description { get; }
/// <summary>
/// The Material icon to display in the UI, a full reference can be found
/// <see href="https://materialdesignicons.com">here</see>
/// </summary>
public string Icon { get; }
/// <summary>
/// The type of the layer brush
/// </summary>
public Type LayerBrushType { get; }
/// <summary>
/// The plugin that provided this <see cref="LayerBrushDescriptor" />
/// </summary>
public LayerBrushProvider LayerBrushProvider { get; }
/// <summary>
/// Gets or sets the kernel used to instantiate the described layer brush
/// </summary>
internal IKernel Kernel { get; set; }
/// <summary>
/// Creates an instance of the described brush and applies it to the layer
/// </summary>
internal void CreateInstance(Layer layer)
{
if (layer.LayerBrush != null)
throw new ArtemisCoreException("Layer already has an instantiated layer brush");
var brush = (BaseLayerBrush) Kernel.Get(LayerBrushType);
brush.Layer = layer;
brush.Descriptor = this;
brush.Initialize();
brush.Update(0);
layer.LayerBrush = brush;
layer.OnLayerBrushUpdated();
}
}
}