mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 03:19:56 +00:00
Core - Remove API versioning, we have MinimumVersion to achieve the same thing
This commit is contained in:
1 parent
e2cb73e327
commit
86f2426f37
184 files changed
+598
-523
No files matched your search
@@ -14,7 +14,7 @@ namespace Artemis.Core;
|
||||
public class ColorGradient : IList<ColorGradientStop>, IList, INotifyCollectionChanged
|
||||
{
|
||||
private static readonly SKColor[] FAST_LED_RAINBOW =
|
||||
{
|
||||
[
|
||||
new(0xFFFF0000), // Red
|
||||
new(0xFFFF9900), // Orange
|
||||
new(0xFFFFFF00), // Yellow
|
||||
@@ -24,11 +24,11 @@ public class ColorGradient : IList<ColorGradientStop>, IList, INotifyCollectionC
|
||||
new(0xFF9E22FF), // Purple
|
||||
new(0xFFFF34AE), // Pink
|
||||
new(0xFFFF0000) // and back to Red
|
||||
};
|
||||
];
|
||||
|
||||
private readonly List<ColorGradientStop> _stops;
|
||||
private SKColor[] _colors = Array.Empty<SKColor>();
|
||||
private float[] _positions = Array.Empty<float>();
|
||||
private SKColor[] _colors = [];
|
||||
private float[] _positions = [];
|
||||
private bool _dirty = true;
|
||||
private bool _updating;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ColorGradient : IList<ColorGradientStop>, IList, INotifyCollectionC
|
||||
/// </summary>
|
||||
public ColorGradient()
|
||||
{
|
||||
_stops = new List<ColorGradientStop>();
|
||||
_stops = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -60,7 +60,7 @@ public class ColorGradient : IList<ColorGradientStop>, IList, INotifyCollectionC
|
||||
/// <param name="colorGradient">The color gradient to copy</param>
|
||||
public ColorGradient(ColorGradient? colorGradient)
|
||||
{
|
||||
_stops = new List<ColorGradientStop>();
|
||||
_stops = [];
|
||||
if (colorGradient == null)
|
||||
return;
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ColorGradient : IList<ColorGradientStop>, IList, INotifyCollectionC
|
||||
/// <param name="stops">The stops to copy</param>
|
||||
public ColorGradient(List<ColorGradientStop> stops)
|
||||
{
|
||||
_stops = new List<ColorGradientStop>();
|
||||
_stops = [];
|
||||
foreach (ColorGradientStop colorGradientStop in stops)
|
||||
{
|
||||
ColorGradientStop stop = new(colorGradientStop.Color, colorGradientStop.Position);
|
||||
@@ -104,7 +104,7 @@ public class ColorGradient : IList<ColorGradientStop>, IList, INotifyCollectionC
|
||||
if (timesToRepeat == 0 && !seamless)
|
||||
return Colors;
|
||||
|
||||
List<SKColor> result = new();
|
||||
List<SKColor> result = [];
|
||||
if (timesToRepeat == 0)
|
||||
result = this.Select(c => c.Color).ToList();
|
||||
else
|
||||
@@ -132,7 +132,7 @@ public class ColorGradient : IList<ColorGradientStop>, IList, INotifyCollectionC
|
||||
if (timesToRepeat == 0 && seamless)
|
||||
return Positions;
|
||||
|
||||
List<float> result = new();
|
||||
List<float> result = [];
|
||||
if (timesToRepeat == 0)
|
||||
{
|
||||
result = this.Select(c => c.Position).ToList();
|
||||
@@ -456,7 +456,7 @@ public class ColorGradient : IList<ColorGradientStop>, IList, INotifyCollectionC
|
||||
/// </summary>
|
||||
public static ColorGradient GetUnicornBarf()
|
||||
{
|
||||
ColorGradient gradient = new();
|
||||
ColorGradient gradient = [];
|
||||
for (int index = 0; index < FAST_LED_RAINBOW.Length; index++)
|
||||
{
|
||||
SKColor skColor = FAST_LED_RAINBOW[index];
|
||||
@@ -473,7 +473,7 @@ public class ColorGradient : IList<ColorGradientStop>, IList, INotifyCollectionC
|
||||
/// <param name="stops">The amount of stops to add</param>
|
||||
public static ColorGradient GetRandom(int stops)
|
||||
{
|
||||
ColorGradient gradient = new();
|
||||
ColorGradient gradient = [];
|
||||
gradient.Randomize(stops);
|
||||
return gradient;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class EventCondition : CorePropertyChanged, INodeScriptCondition
|
||||
_entity = new EventConditionEntity();
|
||||
_displayName = profileElement.GetType().Name;
|
||||
_startNode = new EventConditionEventStartNode {X = -300};
|
||||
_script = new NodeScript<bool>($"Activate {_displayName}", $"Whether or not the event should activate the {_displayName}", ProfileElement.Profile, new List<DefaultNode> {_startNode});
|
||||
_script = new NodeScript<bool>($"Activate {_displayName}", $"Whether or not the event should activate the {_displayName}", ProfileElement.Profile, [_startNode]);
|
||||
}
|
||||
|
||||
internal EventCondition(EventConditionEntity entity, RenderProfileElement profileElement)
|
||||
@@ -288,8 +288,8 @@ public class EventCondition : CorePropertyChanged, INodeScriptCondition
|
||||
string name = $"Activate {_displayName}";
|
||||
string description = $"Whether or not the event should activate the {_displayName}";
|
||||
Script = _entity.Script != null
|
||||
? new NodeScript<bool>(name, description, _entity.Script, ProfileElement.Profile, new List<DefaultNode> {_startNode})
|
||||
: new NodeScript<bool>(name, description, ProfileElement.Profile, new List<DefaultNode> {_startNode});
|
||||
? new NodeScript<bool>(name, description, _entity.Script, ProfileElement.Profile, [_startNode])
|
||||
: new NodeScript<bool>(name, description, ProfileElement.Profile, [_startNode]);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Artemis.Core;
|
||||
/// <inheritdoc />
|
||||
public class DataBinding<TLayerProperty> : IDataBinding
|
||||
{
|
||||
private readonly List<IDataBindingProperty> _properties = new();
|
||||
private readonly List<IDataBindingProperty> _properties = [];
|
||||
private bool _disposed;
|
||||
private bool _isEnabled;
|
||||
private DataBindingNodeScript<TLayerProperty> _script;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class DataModelPath : IStorageModel, IDisposable, IPluginFeatureDependent
|
||||
Path = "";
|
||||
Entity = new DataModelPathEntity();
|
||||
|
||||
_segments = new LinkedList<DataModelPathSegment>();
|
||||
_segments = [];
|
||||
|
||||
Save();
|
||||
Initialize();
|
||||
@@ -45,7 +45,7 @@ public class DataModelPath : IStorageModel, IDisposable, IPluginFeatureDependent
|
||||
Path = path ?? throw new ArgumentNullException(nameof(path));
|
||||
Entity = new DataModelPathEntity();
|
||||
|
||||
_segments = new LinkedList<DataModelPathSegment>();
|
||||
_segments = [];
|
||||
|
||||
Save();
|
||||
Initialize();
|
||||
@@ -65,7 +65,7 @@ public class DataModelPath : IStorageModel, IDisposable, IPluginFeatureDependent
|
||||
Path = dataModelPath.Path;
|
||||
Entity = new DataModelPathEntity();
|
||||
|
||||
_segments = new LinkedList<DataModelPathSegment>();
|
||||
_segments = [];
|
||||
|
||||
Save();
|
||||
Initialize();
|
||||
@@ -81,7 +81,7 @@ public class DataModelPath : IStorageModel, IDisposable, IPluginFeatureDependent
|
||||
Path = entity.Path;
|
||||
Entity = entity;
|
||||
|
||||
_segments = new LinkedList<DataModelPathSegment>();
|
||||
_segments = [];
|
||||
|
||||
Load();
|
||||
Initialize();
|
||||
|
||||
@@ -242,7 +242,7 @@ public class DataModelPathSegment : IDisposable
|
||||
accessorExpression = Expression.Call(
|
||||
expression,
|
||||
nameof(DataModel.GetDynamicChildValue),
|
||||
_dynamicDataModelType != null ? new[] {_dynamicDataModelType} : null,
|
||||
_dynamicDataModelType != null ? [_dynamicDataModelType] : null,
|
||||
Expression.Constant(Identifier)
|
||||
);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public sealed class Folder : RenderProfileElement
|
||||
/// <inheritdoc />
|
||||
public override List<ILayerProperty> GetAllLayerProperties()
|
||||
{
|
||||
List<ILayerProperty> result = new();
|
||||
List<ILayerProperty> result = [];
|
||||
foreach (BaseLayerEffect layerEffect in LayerEffects)
|
||||
{
|
||||
if (layerEffect.BaseProperties != null)
|
||||
|
||||
@@ -19,13 +19,13 @@ public sealed class Layer : RenderProfileElement
|
||||
private const string BROKEN_STATE_BRUSH_NOT_FOUND = "Failed to load layer brush, ensure the plugin is enabled";
|
||||
private const string BROKEN_STATE_INIT_FAILED = "Failed to initialize layer brush";
|
||||
|
||||
private readonly List<Layer> _renderCopies = new();
|
||||
private readonly List<Layer> _renderCopies = [];
|
||||
private LayerGeneralProperties _general = new();
|
||||
private LayerTransformProperties _transform = new();
|
||||
private BaseLayerBrush? _layerBrush;
|
||||
private LayerShape? _layerShape;
|
||||
private List<ArtemisLed> _leds = new();
|
||||
private List<LedEntity> _missingLeds = new();
|
||||
private List<ArtemisLed> _leds = [];
|
||||
private List<LedEntity> _missingLeds = [];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="Layer" /> class and adds itself to the child collection of the provided
|
||||
@@ -82,11 +82,11 @@ public sealed class Layer : RenderProfileElement
|
||||
Parent = source;
|
||||
|
||||
// TODO: move to top
|
||||
_renderCopies = new List<Layer>();
|
||||
_renderCopies = [];
|
||||
_general = new LayerGeneralProperties();
|
||||
_transform = new LayerTransformProperties();
|
||||
|
||||
_leds = new List<ArtemisLed>();
|
||||
_leds = [];
|
||||
Leds = new ReadOnlyCollection<ArtemisLed>(_leds);
|
||||
|
||||
Adapter = new LayerAdapter(this);
|
||||
@@ -169,7 +169,7 @@ public sealed class Layer : RenderProfileElement
|
||||
/// <inheritdoc />
|
||||
public override List<ILayerProperty> GetAllLayerProperties()
|
||||
{
|
||||
List<ILayerProperty> result = new();
|
||||
List<ILayerProperty> result = [];
|
||||
result.AddRange(General.GetAllLayerProperties());
|
||||
result.AddRange(Transform.GetAllLayerProperties());
|
||||
if (LayerBrush?.BaseProperties != null)
|
||||
@@ -801,7 +801,7 @@ public sealed class Layer : RenderProfileElement
|
||||
if (Disposed)
|
||||
throw new ObjectDisposedException("Layer");
|
||||
|
||||
List<ArtemisLed> leds = new();
|
||||
List<ArtemisLed> leds = [];
|
||||
|
||||
// Get the surface LEDs for this layer
|
||||
List<ArtemisLed> availableLeds = devices.SelectMany(d => d.Leds).ToList();
|
||||
|
||||
@@ -17,7 +17,7 @@ public class LayerAdapter : IStorageModel
|
||||
|
||||
internal LayerAdapter(Layer layer)
|
||||
{
|
||||
_adaptionHints = new List<IAdaptionHint>();
|
||||
_adaptionHints = [];
|
||||
Layer = layer;
|
||||
AdaptionHints = new ReadOnlyCollection<IAdaptionHint>(_adaptionHints);
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class LayerAdapter : IStorageModel
|
||||
else
|
||||
{
|
||||
List<ArtemisLed> availableLeds = devices.SelectMany(d => d.Leds).ToList();
|
||||
List<ArtemisLed> usedLeds = new();
|
||||
List<ArtemisLed> usedLeds = [];
|
||||
|
||||
foreach (LedEntity ledEntity in Layer.LayerEntity.Leds)
|
||||
{
|
||||
@@ -73,7 +73,7 @@ public class LayerAdapter : IStorageModel
|
||||
/// </summary>
|
||||
public List<IAdaptionHint> DetermineHints(IEnumerable<ArtemisDevice> devices)
|
||||
{
|
||||
List<IAdaptionHint> newHints = new();
|
||||
List<IAdaptionHint> newHints = [];
|
||||
if (devices.All(DoesLayerCoverDevice))
|
||||
{
|
||||
DeviceAdaptionHint hint = new() {DeviceType = RGBDeviceType.All};
|
||||
|
||||
@@ -44,7 +44,7 @@ public class LayerProperty<T> : CorePropertyChanged, ILayerProperty
|
||||
else
|
||||
_baseValue = default!;
|
||||
|
||||
_keyframes = new List<LayerPropertyKeyframe<T>>();
|
||||
_keyframes = [];
|
||||
Keyframes = new ReadOnlyCollection<LayerPropertyKeyframe<T>>(_keyframes);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ public abstract class LayerPropertyGroup : IDisposable, IPluginFeatureDependent
|
||||
GroupDescription = null!;
|
||||
Path = "";
|
||||
|
||||
_layerProperties = new List<ILayerProperty>();
|
||||
_layerPropertyGroups = new List<LayerPropertyGroup>();
|
||||
_layerProperties = [];
|
||||
_layerPropertyGroups = [];
|
||||
|
||||
LayerProperties = new ReadOnlyCollection<ILayerProperty>(_layerProperties);
|
||||
LayerPropertyGroups = new ReadOnlyCollection<LayerPropertyGroup>(_layerPropertyGroups);
|
||||
|
||||
@@ -23,7 +23,7 @@ public sealed class Profile : ProfileElement
|
||||
ProfileEntity = profileEntity;
|
||||
EntityId = profileEntity.Id;
|
||||
|
||||
Exceptions = new List<Exception>();
|
||||
Exceptions = [];
|
||||
|
||||
Load();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public abstract class ProfileElement : BreakableModel, IDisposable, IPluginFeatu
|
||||
internal ProfileElement(Profile profile)
|
||||
{
|
||||
_profile = profile;
|
||||
ChildrenList = new List<ProfileElement>();
|
||||
ChildrenList = [];
|
||||
Children = new ReadOnlyCollection<ProfileElement>(ChildrenList);
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ public abstract class ProfileElement : BreakableModel, IDisposable, IPluginFeatu
|
||||
if (Disposed)
|
||||
throw new ObjectDisposedException(GetType().Name);
|
||||
|
||||
List<RenderProfileElement> elements = new();
|
||||
List<RenderProfileElement> elements = [];
|
||||
foreach (RenderProfileElement childElement in Children.Where(c => c is RenderProfileElement).Cast<RenderProfileElement>())
|
||||
{
|
||||
// Add all folders in this element
|
||||
@@ -301,7 +301,7 @@ public abstract class ProfileElement : BreakableModel, IDisposable, IPluginFeatu
|
||||
if (Disposed)
|
||||
throw new ObjectDisposedException(GetType().Name);
|
||||
|
||||
List<Folder> folders = new();
|
||||
List<Folder> folders = [];
|
||||
foreach (Folder childFolder in Children.Where(c => c is Folder).Cast<Folder>())
|
||||
{
|
||||
// Add all folders in this element
|
||||
@@ -322,7 +322,7 @@ public abstract class ProfileElement : BreakableModel, IDisposable, IPluginFeatu
|
||||
if (Disposed)
|
||||
throw new ObjectDisposedException(GetType().Name);
|
||||
|
||||
List<Layer> layers = new();
|
||||
List<Layer> layers = [];
|
||||
|
||||
// Add all layers in this element
|
||||
layers.AddRange(Children.Where(c => c is Layer).Cast<Layer>());
|
||||
|
||||
@@ -21,7 +21,7 @@ public abstract class RenderProfileElement : ProfileElement
|
||||
|
||||
internal RenderProfileElement(ProfileElement parent, Profile profile) : base(profile)
|
||||
{
|
||||
_layerEffects = new List<BaseLayerEffect>();
|
||||
_layerEffects = [];
|
||||
_displayCondition = new AlwaysOnCondition(this);
|
||||
Timeline = new Timeline();
|
||||
LayerEffects = new ReadOnlyCollection<BaseLayerEffect>(_layerEffects);
|
||||
|
||||
Reference in new issue
Block a user