mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Code style - Omit the type in a new expressions
This commit is contained in:
1 parent
099f56f4fe
commit
10e6cdc54b
117 files changed
+251
-252
No files matched your search
@@ -34,7 +34,7 @@ namespace Artemis.Core
|
||||
return Stops.OrderBy(c => c.Position).Select(c => c.Color).ToArray();
|
||||
|
||||
List<SKColor> colors = Stops.OrderBy(c => c.Position).Select(c => c.Color).ToList();
|
||||
List<SKColor> result = new List<SKColor>();
|
||||
List<SKColor> result = new();
|
||||
|
||||
for (int i = 0; i <= timesToRepeat; i++)
|
||||
result.AddRange(colors);
|
||||
@@ -57,7 +57,7 @@ namespace Artemis.Core
|
||||
|
||||
// Create stops and a list of divided stops
|
||||
List<float> stops = Stops.OrderBy(c => c.Position).Select(c => c.Position / (timesToRepeat + 1)).ToList();
|
||||
List<float> result = new List<float>();
|
||||
List<float> result = new();
|
||||
|
||||
// For each repeat cycle, add the base stops to the end result
|
||||
for (int i = 0; i <= timesToRepeat; i++)
|
||||
@@ -120,7 +120,7 @@ namespace Artemis.Core
|
||||
public static ColorGradient GetUnicornBarf()
|
||||
{
|
||||
const int amount = 8;
|
||||
ColorGradient gradient = new ColorGradient();
|
||||
ColorGradient gradient = new();
|
||||
|
||||
for (int i = 0; i <= amount; i++)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public abstract class DataModelConditionPart : IDisposable
|
||||
{
|
||||
private readonly List<DataModelConditionPart> _children = new List<DataModelConditionPart>();
|
||||
private readonly List<DataModelConditionPart> _children = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parent of this part
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace Artemis.Core
|
||||
return;
|
||||
|
||||
// Ensure the list path is valid and points to a list
|
||||
DataModelPath eventPath = new DataModelPath(null, Entity.EventPath);
|
||||
DataModelPath eventPath = new(null, Entity.EventPath);
|
||||
// Can't check this on an invalid list, if it becomes valid later lets hope for the best
|
||||
if (eventPath.IsValid && !PointsToEvent(eventPath))
|
||||
return;
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace Artemis.Core
|
||||
return;
|
||||
|
||||
// Ensure the list path is valid and points to a list
|
||||
DataModelPath listPath = new DataModelPath(null, Entity.ListPath);
|
||||
DataModelPath listPath = new(null, Entity.ListPath);
|
||||
Type listType = listPath.GetPropertyType()!;
|
||||
// Can't check this on an invalid list, if it becomes valid later lets hope for the best
|
||||
if (listPath.IsValid && !PointsToList(listPath))
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public class ConditionalDataBinding<TLayerProperty, TProperty> : IDataBindingMode<TLayerProperty, TProperty>
|
||||
{
|
||||
private readonly List<DataBindingCondition<TLayerProperty, TProperty>> _conditions = new List<DataBindingCondition<TLayerProperty, TProperty>>();
|
||||
private readonly List<DataBindingCondition<TLayerProperty, TProperty>> _conditions = new();
|
||||
private bool _disposed;
|
||||
|
||||
internal ConditionalDataBinding(DataBinding<TLayerProperty, TProperty> dataBinding, ConditionalDataBindingEntity entity)
|
||||
@@ -81,7 +81,7 @@ namespace Artemis.Core
|
||||
if (_disposed)
|
||||
throw new ObjectDisposedException("ConditionalDataBinding");
|
||||
|
||||
DataBindingCondition<TLayerProperty, TProperty> condition = new DataBindingCondition<TLayerProperty, TProperty>(this);
|
||||
DataBindingCondition<TLayerProperty, TProperty> condition = new(this);
|
||||
_conditions.Add(condition);
|
||||
|
||||
ApplyOrder();
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public class DirectDataBinding<TLayerProperty, TProperty> : IDataBindingMode<TLayerProperty, TProperty>
|
||||
{
|
||||
private readonly List<DataBindingModifier<TLayerProperty, TProperty>> _modifiers = new List<DataBindingModifier<TLayerProperty, TProperty>>();
|
||||
private readonly List<DataBindingModifier<TLayerProperty, TProperty>> _modifiers = new();
|
||||
private bool _disposed;
|
||||
|
||||
internal DirectDataBinding(DataBinding<TLayerProperty, TProperty> dataBinding, DirectDataBindingEntity entity)
|
||||
@@ -156,7 +156,7 @@ namespace Artemis.Core
|
||||
if (_disposed)
|
||||
throw new ObjectDisposedException("DirectDataBinding");
|
||||
|
||||
DataBindingModifier<TLayerProperty, TProperty> modifier = new DataBindingModifier<TLayerProperty, TProperty>(this, type);
|
||||
DataBindingModifier<TLayerProperty, TProperty> modifier = new(this, type);
|
||||
_modifiers.Add(modifier);
|
||||
|
||||
ApplyOrder();
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Artemis.Core
|
||||
/// <para>Always empty if <see cref="TrackHistory" /> is <see langword="false" /></para>
|
||||
/// </summary>
|
||||
[DataModelProperty(Description = "The arguments of the last time this event triggered")]
|
||||
public Queue<T> EventArgumentsHistory { get; } = new Queue<T>(20);
|
||||
public Queue<T> EventArgumentsHistory { get; } = new(20);
|
||||
|
||||
/// <summary>
|
||||
/// Trigger the event with the given <paramref name="eventArgs" />
|
||||
@@ -157,14 +157,14 @@ namespace Artemis.Core
|
||||
/// <para>Always empty if <see cref="TrackHistory" /> is <see langword="false" /></para>
|
||||
/// </summary>
|
||||
[DataModelProperty(Description = "The arguments of the last time this event triggered")]
|
||||
public Queue<DataModelEventArgs> EventArgumentsHistory { get; } = new Queue<DataModelEventArgs>(20);
|
||||
public Queue<DataModelEventArgs> EventArgumentsHistory { get; } = new(20);
|
||||
|
||||
/// <summary>
|
||||
/// Trigger the event
|
||||
/// </summary>
|
||||
public void Trigger()
|
||||
{
|
||||
DataModelEventArgs eventArgs = new DataModelEventArgs {TriggerTime = DateTime.Now};
|
||||
DataModelEventArgs eventArgs = new() {TriggerTime = DateTime.Now};
|
||||
|
||||
LastEventArguments = eventArgs;
|
||||
LastTrigger = DateTime.Now;
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace Artemis.Core
|
||||
if (Target == null)
|
||||
return;
|
||||
|
||||
DataModelPathSegment startSegment = new DataModelPathSegment(this, "target", "target");
|
||||
DataModelPathSegment startSegment = new(this, "target", "target");
|
||||
startSegment.Node = _segments.AddFirst(startSegment);
|
||||
|
||||
// On an empty path don't bother processing segments
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Artemis.Core
|
||||
/// <inheritdoc />
|
||||
public override List<ILayerProperty> GetAllLayerProperties()
|
||||
{
|
||||
List<ILayerProperty> result = new List<ILayerProperty>();
|
||||
List<ILayerProperty> result = new();
|
||||
foreach (BaseLayerEffect layerEffect in LayerEffects)
|
||||
if (layerEffect.BaseProperties != null)
|
||||
result.AddRange(layerEffect.BaseProperties.GetAllLayerProperties());
|
||||
@@ -151,7 +151,7 @@ namespace Artemis.Core
|
||||
if (Disposed)
|
||||
throw new ObjectDisposedException("Folder");
|
||||
|
||||
SKPath path = new SKPath {FillType = SKPathFillType.Winding};
|
||||
SKPath path = new() {FillType = SKPathFillType.Winding};
|
||||
foreach (ProfileElement child in Children)
|
||||
if (child is RenderProfileElement effectChild && effectChild.Path != null)
|
||||
path.AddPath(effectChild.Path);
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace Artemis.Core
|
||||
/// <inheritdoc />
|
||||
public override List<ILayerProperty> GetAllLayerProperties()
|
||||
{
|
||||
List<ILayerProperty> result = new List<ILayerProperty>();
|
||||
List<ILayerProperty> result = new();
|
||||
result.AddRange(General.GetAllLayerProperties());
|
||||
result.AddRange(Transform.GetAllLayerProperties());
|
||||
if (LayerBrush?.BaseProperties != null)
|
||||
@@ -221,7 +221,7 @@ namespace Artemis.Core
|
||||
LayerEntity.Leds.Clear();
|
||||
foreach (ArtemisLed artemisLed in Leds)
|
||||
{
|
||||
LedEntity ledEntity = new LedEntity
|
||||
LedEntity ledEntity = new()
|
||||
{
|
||||
DeviceIdentifier = artemisLed.Device.RgbDevice.GetDeviceIdentifier(),
|
||||
LedName = artemisLed.RgbLed.Id.ToString()
|
||||
@@ -336,7 +336,7 @@ namespace Artemis.Core
|
||||
Renderer.Paint.BlendMode = General.BlendMode.CurrentValue;
|
||||
Renderer.Paint.Color = new SKColor(0, 0, 0, (byte) (Transform.Opacity.CurrentValue * 2.55f));
|
||||
|
||||
using SKPath renderPath = new SKPath();
|
||||
using SKPath renderPath = new();
|
||||
if (General.ShapeType.CurrentValue == LayerShapeType.Rectangle)
|
||||
renderPath.AddRect(Renderer.Path.Bounds);
|
||||
else
|
||||
@@ -415,7 +415,7 @@ namespace Artemis.Core
|
||||
}
|
||||
else
|
||||
{
|
||||
SKPath path = new SKPath {FillType = SKPathFillType.Winding};
|
||||
SKPath path = new() {FillType = SKPathFillType.Winding};
|
||||
foreach (ArtemisLed artemisLed in Leds)
|
||||
path.AddRect(artemisLed.AbsoluteRectangle);
|
||||
|
||||
@@ -569,7 +569,7 @@ namespace Artemis.Core
|
||||
if (Disposed)
|
||||
throw new ObjectDisposedException("Layer");
|
||||
|
||||
List<ArtemisLed> leds = new List<ArtemisLed>();
|
||||
List<ArtemisLed> leds = new();
|
||||
|
||||
// Get the surface LEDs for this layer
|
||||
List<ArtemisLed> availableLeds = surface.Devices.SelectMany(d => d.Leds).ToList();
|
||||
|
||||
@@ -292,7 +292,7 @@ namespace Artemis.Core
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
LayerPropertyKeyframe<T> keyframe = new LayerPropertyKeyframe<T>(
|
||||
LayerPropertyKeyframe<T> keyframe = new(
|
||||
CoreJson.DeserializeObject<T>(keyframeEntity.Value)!, keyframeEntity.Position, (Easings.Functions) keyframeEntity.EasingFunction, this
|
||||
);
|
||||
AddKeyframe(keyframe);
|
||||
@@ -366,9 +366,9 @@ namespace Artemis.Core
|
||||
#region Data bindings
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
internal readonly List<IDataBindingRegistration> _dataBindingRegistrations = new List<IDataBindingRegistration>();
|
||||
internal readonly List<IDataBindingRegistration> _dataBindingRegistrations = new();
|
||||
|
||||
internal readonly List<IDataBinding> _dataBindings = new List<IDataBinding>();
|
||||
internal readonly List<IDataBinding> _dataBindings = new();
|
||||
// ReSharper restore InconsistentNaming
|
||||
|
||||
/// <summary>
|
||||
@@ -444,7 +444,7 @@ namespace Artemis.Core
|
||||
if (dataBindingRegistration.DataBinding != null)
|
||||
throw new ArtemisCoreException("Provided data binding registration already has an enabled data binding");
|
||||
|
||||
DataBinding<T, TProperty> dataBinding = new DataBinding<T, TProperty>(dataBindingRegistration);
|
||||
DataBinding<T, TProperty> dataBinding = new(dataBindingRegistration);
|
||||
_dataBindings.Add(dataBinding);
|
||||
|
||||
OnDataBindingEnabled(new LayerPropertyEventArgs<T>(dataBinding.LayerProperty));
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Artemis.Core
|
||||
/// <inheritdoc />
|
||||
public KeyframeEntity GetKeyframeEntity()
|
||||
{
|
||||
return new KeyframeEntity
|
||||
return new()
|
||||
{
|
||||
Value = CoreJson.SerializeObject(Value),
|
||||
Position = Position,
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Artemis.Core
|
||||
if (!PropertiesInitialized)
|
||||
return new List<ILayerProperty>();
|
||||
|
||||
List<ILayerProperty> result = new List<ILayerProperty>(LayerProperties);
|
||||
List<ILayerProperty> result = new(LayerProperties);
|
||||
foreach (LayerPropertyGroup layerPropertyGroup in LayerPropertyGroups)
|
||||
result.AddRange(layerPropertyGroup.GetAllLayerProperties());
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Artemis.Core
|
||||
/// <inheritdoc />
|
||||
public override void CalculateRenderProperties()
|
||||
{
|
||||
SKPath path = new SKPath();
|
||||
SKPath path = new();
|
||||
path.AddOval(SKRect.Create(Layer.Bounds.Width, Layer.Bounds.Height));
|
||||
Path = path;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Artemis.Core
|
||||
/// <inheritdoc />
|
||||
public override void CalculateRenderProperties()
|
||||
{
|
||||
SKPath path = new SKPath();
|
||||
SKPath path = new();
|
||||
path.AddRect(SKRect.Create(Layer.Bounds.Width, Layer.Bounds.Height));
|
||||
Path = path;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public sealed class Profile : ProfileElement
|
||||
{
|
||||
private readonly object _lock = new object();
|
||||
private readonly object _lock = new();
|
||||
private bool _isActivated;
|
||||
|
||||
internal Profile(ProfileModule module, string name) : base(null!)
|
||||
@@ -26,7 +26,7 @@ namespace Artemis.Core
|
||||
UndoStack = new Stack<string>();
|
||||
RedoStack = new Stack<string>();
|
||||
|
||||
Folder _ = new Folder(this, "Root folder");
|
||||
Folder _ = new(this, "Root folder");
|
||||
Save();
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace Artemis.Core
|
||||
FolderEntity? rootFolder = ProfileEntity.Folders.FirstOrDefault(f => f.ParentId == EntityId);
|
||||
if (rootFolder == null)
|
||||
{
|
||||
Folder _ = new Folder(this, "Root folder");
|
||||
Folder _ = new(this, "Root folder");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace Artemis.Core
|
||||
if (Disposed)
|
||||
throw new ObjectDisposedException(GetType().Name);
|
||||
|
||||
List<Folder> folders = new List<Folder>();
|
||||
List<Folder> folders = new();
|
||||
foreach (Folder childFolder in Children.Where(c => c is Folder).Cast<Folder>())
|
||||
{
|
||||
// Add all folders in this element
|
||||
@@ -210,7 +210,7 @@ namespace Artemis.Core
|
||||
if (Disposed)
|
||||
throw new ObjectDisposedException(GetType().Name);
|
||||
|
||||
List<Layer> layers = new List<Layer>();
|
||||
List<Layer> layers = new();
|
||||
|
||||
// Add all layers in this element
|
||||
layers.AddRange(Children.Where(c => c is Layer).Cast<Layer>());
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Artemis.Core
|
||||
RenderElementEntity.LayerEffects.Clear();
|
||||
foreach (BaseLayerEffect layerEffect in LayerEffects)
|
||||
{
|
||||
LayerEffectEntity layerEffectEntity = new LayerEffectEntity
|
||||
LayerEffectEntity layerEffectEntity = new()
|
||||
{
|
||||
Id = layerEffect.EntityId,
|
||||
ProviderId = layerEffect.Descriptor?.PlaceholderFor ?? layerEffect.ProviderId,
|
||||
@@ -208,7 +208,7 @@ namespace Artemis.Core
|
||||
if (descriptor == null)
|
||||
throw new ArgumentNullException(nameof(descriptor));
|
||||
|
||||
LayerEffectEntity entity = new LayerEffectEntity
|
||||
LayerEffectEntity entity = new()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Enabled = true,
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Artemis.Core
|
||||
public class Timeline : CorePropertyChanged, IStorageModel
|
||||
{
|
||||
private const int MaxExtraTimelines = 15;
|
||||
private readonly object _lock = new object();
|
||||
private readonly object _lock = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="Timeline" /> class
|
||||
|
||||
Reference in new issue
Block a user