mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-02-04 02:43:32 +00:00
Core - Remove API versioning, we have MinimumVersion to achieve the same thing
This commit is contained in:
parent
e2cb73e327
commit
86f2426f37
@ -10,7 +10,6 @@
|
||||
<Platforms>x64</Platforms>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PackageId>ArtemisRGB.Core</PackageId>
|
||||
<PluginApiVersion>1</PluginApiVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
@ -151,19 +151,19 @@ public static class ColorQuantizer
|
||||
{
|
||||
SKColor[] colors = QuantizeSplit(bitmap.Pixels, 8);
|
||||
ColorSwatch swatch = FindAllColorVariations(colors);
|
||||
SKColor[] swatchArray = new SKColor[]
|
||||
{
|
||||
SKColor[] swatchArray =
|
||||
[
|
||||
swatch.Muted,
|
||||
swatch.Vibrant,
|
||||
swatch.DarkMuted,
|
||||
swatch.DarkVibrant,
|
||||
swatch.LightMuted,
|
||||
swatch.LightVibrant
|
||||
};
|
||||
];
|
||||
|
||||
ColorSorter.Sort(swatchArray, SKColors.Black);
|
||||
|
||||
ColorGradient gradient = new();
|
||||
ColorGradient gradient = [];
|
||||
|
||||
for (int i = 0; i < swatchArray.Length; i++)
|
||||
gradient.Add(new ColorGradientStop(swatchArray[i], (float)i / (swatchArray.Length - 1)));
|
||||
|
||||
@ -71,12 +71,6 @@ public static class Constants
|
||||
/// </summary>
|
||||
public static readonly string WorkshopFolder = Path.Combine(DataFolder, "workshop");
|
||||
|
||||
/// <summary>
|
||||
/// The current API version for plugins
|
||||
/// </summary>
|
||||
public static readonly int PluginApiVersion = int.Parse(CoreAssembly.GetCustomAttributes<AssemblyMetadataAttribute>().FirstOrDefault(a => a.Key == "PluginApiVersion")?.Value ??
|
||||
throw new InvalidOperationException("Cannot find PluginApiVersion metadata in assembly"));
|
||||
|
||||
/// <summary>
|
||||
/// The current version of the application
|
||||
/// </summary>
|
||||
|
||||
@ -6,7 +6,7 @@ public class ColorGradientLayerProperty : LayerProperty<ColorGradient>
|
||||
internal ColorGradientLayerProperty()
|
||||
{
|
||||
KeyframesSupported = false;
|
||||
DefaultValue = new ColorGradient();
|
||||
DefaultValue = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -54,7 +54,7 @@ public static class ContainerExtensions
|
||||
|
||||
// Bind plugin service interfaces, DryIoc expects at least one match when calling RegisterMany so ensure there is something to register first
|
||||
if (plugin.Assembly != null && plugin.Assembly.GetTypes().Any(t => t.IsAssignableTo<IPluginService>()))
|
||||
container.RegisterMany(new[] {plugin.Assembly}, type => type.IsAssignableTo<IPluginService>(), Reuse.Singleton, ifAlreadyRegistered: IfAlreadyRegistered.Keep);
|
||||
container.RegisterMany([plugin.Assembly], type => type.IsAssignableTo<IPluginService>(), Reuse.Singleton, ifAlreadyRegistered: IfAlreadyRegistered.Keep);
|
||||
}
|
||||
|
||||
private static bool HasAccessToProtectedService(Request request)
|
||||
|
||||
@ -8,7 +8,7 @@ namespace Artemis.Core.DryIoc.Factories;
|
||||
|
||||
internal class PluginSettingsFactory : IPluginSettingsFactory
|
||||
{
|
||||
private static readonly List<PluginSettings> PluginSettings = new();
|
||||
private static readonly List<PluginSettings> PluginSettings = [];
|
||||
private readonly IPluginManagementService _pluginManagementService;
|
||||
private readonly IPluginRepository _pluginRepository;
|
||||
|
||||
|
||||
@ -14,15 +14,15 @@ public static class TypeExtensions
|
||||
{
|
||||
private static readonly Dictionary<Type, List<Type>> PrimitiveTypeConversions = new()
|
||||
{
|
||||
{typeof(decimal), new List<Type> {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(char)}},
|
||||
{typeof(double), new List<Type> {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(char), typeof(float)}},
|
||||
{typeof(float), new List<Type> {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(char), typeof(float)}},
|
||||
{typeof(ulong), new List<Type> {typeof(byte), typeof(ushort), typeof(uint), typeof(char)}},
|
||||
{typeof(long), new List<Type> {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(char)}},
|
||||
{typeof(uint), new List<Type> {typeof(byte), typeof(ushort), typeof(char)}},
|
||||
{typeof(int), new List<Type> {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(char)}},
|
||||
{typeof(ushort), new List<Type> {typeof(byte), typeof(char)}},
|
||||
{typeof(short), new List<Type> {typeof(byte)}}
|
||||
{typeof(decimal), [typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(char)]},
|
||||
{typeof(double), [typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(char), typeof(float)]},
|
||||
{typeof(float), [typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(char), typeof(float)]},
|
||||
{typeof(ulong), [typeof(byte), typeof(ushort), typeof(uint), typeof(char)]},
|
||||
{typeof(long), [typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(char)]},
|
||||
{typeof(uint), [typeof(byte), typeof(ushort), typeof(char)]},
|
||||
{typeof(int), [typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(char)]},
|
||||
{typeof(ushort), [typeof(byte), typeof(char)]},
|
||||
{typeof(short), [typeof(byte)]}
|
||||
};
|
||||
|
||||
private static readonly Dictionary<Type, string> TypeKeywords = new()
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -130,7 +130,7 @@ public class ProfileConfigurationIcon : CorePropertyChanged, IStorageModel
|
||||
_entity.ProfileConfiguration.IconType = (int) IconType;
|
||||
_entity.ProfileConfiguration.MaterialIcon = IconType == ProfileConfigurationIconType.MaterialIcon ? IconName : null;
|
||||
_entity.ProfileConfiguration.IconFill = Fill;
|
||||
_entity.Icon = IconBytes ?? Array.Empty<byte>();
|
||||
_entity.Icon = IconBytes ?? [];
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -43,9 +43,9 @@ public class ArtemisDevice : CorePropertyChanged
|
||||
|
||||
LedIds = new ReadOnlyDictionary<LedId, ArtemisLed>(new Dictionary<LedId, ArtemisLed>());
|
||||
Leds = new ReadOnlyCollection<ArtemisLed>(new List<ArtemisLed>());
|
||||
InputIdentifiers = new List<ArtemisDeviceInputIdentifier>();
|
||||
InputIdentifiers = [];
|
||||
InputMappings = new Dictionary<ArtemisLed, ArtemisLed>();
|
||||
Categories = new HashSet<DeviceCategory>();
|
||||
Categories = [];
|
||||
LayoutSelection = new LayoutSelection {Type = DefaultLayoutProvider.LAYOUT_TYPE};
|
||||
|
||||
RgbDevice.ColorCorrections.Clear();
|
||||
@ -72,9 +72,9 @@ public class ArtemisDevice : CorePropertyChanged
|
||||
|
||||
LedIds = new ReadOnlyDictionary<LedId, ArtemisLed>(new Dictionary<LedId, ArtemisLed>());
|
||||
Leds = new ReadOnlyCollection<ArtemisLed>(new List<ArtemisLed>());
|
||||
InputIdentifiers = new List<ArtemisDeviceInputIdentifier>();
|
||||
InputIdentifiers = [];
|
||||
InputMappings = new Dictionary<ArtemisLed, ArtemisLed>();
|
||||
Categories = new HashSet<DeviceCategory>();
|
||||
Categories = [];
|
||||
LayoutSelection = new LayoutSelection {Type = DefaultLayoutProvider.LAYOUT_TYPE};
|
||||
|
||||
foreach (DeviceInputIdentifierEntity identifierEntity in DeviceEntity.InputIdentifiers)
|
||||
|
||||
@ -21,7 +21,7 @@ public class ArtemisLayout
|
||||
public ArtemisLayout(string filePath)
|
||||
{
|
||||
FilePath = filePath;
|
||||
Leds = new List<ArtemisLedLayout>();
|
||||
Leds = [];
|
||||
IsDefaultLayout = filePath.StartsWith(DefaultLayoutPath);
|
||||
|
||||
LoadLayout();
|
||||
@ -70,7 +70,7 @@ public class ArtemisLayout
|
||||
device.Size = new Size(MathF.Round(RgbLayout.Width), MathF.Round(RgbLayout.Height));
|
||||
device.DeviceInfo.LayoutMetadata = RgbLayout.CustomData;
|
||||
|
||||
HashSet<LedId> ledIds = new();
|
||||
HashSet<LedId> ledIds = [];
|
||||
foreach (ILedLayout layoutLed in RgbLayout.Leds)
|
||||
{
|
||||
if (Enum.TryParse(layoutLed.Id, true, out LedId ledId))
|
||||
|
||||
@ -16,7 +16,7 @@ public abstract class LayerBrushProvider : PluginFeature
|
||||
/// </summary>
|
||||
protected LayerBrushProvider()
|
||||
{
|
||||
_layerBrushDescriptors = new List<LayerBrushDescriptor>();
|
||||
_layerBrushDescriptors = [];
|
||||
LayerBrushDescriptors = new ReadOnlyCollection<LayerBrushDescriptor>(_layerBrushDescriptors);
|
||||
Disabled += OnDisabled;
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ public abstract class LayerEffectProvider : PluginFeature
|
||||
/// </summary>
|
||||
protected LayerEffectProvider()
|
||||
{
|
||||
_layerEffectDescriptors = new List<LayerEffectDescriptor>();
|
||||
_layerEffectDescriptors = [];
|
||||
LayerEffectDescriptors = new ReadOnlyCollection<LayerEffectDescriptor>(_layerEffectDescriptors);
|
||||
Disabled += OnDisabled;
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ namespace Artemis.Core.Modules;
|
||||
public abstract class DataModel
|
||||
{
|
||||
private const StringComparison PathsStringComparison = StringComparison.OrdinalIgnoreCase;
|
||||
private readonly List<DataModelPath> _activePaths = new();
|
||||
private readonly List<DataModelPath> _activePaths = [];
|
||||
private readonly HashSet<string> _activePathsHashSet = new(StringComparer.FromComparison(PathsStringComparison));
|
||||
private readonly Dictionary<string, DynamicChild> _dynamicChildren = new();
|
||||
|
||||
|
||||
@ -111,13 +111,13 @@ public abstract class Module<T> : Module where T : DataModel, new()
|
||||
/// </summary>
|
||||
public abstract class Module : PluginFeature
|
||||
{
|
||||
private readonly List<(DefaultCategoryName, string)> _defaultProfilePaths = new();
|
||||
private readonly List<(DefaultCategoryName, string)> _pendingDefaultProfilePaths = new();
|
||||
private readonly List<(DefaultCategoryName, string)> _defaultProfilePaths = [];
|
||||
private readonly List<(DefaultCategoryName, string)> _pendingDefaultProfilePaths = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all properties ignored at runtime using <c>IgnoreProperty(x => x.y)</c>
|
||||
/// </summary>
|
||||
protected internal readonly List<PropertyInfo> HiddenPropertiesList = new();
|
||||
protected internal readonly List<PropertyInfo> HiddenPropertiesList = [];
|
||||
|
||||
/// <summary>
|
||||
/// The base constructor of the <see cref="Module" /> class.
|
||||
|
||||
@ -18,7 +18,7 @@ public abstract class NodeProvider : PluginFeature
|
||||
/// </summary>
|
||||
public NodeProvider()
|
||||
{
|
||||
_nodeDescriptors = new List<NodeData>();
|
||||
_nodeDescriptors = [];
|
||||
NodeDescriptors = new ReadOnlyCollection<NodeData>(_nodeDescriptors);
|
||||
Disabled += OnDisabled;
|
||||
}
|
||||
|
||||
@ -31,8 +31,8 @@ public class Plugin : CorePropertyChanged, IDisposable
|
||||
Info.Plugin = this;
|
||||
|
||||
_loadedFromStorage = loadedFromStorage;
|
||||
_features = new List<PluginFeatureInfo>();
|
||||
_profilers = new List<Profiler>();
|
||||
_features = [];
|
||||
_profilers = [];
|
||||
|
||||
Features = new ReadOnlyCollection<PluginFeatureInfo>(_features);
|
||||
Profilers = new ReadOnlyCollection<Profiler>(_profilers);
|
||||
|
||||
@ -78,7 +78,7 @@ public class PluginFeatureInfo : IPrerequisitesSubject
|
||||
public PluginFeature? Instance { get; internal set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<PluginPrerequisite> Prerequisites { get; } = new();
|
||||
public List<PluginPrerequisite> Prerequisites { get; } = [];
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<PluginPrerequisite> PlatformPrerequisites => Prerequisites.Where(p => p.AppliesToPlatform());
|
||||
|
||||
@ -110,12 +110,6 @@ public class PluginInfo : IPrerequisitesSubject
|
||||
[JsonInclude]
|
||||
public PluginPlatform? Platforms { get; internal init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the API version the plugin was built for
|
||||
/// </summary>
|
||||
[JsonInclude]
|
||||
public Version? Api { get; internal init; } = new(1, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the minimum version of Artemis required by this plugin
|
||||
/// </summary>
|
||||
@ -125,28 +119,34 @@ public class PluginInfo : IPrerequisitesSubject
|
||||
/// Gets the plugin this info is associated with
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public Plugin Plugin { get; internal set; } = null!;
|
||||
public Plugin? Plugin { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string representing either a full path pointing to an svg or the markdown icon
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public string? ResolvedIcon => Icon == null ? null : Icon.Contains('.') ? Plugin.ResolveRelativePath(Icon) : Icon;
|
||||
public string? ResolvedIcon => Icon == null ? null : Icon.Contains('.') ? Plugin?.ResolveRelativePath(Icon) : Icon;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean indicating whether this plugin is compatible with the current operating system and API version
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public bool IsCompatible => Platforms.MatchesCurrentOperatingSystem() && Api != null && Api.Major >= Constants.PluginApiVersion && MatchesMinimumVersion();
|
||||
public bool IsCompatible => Platforms.MatchesCurrentOperatingSystem() && MatchesMinimumVersion();
|
||||
|
||||
/// <inheritdoc />
|
||||
[JsonIgnore]
|
||||
public List<PluginPrerequisite> Prerequisites { get; } = new();
|
||||
public List<PluginPrerequisite> Prerequisites { get; } = [];
|
||||
|
||||
/// <inheritdoc />
|
||||
[JsonIgnore]
|
||||
public IEnumerable<PluginPrerequisite> PlatformPrerequisites => Prerequisites.Where(p => p.AppliesToPlatform());
|
||||
|
||||
/// <summary>
|
||||
/// Gets the exception thrown while loading
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public Exception? LoadException { get; internal set; }
|
||||
|
||||
[JsonIgnore]
|
||||
internal string PreferredPluginDirectory => $"{Main.Split(".dll")[0].Replace("/", "").Replace("\\", "")}-{Guid.ToString().Substring(0, 8)}";
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ internal sealed class SurfaceManager : IDisposable
|
||||
{
|
||||
private readonly IRenderer _renderer;
|
||||
private readonly TimerUpdateTrigger _updateTrigger;
|
||||
private readonly List<ArtemisDevice> _devices = new();
|
||||
private readonly List<ArtemisDevice> _devices = [];
|
||||
private readonly SKTextureBrush _textureBrush = new(null) {CalculationMode = RenderMode.Absolute};
|
||||
|
||||
private ListLedGroup? _surfaceLedGroup;
|
||||
@ -44,7 +44,7 @@ internal sealed class SurfaceManager : IDisposable
|
||||
|
||||
public void AddDevices(IEnumerable<ArtemisDevice> devices)
|
||||
{
|
||||
List<IRGBDevice> newDevices = new();
|
||||
List<IRGBDevice> newDevices = [];
|
||||
lock (_devices)
|
||||
{
|
||||
foreach (ArtemisDevice artemisDevice in devices)
|
||||
@ -66,7 +66,7 @@ internal sealed class SurfaceManager : IDisposable
|
||||
|
||||
public void RemoveDevices(IEnumerable<ArtemisDevice> devices)
|
||||
{
|
||||
List<IRGBDevice> removedDevices = new();
|
||||
List<IRGBDevice> removedDevices = [];
|
||||
lock (_devices)
|
||||
{
|
||||
foreach (ArtemisDevice artemisDevice in devices)
|
||||
|
||||
@ -100,7 +100,7 @@ internal class InputService : IInputService
|
||||
|
||||
#region Providers
|
||||
|
||||
private readonly List<InputProvider> _inputProviders = new();
|
||||
private readonly List<InputProvider> _inputProviders = [];
|
||||
|
||||
public KeyboardToggleStatus KeyboardToggleStatus { get; private set; } = new(false, false, false);
|
||||
|
||||
@ -137,7 +137,7 @@ internal class InputService : IInputService
|
||||
#region Identification
|
||||
|
||||
private readonly Dictionary<Tuple<InputProvider, object>, ArtemisDevice> _deviceCache = new();
|
||||
private List<ArtemisDevice> _devices = new();
|
||||
private List<ArtemisDevice> _devices = [];
|
||||
private ArtemisDevice? _identifyingDevice;
|
||||
|
||||
public void IdentifyDevice(ArtemisDevice device)
|
||||
@ -308,7 +308,7 @@ internal class InputService : IInputService
|
||||
if (device != null)
|
||||
{
|
||||
// Ensure the device is in the dictionary
|
||||
_pressedKeys.TryAdd(device, new HashSet<KeyboardKey>());
|
||||
_pressedKeys.TryAdd(device, []);
|
||||
// Get the hash set of the device
|
||||
HashSet<KeyboardKey> pressedDeviceKeys = _pressedKeys[device];
|
||||
// See if the key is already pressed
|
||||
@ -389,7 +389,7 @@ internal class InputService : IInputService
|
||||
|
||||
#region Mouse
|
||||
|
||||
private readonly HashSet<MouseButton> _pressedButtons = new();
|
||||
private readonly HashSet<MouseButton> _pressedButtons = [];
|
||||
|
||||
|
||||
private void InputProviderOnMouseButtonDataReceived(object? sender, InputProviderMouseButtonEventArgs e)
|
||||
|
||||
@ -108,7 +108,13 @@ public interface IPluginManagementService : IArtemisService, IDisposable
|
||||
void DisablePluginFeature(PluginFeature pluginFeature, bool saveState);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin info of all loaded plugins
|
||||
/// Gets the plugin info of all plugins, regardless of whether they are currently loaded
|
||||
/// </summary>
|
||||
/// <returns>A list containing all the plugin info</returns>
|
||||
List<PluginInfo> GetAllPluginInfo();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of all loaded plugins
|
||||
/// </summary>
|
||||
/// <returns>A list containing all the plugin info</returns>
|
||||
List<Plugin> GetAllPlugins();
|
||||
|
||||
@ -28,6 +28,7 @@ internal class PluginManagementService : IPluginManagementService
|
||||
private readonly IContainer _container;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPluginRepository _pluginRepository;
|
||||
private readonly List<PluginInfo> _pluginInfos;
|
||||
private readonly List<Plugin> _plugins;
|
||||
private FileSystemWatcher? _hotReloadWatcher;
|
||||
private bool _disposed;
|
||||
@ -39,20 +40,29 @@ internal class PluginManagementService : IPluginManagementService
|
||||
_logger = logger;
|
||||
_pluginRepository = pluginRepository;
|
||||
_deviceRepository = deviceRepository;
|
||||
_plugins = new List<Plugin>();
|
||||
_pluginInfos = [];
|
||||
_plugins = [];
|
||||
}
|
||||
|
||||
public List<DirectoryInfo> AdditionalPluginDirectories { get; } = new();
|
||||
public List<DirectoryInfo> AdditionalPluginDirectories { get; } = [];
|
||||
|
||||
public bool LoadingPlugins { get; private set; }
|
||||
|
||||
public bool LoadedPlugins { get; private set; }
|
||||
|
||||
public List<PluginInfo> GetAllPluginInfo()
|
||||
{
|
||||
lock (_pluginInfos)
|
||||
{
|
||||
return [.._pluginInfos];
|
||||
}
|
||||
}
|
||||
|
||||
public List<Plugin> GetAllPlugins()
|
||||
{
|
||||
lock (_plugins)
|
||||
{
|
||||
return new List<Plugin>(_plugins);
|
||||
return [.._plugins];
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,6 +274,13 @@ internal class PluginManagementService : IPluginManagementService
|
||||
throw new ArtemisCoreException($"Cannot load plugin {pluginInfo} because it is using a GUID already used by another plugin");
|
||||
}
|
||||
|
||||
// There may be info on a plugin that previously failed to load, remove that
|
||||
lock (_pluginInfos)
|
||||
{
|
||||
_pluginInfos.RemoveAll(i => i.Guid == pluginInfo.Guid);
|
||||
_pluginInfos.Add(pluginInfo);
|
||||
}
|
||||
|
||||
// Load the entity and fall back on creating a new one
|
||||
PluginEntity? entity = _pluginRepository.GetPluginByPluginGuid(pluginInfo.Guid);
|
||||
bool loadedFromStorage = entity != null;
|
||||
@ -301,6 +318,7 @@ internal class PluginManagementService : IPluginManagementService
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
pluginInfo.LoadException = e;
|
||||
throw new ArtemisPluginException(plugin, "Failed to load the plugins assembly", e);
|
||||
}
|
||||
|
||||
@ -312,6 +330,7 @@ internal class PluginManagementService : IPluginManagementService
|
||||
}
|
||||
catch (ReflectionTypeLoadException e)
|
||||
{
|
||||
pluginInfo.LoadException = e;
|
||||
throw new ArtemisPluginException(
|
||||
plugin,
|
||||
"Failed to initialize the plugin assembly",
|
||||
@ -471,6 +490,10 @@ internal class PluginManagementService : IPluginManagementService
|
||||
}
|
||||
|
||||
plugin.Dispose();
|
||||
lock (_pluginInfos)
|
||||
{
|
||||
_pluginInfos.Remove(plugin.Info);
|
||||
}
|
||||
lock (_plugins)
|
||||
{
|
||||
_plugins.Remove(plugin);
|
||||
|
||||
@ -28,7 +28,7 @@ public static partial class ProcessMonitor
|
||||
get
|
||||
{
|
||||
lock (LOCK)
|
||||
return _processes.Values.ToImmutableArray();
|
||||
return [.._processes.Values];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ namespace Artemis.Core.Services;
|
||||
internal class RenderService : IRenderService, IRenderer, IDisposable
|
||||
{
|
||||
private readonly Stopwatch _frameStopWatch;
|
||||
private readonly List<Exception> _updateExceptions = new();
|
||||
private readonly List<Exception> _updateExceptions = [];
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDeviceService _deviceService;
|
||||
|
||||
@ -8,8 +8,8 @@ internal class SurfaceArrangement
|
||||
{
|
||||
public SurfaceArrangement()
|
||||
{
|
||||
Types = new List<SurfaceArrangementType>();
|
||||
ArrangedDevices = new List<ArtemisDevice>();
|
||||
Types = [];
|
||||
ArrangedDevices = [];
|
||||
}
|
||||
|
||||
public List<SurfaceArrangementType> Types { get; }
|
||||
|
||||
@ -12,7 +12,7 @@ internal class SurfaceArrangementType
|
||||
SurfaceArrangement = surfaceArrangement;
|
||||
DeviceType = deviceType;
|
||||
ZIndex = zIndex;
|
||||
Configurations = new List<SurfaceArrangementConfiguration>();
|
||||
Configurations = [];
|
||||
}
|
||||
|
||||
public SurfaceArrangement SurfaceArrangement { get; }
|
||||
|
||||
@ -23,9 +23,9 @@ internal class ProfileService : IProfileService
|
||||
private readonly IProfileRepository _profileRepository;
|
||||
private readonly IPluginManagementService _pluginManagementService;
|
||||
private readonly IDeviceService _deviceService;
|
||||
private readonly List<ArtemisKeyboardKeyEventArgs> _pendingKeyboardEvents = new();
|
||||
private readonly List<Exception> _renderExceptions = new();
|
||||
private readonly List<Exception> _updateExceptions = new();
|
||||
private readonly List<ArtemisKeyboardKeyEventArgs> _pendingKeyboardEvents = [];
|
||||
private readonly List<Exception> _renderExceptions = [];
|
||||
private readonly List<Exception> _updateExceptions = [];
|
||||
|
||||
private DateTime _lastRenderExceptionLog;
|
||||
private DateTime _lastUpdateExceptionLog;
|
||||
|
||||
@ -55,7 +55,7 @@ public abstract class PluginEndPoint
|
||||
public FlexibleContentType Returns { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Occurs whenever a request threw an unhandled exception
|
||||
/// Occurs whenever a request threw an Unhandled error
|
||||
/// </summary>
|
||||
public event EventHandler<EndpointExceptionEventArgs>? RequestException;
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ internal class WebServerService : IWebServerService, IDisposable
|
||||
{
|
||||
_logger = logger;
|
||||
_coreService = coreService;
|
||||
_controllers = new List<WebApiControllerRegistration>();
|
||||
_controllers = [];
|
||||
|
||||
_webServerEnabledSetting = settingsService.GetSetting("WebServer.Enabled", true);
|
||||
_webServerRemoteAccessSetting = settingsService.GetSetting("WebServer.RemoteAccess", false);
|
||||
|
||||
@ -7,7 +7,7 @@ namespace Artemis.Core;
|
||||
|
||||
internal class DataModelStore
|
||||
{
|
||||
private static readonly List<DataModelRegistration> Registrations = new();
|
||||
private static readonly List<DataModelRegistration> Registrations = [];
|
||||
|
||||
public static DataModelRegistration Add(DataModel dataModel)
|
||||
{
|
||||
@ -43,7 +43,7 @@ internal class DataModelStore
|
||||
{
|
||||
lock (Registrations)
|
||||
{
|
||||
return new List<DataModelRegistration>(Registrations);
|
||||
return [..Registrations];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ namespace Artemis.Core;
|
||||
|
||||
internal class LayerBrushStore
|
||||
{
|
||||
private static readonly List<LayerBrushRegistration> Registrations = new();
|
||||
private static readonly List<LayerBrushRegistration> Registrations = [];
|
||||
|
||||
public static LayerBrushRegistration Add(LayerBrushDescriptor descriptor)
|
||||
{
|
||||
@ -43,7 +43,7 @@ internal class LayerBrushStore
|
||||
{
|
||||
lock (Registrations)
|
||||
{
|
||||
return new List<LayerBrushRegistration>(Registrations);
|
||||
return [..Registrations];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ namespace Artemis.Core;
|
||||
|
||||
internal class LayerEffectStore
|
||||
{
|
||||
private static readonly List<LayerEffectRegistration> Registrations = new();
|
||||
private static readonly List<LayerEffectRegistration> Registrations = [];
|
||||
|
||||
public static LayerEffectRegistration Add(LayerEffectDescriptor descriptor)
|
||||
{
|
||||
@ -43,7 +43,7 @@ internal class LayerEffectStore
|
||||
{
|
||||
lock (Registrations)
|
||||
{
|
||||
return new List<LayerEffectRegistration>(Registrations);
|
||||
return [..Registrations];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ public static class LogStore
|
||||
{
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static readonly LinkedList<LogEvent> LinkedList = new();
|
||||
private static readonly LinkedList<LogEvent> LinkedList = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list containing the last 500 log events.
|
||||
|
||||
@ -8,8 +8,8 @@ namespace Artemis.Core;
|
||||
|
||||
internal class NodeTypeStore
|
||||
{
|
||||
private static readonly List<NodeTypeRegistration> Registrations = new();
|
||||
private static readonly List<TypeColorRegistration> ColorRegistrations = new();
|
||||
private static readonly List<NodeTypeRegistration> Registrations = [];
|
||||
private static readonly List<TypeColorRegistration> ColorRegistrations = [];
|
||||
|
||||
public static NodeTypeRegistration Add(NodeData nodeData)
|
||||
{
|
||||
@ -85,7 +85,7 @@ internal class NodeTypeStore
|
||||
{
|
||||
lock (ColorRegistrations)
|
||||
{
|
||||
return new List<TypeColorRegistration>(ColorRegistrations);
|
||||
return [..ColorRegistrations];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ public static class NodeExtension
|
||||
/// <returns><see langword="true" /> if there would be a loop; otherwise <see langword="false" />.</returns>
|
||||
public static bool IsInLoop(this INode node, INode pendingConnection)
|
||||
{
|
||||
HashSet<INode> checkedNodes = new();
|
||||
HashSet<INode> checkedNodes = [];
|
||||
|
||||
bool CheckNode(INode checkNode, INode? pending)
|
||||
{
|
||||
|
||||
@ -46,7 +46,7 @@ public abstract class NodeScript : CorePropertyChanged, INodeScript
|
||||
/// <inheritdoc />
|
||||
public string Description { get; }
|
||||
|
||||
private readonly List<INode> _nodes = new();
|
||||
private readonly List<INode> _nodes = [];
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<INode> Nodes => new ReadOnlyCollection<INode>(_nodes);
|
||||
|
||||
@ -28,8 +28,8 @@ public abstract class Node : BreakableModel, INode
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
private readonly List<OutputPin> _outputPinBucket = new();
|
||||
private readonly List<InputPin> _inputPinBucket = new();
|
||||
private readonly List<OutputPin> _outputPinBucket = [];
|
||||
private readonly List<InputPin> _inputPinBucket = [];
|
||||
|
||||
private Guid _id;
|
||||
|
||||
@ -95,12 +95,12 @@ public abstract class Node : BreakableModel, INode
|
||||
/// <inheritdoc />
|
||||
public bool IsLoading { get; set; }
|
||||
|
||||
private readonly List<IPin> _pins = new();
|
||||
private readonly List<IPin> _pins = [];
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<IPin> Pins => new ReadOnlyCollection<IPin>(_pins);
|
||||
|
||||
private readonly List<IPinCollection> _pinCollections = new();
|
||||
private readonly List<IPinCollection> _pinCollections = [];
|
||||
private string _helpUrl;
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -27,7 +27,7 @@ public abstract class Node<TStorage, TViewModel> : Node<TStorage>, ICustomViewMo
|
||||
{
|
||||
if (NodeData == null)
|
||||
throw new ArtemisCoreException("Nodes without node data (default nodes or exit nodes) cannot have custom view models");
|
||||
return NodeData.Provider.Plugin.Container.Resolve<TViewModel>(args: new object[] {this, nodeScript});
|
||||
return NodeData.Provider.Plugin.Container.Resolve<TViewModel>(args: [this, nodeScript]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -60,7 +60,7 @@ public abstract class Pin : CorePropertyChanged, IPin
|
||||
protected set => SetAndNotify(ref _isNumeric, value);
|
||||
}
|
||||
|
||||
private readonly List<IPin> _connectedTo = new();
|
||||
private readonly List<IPin> _connectedTo = [];
|
||||
private string _name;
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -45,7 +45,7 @@ public abstract class PinCollection : CorePropertyChanged, IPinCollection
|
||||
/// <inheritdoc />
|
||||
public abstract Type Type { get; }
|
||||
|
||||
private readonly List<IPin> _pins = new();
|
||||
private readonly List<IPin> _pins = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets a read only observable collection of the pins
|
||||
|
||||
@ -7,7 +7,7 @@ internal class PluginEntity
|
||||
{
|
||||
public PluginEntity()
|
||||
{
|
||||
Features = new List<PluginFeatureEntity>();
|
||||
Features = [];
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
|
||||
@ -7,7 +7,7 @@ internal abstract class RenderElementEntity
|
||||
public Guid Id { get; set; }
|
||||
public Guid ParentId { get; set; }
|
||||
|
||||
public List<LayerEffectEntity> LayerEffects { get; set; } = new();
|
||||
public List<LayerEffectEntity> LayerEffects { get; set; } = [];
|
||||
|
||||
public IConditionEntity? DisplayCondition { get; set; }
|
||||
public TimelineEntity? Timeline { get; set; }
|
||||
|
||||
@ -8,8 +8,8 @@ internal class LayerEntity : RenderElementEntity
|
||||
{
|
||||
public LayerEntity()
|
||||
{
|
||||
Leds = new List<LedEntity>();
|
||||
AdaptionHints = new List<IAdaptionHintEntity>();
|
||||
Leds = [];
|
||||
AdaptionHints = [];
|
||||
}
|
||||
|
||||
public int Order { get; set; }
|
||||
|
||||
@ -4,7 +4,7 @@ internal class NodeEntity
|
||||
{
|
||||
public NodeEntity()
|
||||
{
|
||||
PinCollections = new List<NodePinCollectionEntity>();
|
||||
PinCollections = [];
|
||||
}
|
||||
|
||||
public NodeEntity(NodeEntity nodeEntity)
|
||||
|
||||
@ -4,8 +4,8 @@ internal class NodeScriptEntity
|
||||
{
|
||||
public NodeScriptEntity()
|
||||
{
|
||||
Nodes = new List<NodeEntity>();
|
||||
Connections = new List<NodeConnectionEntity>();
|
||||
Nodes = [];
|
||||
Connections = [];
|
||||
}
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
@ -14,7 +14,7 @@ internal class ProfileCategoryEntity
|
||||
public bool IsSuspended { get; set; }
|
||||
public int Order { get; set; }
|
||||
|
||||
public List<ProfileConfigurationEntity> ProfileConfigurations { get; set; } = new();
|
||||
public List<ProfileConfigurationEntity> ProfileConfigurations { get; set; } = [];
|
||||
|
||||
public Storage.Entities.Profile.ProfileCategoryEntity Migrate(ILogger logger, List<ProfileEntity> legacyProfiles, ILiteStorage<Guid> profileIcons)
|
||||
{
|
||||
|
||||
@ -6,9 +6,9 @@ internal class ProfileEntity
|
||||
{
|
||||
public ProfileEntity()
|
||||
{
|
||||
Folders = new List<FolderEntity>();
|
||||
Layers = new List<LayerEntity>();
|
||||
ScriptConfigurations = new List<ScriptConfigurationEntity>();
|
||||
Folders = [];
|
||||
Layers = [];
|
||||
ScriptConfigurations = [];
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
|
||||
@ -9,5 +9,5 @@ internal class PropertyEntity
|
||||
public bool KeyframesEnabled { get; set; }
|
||||
|
||||
public DataBindingEntity? DataBinding { get; set; }
|
||||
public List<KeyframeEntity> KeyframeEntities { get; set; } = new();
|
||||
public List<KeyframeEntity> KeyframeEntities { get; set; } = [];
|
||||
}
|
||||
@ -3,6 +3,6 @@
|
||||
internal class PropertyGroupEntity
|
||||
{
|
||||
public string Identifier { get; set; } = string.Empty;
|
||||
public List<PropertyEntity> Properties { get; set; } = new();
|
||||
public List<PropertyGroupEntity> PropertyGroups { get; set; } = new();
|
||||
public List<PropertyEntity> Properties { get; set; } = [];
|
||||
public List<PropertyGroupEntity> PropertyGroups { get; set; } = [];
|
||||
}
|
||||
@ -4,9 +4,9 @@ internal class DeviceEntity
|
||||
{
|
||||
public DeviceEntity()
|
||||
{
|
||||
InputIdentifiers = new List<DeviceInputIdentifierEntity>();
|
||||
InputMappings = new List<InputMappingEntity>();
|
||||
Categories = new List<int>();
|
||||
InputIdentifiers = [];
|
||||
InputMappings = [];
|
||||
Categories = [];
|
||||
}
|
||||
|
||||
public string Id { get; set; } = string.Empty;
|
||||
|
||||
@ -9,7 +9,7 @@ internal class M0023LayoutProviders : IStorageMigration
|
||||
public void Apply(LiteRepository repository)
|
||||
{
|
||||
ILiteCollection<BsonDocument> deviceEntities = repository.Database.GetCollection("DeviceEntity");
|
||||
List<BsonDocument> toUpdate = new();
|
||||
List<BsonDocument> toUpdate = [];
|
||||
|
||||
foreach (BsonDocument bsonDocument in deviceEntities.FindAll())
|
||||
{
|
||||
|
||||
@ -9,7 +9,7 @@ internal class M0024NodeProviders : IStorageMigration
|
||||
public void Apply(LiteRepository repository)
|
||||
{
|
||||
ILiteCollection<BsonDocument> categoryCollection = repository.Database.GetCollection("ProfileCategoryEntity");
|
||||
List<BsonDocument> categoriesToUpdate = new();
|
||||
List<BsonDocument> categoriesToUpdate = [];
|
||||
foreach (BsonDocument profileCategoryBson in categoryCollection.FindAll())
|
||||
{
|
||||
BsonArray? profiles = profileCategoryBson["ProfileConfigurations"]?.AsArray;
|
||||
@ -24,7 +24,7 @@ internal class M0024NodeProviders : IStorageMigration
|
||||
categoryCollection.Update(categoriesToUpdate);
|
||||
|
||||
ILiteCollection<BsonDocument> collection = repository.Database.GetCollection("ProfileEntity");
|
||||
List<BsonDocument> profilesToUpdate = new();
|
||||
List<BsonDocument> profilesToUpdate = [];
|
||||
foreach (BsonDocument profileBson in collection.FindAll())
|
||||
{
|
||||
BsonArray? folders = profileBson["Folders"]?.AsArray;
|
||||
|
||||
@ -9,7 +9,7 @@ internal class M0025NodeProvidersProfileConfig : IStorageMigration
|
||||
public void Apply(LiteRepository repository)
|
||||
{
|
||||
ILiteCollection<BsonDocument> categoryCollection = repository.Database.GetCollection("ProfileCategoryEntity");
|
||||
List<BsonDocument> toUpdate = new();
|
||||
List<BsonDocument> toUpdate = [];
|
||||
foreach (BsonDocument profileCategoryBson in categoryCollection.FindAll())
|
||||
{
|
||||
BsonArray? profiles = profileCategoryBson["ProfileConfigurations"]?.AsArray;
|
||||
|
||||
@ -19,7 +19,7 @@ internal class M0026NodeStorage : IStorageMigration
|
||||
public void Apply(LiteRepository repository)
|
||||
{
|
||||
ILiteCollection<BsonDocument> categoryCollection = repository.Database.GetCollection("ProfileCategoryEntity");
|
||||
List<BsonDocument> toUpdate = new();
|
||||
List<BsonDocument> toUpdate = [];
|
||||
foreach (BsonDocument profileCategoryBson in categoryCollection.FindAll())
|
||||
{
|
||||
BsonArray? profiles = profileCategoryBson["ProfileConfigurations"]?.AsArray;
|
||||
@ -38,7 +38,7 @@ internal class M0026NodeStorage : IStorageMigration
|
||||
categoryCollection.Update(toUpdate);
|
||||
|
||||
ILiteCollection<BsonDocument> collection = repository.Database.GetCollection("ProfileEntity");
|
||||
List<BsonDocument> profilesToUpdate = new();
|
||||
List<BsonDocument> profilesToUpdate = [];
|
||||
foreach (BsonDocument profileBson in collection.FindAll())
|
||||
{
|
||||
BsonArray? folders = profileBson["Folders"]?.AsArray;
|
||||
|
||||
@ -9,7 +9,7 @@ internal class M0027Namespace : IStorageMigration
|
||||
public void Apply(LiteRepository repository)
|
||||
{
|
||||
ILiteCollection<BsonDocument> collection = repository.Database.GetCollection("ProfileEntity");
|
||||
List<BsonDocument> profilesToUpdate = new();
|
||||
List<BsonDocument> profilesToUpdate = [];
|
||||
|
||||
foreach (BsonDocument profileBson in collection.FindAll())
|
||||
{
|
||||
|
||||
@ -12,7 +12,7 @@ public class PluginEntity
|
||||
{
|
||||
public PluginEntity()
|
||||
{
|
||||
Features = new List<PluginFeatureEntity>();
|
||||
Features = [];
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
|
||||
@ -8,7 +8,7 @@ public abstract class RenderElementEntity
|
||||
public Guid Id { get; set; }
|
||||
public Guid ParentId { get; set; }
|
||||
|
||||
public List<LayerEffectEntity> LayerEffects { get; set; } = new();
|
||||
public List<LayerEffectEntity> LayerEffects { get; set; } = [];
|
||||
|
||||
public IConditionEntity? DisplayCondition { get; set; }
|
||||
public TimelineEntity? Timeline { get; set; }
|
||||
|
||||
@ -8,8 +8,8 @@ public class LayerEntity : RenderElementEntity
|
||||
{
|
||||
public LayerEntity()
|
||||
{
|
||||
Leds = new List<LedEntity>();
|
||||
AdaptionHints = new List<IAdaptionHintEntity>();
|
||||
Leds = [];
|
||||
AdaptionHints = [];
|
||||
}
|
||||
|
||||
public int Order { get; set; }
|
||||
|
||||
@ -8,7 +8,7 @@ public class NodeEntity
|
||||
{
|
||||
public NodeEntity()
|
||||
{
|
||||
PinCollections = new List<NodePinCollectionEntity>();
|
||||
PinCollections = [];
|
||||
}
|
||||
|
||||
public NodeEntity(NodeEntity nodeEntity)
|
||||
|
||||
@ -6,8 +6,8 @@ public class NodeScriptEntity
|
||||
{
|
||||
public NodeScriptEntity()
|
||||
{
|
||||
Nodes = new List<NodeEntity>();
|
||||
Connections = new List<NodeConnectionEntity>();
|
||||
Nodes = [];
|
||||
Connections = [];
|
||||
}
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
@ -16,5 +16,5 @@ public class ProfileCategoryEntity
|
||||
public bool IsSuspended { get; set; }
|
||||
public int Order { get; set; }
|
||||
|
||||
public List<ProfileContainerEntity> ProfileConfigurations { get; set; } = new();
|
||||
public List<ProfileContainerEntity> ProfileConfigurations { get; set; } = [];
|
||||
}
|
||||
@ -5,7 +5,7 @@ namespace Artemis.Storage.Entities.Profile;
|
||||
public class ProfileContainerEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public byte[] Icon { get; set; } = Array.Empty<byte>();
|
||||
public byte[] Icon { get; set; } = [];
|
||||
|
||||
public ProfileCategoryEntity ProfileCategory { get; set; } = null!;
|
||||
|
||||
|
||||
@ -8,8 +8,8 @@ public class ProfileEntity
|
||||
{
|
||||
public ProfileEntity()
|
||||
{
|
||||
Folders = new List<FolderEntity>();
|
||||
Layers = new List<LayerEntity>();
|
||||
Folders = [];
|
||||
Layers = [];
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
|
||||
@ -10,5 +10,5 @@ public class PropertyEntity
|
||||
public bool KeyframesEnabled { get; set; }
|
||||
|
||||
public DataBindingEntity? DataBinding { get; set; }
|
||||
public List<KeyframeEntity> KeyframeEntities { get; set; } = new();
|
||||
public List<KeyframeEntity> KeyframeEntities { get; set; } = [];
|
||||
}
|
||||
@ -5,6 +5,6 @@ namespace Artemis.Storage.Entities.Profile;
|
||||
public class PropertyGroupEntity
|
||||
{
|
||||
public string Identifier { get; set; } = string.Empty;
|
||||
public List<PropertyEntity> Properties { get; set; } = new();
|
||||
public List<PropertyGroupEntity> PropertyGroups { get; set; } = new();
|
||||
public List<PropertyEntity> Properties { get; set; } = [];
|
||||
public List<PropertyGroupEntity> PropertyGroups { get; set; } = [];
|
||||
}
|
||||
@ -7,9 +7,9 @@ public class DeviceEntity
|
||||
{
|
||||
public DeviceEntity()
|
||||
{
|
||||
InputIdentifiers = new List<DeviceInputIdentifierEntity>();
|
||||
InputMappings = new List<InputMappingEntity>();
|
||||
Categories = new List<int>();
|
||||
InputIdentifiers = [];
|
||||
InputMappings = [];
|
||||
Categories = [];
|
||||
}
|
||||
|
||||
[MaxLength(512)]
|
||||
|
||||
@ -34,7 +34,7 @@ public class App : Application
|
||||
if (ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop || Design.IsDesignMode)
|
||||
return;
|
||||
|
||||
_applicationStateManager = new ApplicationStateManager(_container!, desktop.Args ?? Array.Empty<string>());
|
||||
_applicationStateManager = new ApplicationStateManager(_container!, desktop.Args ?? []);
|
||||
ArtemisBootstrapper.Initialize();
|
||||
RegisterProviders();
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public class ApplicationStateManager
|
||||
{
|
||||
try
|
||||
{
|
||||
_windowService.ShowExceptionDialog("An unhandled exception occured", e);
|
||||
_windowService.ShowExceptionDialog("An unhandled error occured", e);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -112,7 +112,7 @@ public class ApplicationStateManager
|
||||
|
||||
private void UtilitiesOnRestartRequested(object? sender, RestartEventArgs e)
|
||||
{
|
||||
List<string> argsList = new();
|
||||
List<string> argsList = [];
|
||||
argsList.AddRange(StartupArguments);
|
||||
if (e.ExtraArgs != null)
|
||||
argsList.AddRange(e.ExtraArgs.Except(argsList));
|
||||
|
||||
@ -17,7 +17,7 @@ public class LinuxInputProvider : InputProvider
|
||||
{
|
||||
_logger = logger;
|
||||
_inputService = inputService;
|
||||
_readers = new List<LinuxInputDeviceReader>();
|
||||
_readers = [];
|
||||
|
||||
foreach (LinuxInputDevice deviceDefinition in LinuxInputDeviceFinder.Find())
|
||||
{
|
||||
|
||||
@ -47,7 +47,7 @@ public class DataModelPicker : TemplatedControl
|
||||
/// A list of extra modules to show data models of.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<ObservableCollection<Module>?> ModulesProperty =
|
||||
AvaloniaProperty.Register<DataModelPicker, ObservableCollection<Module>?>(nameof(Modules), new ObservableCollection<Module>());
|
||||
AvaloniaProperty.Register<DataModelPicker, ObservableCollection<Module>?>(nameof(Modules), []);
|
||||
|
||||
/// <summary>
|
||||
/// The data model view model to show, if not provided one will be retrieved by the control.
|
||||
@ -59,7 +59,7 @@ public class DataModelPicker : TemplatedControl
|
||||
/// A list of types to filter the selectable paths on.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<ObservableCollection<Type>?> FilterTypesProperty =
|
||||
AvaloniaProperty.Register<DataModelPicker, ObservableCollection<Type>?>(nameof(FilterTypes), new ObservableCollection<Type>());
|
||||
AvaloniaProperty.Register<DataModelPicker, ObservableCollection<Type>?>(nameof(FilterTypes), []);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether the picker is in event picker mode.
|
||||
@ -222,7 +222,7 @@ public class DataModelPicker : TemplatedControl
|
||||
if (DataModelUIService == null)
|
||||
return;
|
||||
|
||||
ChangeDataModel(DataModelUIService.GetPluginDataModelVisualization(Modules?.ToList() ?? new List<Module>(), true));
|
||||
ChangeDataModel(DataModelUIService.GetPluginDataModelVisualization(Modules?.ToList() ?? [], true));
|
||||
}
|
||||
|
||||
private void ChangeDataModel(DataModelPropertiesViewModel? dataModel)
|
||||
|
||||
@ -65,13 +65,13 @@ public class DataModelPickerButton : TemplatedControl
|
||||
/// A list of extra modules to show data models of.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<ObservableCollection<Module>?> ModulesProperty =
|
||||
AvaloniaProperty.Register<DataModelPicker, ObservableCollection<Module>?>(nameof(Modules), new ObservableCollection<Module>());
|
||||
AvaloniaProperty.Register<DataModelPicker, ObservableCollection<Module>?>(nameof(Modules), []);
|
||||
|
||||
/// <summary>
|
||||
/// A list of types to filter the selectable paths on.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<ObservableCollection<Type>?> FilterTypesProperty =
|
||||
AvaloniaProperty.Register<DataModelPicker, ObservableCollection<Type>?>(nameof(FilterTypes), new ObservableCollection<Type>());
|
||||
AvaloniaProperty.Register<DataModelPicker, ObservableCollection<Type>?>(nameof(FilterTypes), []);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether the picker is in event picker mode.
|
||||
|
||||
@ -34,13 +34,13 @@ public class DeviceVisualizer : Control
|
||||
private RenderTargetBitmap? _deviceImage;
|
||||
private ArtemisDevice? _oldDevice;
|
||||
private bool _loading;
|
||||
private Color[] _previousState = Array.Empty<Color>();
|
||||
private Color[] _previousState = [];
|
||||
|
||||
/// <inheritdoc />
|
||||
public DeviceVisualizer()
|
||||
{
|
||||
_renderService = UI.Locator.Resolve<IRenderService>();
|
||||
_deviceVisualizerLeds = new List<DeviceVisualizerLed>();
|
||||
_deviceVisualizerLeds = [];
|
||||
|
||||
PointerReleased += OnPointerReleased;
|
||||
PropertyChanged += OnPropertyChanged;
|
||||
|
||||
@ -105,11 +105,11 @@ internal class DeviceVisualizerLed
|
||||
Geometry geometry = Geometry.Parse(Led.RgbLed.ShapeData);
|
||||
geometry.Transform = new TransformGroup
|
||||
{
|
||||
Children = new Transforms
|
||||
{
|
||||
Children =
|
||||
[
|
||||
new ScaleTransform(width, height),
|
||||
new TranslateTransform(Led.RgbLed.Location.X + deflateAmount / 2, Led.RgbLed.Location.Y + deflateAmount / 2)
|
||||
}
|
||||
]
|
||||
};
|
||||
DisplayGeometry = geometry;
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ public partial class EnumComboBox : UserControl
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<object?> ValueProperty = AvaloniaProperty.Register<EnumComboBox, object?>(nameof(Value), defaultBindingMode: BindingMode.TwoWay);
|
||||
|
||||
private readonly ObservableCollection<EnumComboBoxItem> _currentValues = new();
|
||||
private readonly ObservableCollection<EnumComboBoxItem> _currentValues = [];
|
||||
private Type? _currentType;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -269,7 +269,7 @@ public class GradientPicker : TemplatedControl
|
||||
private void UpdateGradient()
|
||||
{
|
||||
// Update the display gradient
|
||||
GradientStops collection = new();
|
||||
GradientStops collection = [];
|
||||
foreach (ColorGradientStop c in EditingColorGradient.OrderBy(s => s.Position))
|
||||
collection.Add(new GradientStop(Color.FromArgb(c.Color.Alpha, c.Color.Red, c.Color.Green, c.Color.Blue), c.Position));
|
||||
|
||||
|
||||
@ -169,7 +169,7 @@ public class GradientPickerButton : TemplatedControl
|
||||
private void UpdateGradient()
|
||||
{
|
||||
// Update the display gradient
|
||||
GradientStops collection = new();
|
||||
GradientStops collection = [];
|
||||
if (ColorGradient != null)
|
||||
foreach (ColorGradientStop c in ColorGradient.OrderBy(s => s.Position))
|
||||
collection.Add(new GradientStop(Color.FromArgb(c.Color.Alpha, c.Color.Red, c.Color.Green, c.Color.Blue), c.Position));
|
||||
|
||||
@ -10,7 +10,7 @@ public partial class TagsInput : TemplatedControl
|
||||
/// Defines the <see cref="Tags" /> property
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<ObservableCollection<string>> TagsProperty =
|
||||
AvaloniaProperty.Register<TagsInput, ObservableCollection<string>>(nameof(Tags), new ObservableCollection<string>());
|
||||
AvaloniaProperty.Register<TagsInput, ObservableCollection<string>>(nameof(Tags), []);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the selected tags.
|
||||
|
||||
@ -17,7 +17,7 @@ public class ColorGradientToGradientStopsConverter : IValueConverter
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
ColorGradient? colorGradient = value as ColorGradient;
|
||||
GradientStops collection = new();
|
||||
GradientStops collection = [];
|
||||
if (colorGradient == null)
|
||||
return collection;
|
||||
|
||||
@ -30,7 +30,7 @@ public class ColorGradientToGradientStopsConverter : IValueConverter
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
GradientStops? collection = value as GradientStops;
|
||||
ColorGradient colorGradients = new();
|
||||
ColorGradient colorGradients = [];
|
||||
if (collection == null)
|
||||
return colorGradients;
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ public class DataModelListViewModel : DataModelVisualizationViewModel
|
||||
: base(dataModel, parent, dataModelPath)
|
||||
{
|
||||
_countDisplay = "0 items";
|
||||
_listChildren = new ObservableCollection<DataModelVisualizationViewModel>();
|
||||
_listChildren = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -29,7 +29,7 @@ public abstract class DataModelVisualizationViewModel : ReactiveObject, IDisposa
|
||||
internal DataModelVisualizationViewModel(DataModel? dataModel, DataModelVisualizationViewModel? parent, DataModelPath? dataModelPath)
|
||||
{
|
||||
_dataModel = dataModel;
|
||||
_children = new ObservableCollection<DataModelVisualizationViewModel>();
|
||||
_children = [];
|
||||
_parent = parent;
|
||||
DataModelPath = dataModelPath;
|
||||
IsMatchingFilteredTypes = true;
|
||||
|
||||
@ -18,7 +18,7 @@ public static class ContainerExtensions
|
||||
{
|
||||
container.Register<IRouter, Router>(Reuse.Singleton);
|
||||
Assembly artemisShared = typeof(IArtemisSharedUIService).GetAssembly();
|
||||
container.RegisterMany(new[] {artemisShared}, type => type.IsAssignableTo<IArtemisSharedUIService>(), Reuse.Singleton);
|
||||
container.RegisterMany([artemisShared], type => type.IsAssignableTo<IArtemisSharedUIService>(), Reuse.Singleton);
|
||||
|
||||
UI.Locator = container;
|
||||
}
|
||||
|
||||
@ -125,11 +125,11 @@ public static class ArtemisLayoutExtensions
|
||||
Geometry geometry = Geometry.Parse(led.RgbLayout.ShapeData);
|
||||
geometry.Transform = new TransformGroup
|
||||
{
|
||||
Children = new Transforms
|
||||
{
|
||||
Children =
|
||||
[
|
||||
new ScaleTransform(width, height),
|
||||
new TranslateTransform(led.RgbLayout.X + deflateAmount / 2, led.RgbLayout.Y + deflateAmount / 2)
|
||||
}
|
||||
]
|
||||
};
|
||||
return geometry;
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ public static class VisualExtensions
|
||||
/// <returns>A recursive list of all visual children of type <typeparamref name="T" />.</returns>
|
||||
public static List<T> GetVisualChildrenOfType<T>(this Visual root)
|
||||
{
|
||||
List<T> result = new();
|
||||
List<T> result = [];
|
||||
|
||||
List<Visual>? visualChildren = root.GetVisualChildren()?.ToList();
|
||||
if (visualChildren == null || !visualChildren.Any())
|
||||
@ -43,7 +43,7 @@ public static class VisualExtensions
|
||||
/// <returns>A recursive list of all visual children with a data context of type <typeparamref name="T" />.</returns>
|
||||
public static List<T> GetVisualChildrenOfDataContextType<T>(this Visual root)
|
||||
{
|
||||
List<T> result = new();
|
||||
List<T> result = [];
|
||||
|
||||
List<Visual>? visualChildren = root.GetVisualChildren()?.ToList();
|
||||
if (visualChildren == null || !visualChildren.Any())
|
||||
|
||||
@ -49,7 +49,7 @@ public class ReactiveAppWindow<TViewModel> : AppWindow, IViewFor<TViewModel> whe
|
||||
return;
|
||||
|
||||
// TransparencyBackgroundFallback = Brushes.Transparent;
|
||||
TransparencyLevelHint = new[] {WindowTransparencyLevel.Mica};
|
||||
TransparencyLevelHint = [WindowTransparencyLevel.Mica];
|
||||
Background = new SolidColorBrush(new Color(80, 0,0,0));
|
||||
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ public abstract class RoutableScreen<TParam> : RoutableScreen, IRoutableScreen w
|
||||
|
||||
Expression<Func<object[], TParam>> lambda = Expression.Lambda<Func<object[], TParam>>(
|
||||
Expression.Block(
|
||||
new[] {parameterExpression},
|
||||
[parameterExpression],
|
||||
Expression.Assign(parameterExpression, Expression.New(parameterType)),
|
||||
Expression.Block(propertyAssignments),
|
||||
parameterExpression
|
||||
|
||||
@ -44,5 +44,5 @@ public class RouteRegistration<TViewModel> : IRouterRegistration where TViewMode
|
||||
public Type ViewModel => typeof(TViewModel);
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<IRouterRegistration> Children { get; set; } = new();
|
||||
public List<IRouterRegistration> Children { get; set; } = [];
|
||||
}
|
||||
@ -25,7 +25,7 @@ internal class RouteResolution
|
||||
return AsFailure(path);
|
||||
|
||||
// Ensure self is a match
|
||||
List<object> parameters = new();
|
||||
List<object> parameters = [];
|
||||
int currentSegment = 0;
|
||||
foreach (RouteSegment routeSegment in registration.Route.Segments)
|
||||
{
|
||||
@ -95,7 +95,7 @@ internal class RouteResolution
|
||||
|
||||
public object[] GetAllParameters()
|
||||
{
|
||||
List<object> result = new();
|
||||
List<object> result = [];
|
||||
if (Parameters != null)
|
||||
result.AddRange(Parameters);
|
||||
object[]? childParameters = Child?.GetAllParameters();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user