diff --git a/src/Artemis.Core/Constants.cs b/src/Artemis.Core/Constants.cs
index 69208acb3..15f337748 100644
--- a/src/Artemis.Core/Constants.cs
+++ b/src/Artemis.Core/Constants.cs
@@ -8,142 +8,148 @@ using Artemis.Core.Services.Core;
using Artemis.Core.SkiaSharp;
using Newtonsoft.Json;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// A few useful constant values
+///
+public static class Constants
{
///
- /// A few useful constant values
+ /// The Artemis.Core assembly
///
- public static class Constants
+ public static readonly Assembly CoreAssembly = typeof(Constants).Assembly;
+
+ ///
+ /// The full path to the Artemis application folder
+ ///
+ public static readonly string ApplicationFolder = Path.GetDirectoryName(typeof(Constants).Assembly.Location)!;
+
+ ///
+ /// The full path to the Artemis executable
+ ///
+ public static readonly string ExecutablePath = Utilities.GetCurrentLocation();
+
+ ///
+ /// The base path for Artemis application data folder
+ ///
+ public static readonly string BaseFolder = Environment.GetFolderPath(OperatingSystem.IsWindows()
+ ? Environment.SpecialFolder.CommonApplicationData
+ : Environment.SpecialFolder.LocalApplicationData);
+
+ ///
+ /// The full path to the Artemis data folder
+ ///
+ public static readonly string DataFolder = Path.Combine(BaseFolder, "Artemis");
+
+ ///
+ /// The full path to the Artemis logs folder
+ ///
+ public static readonly string LogsFolder = Path.Combine(DataFolder, "Logs");
+
+ ///
+ /// The full path to the Artemis plugins folder
+ ///
+ public static readonly string PluginsFolder = Path.Combine(DataFolder, "Plugins");
+
+ ///
+ /// The full path to the Artemis user layouts folder
+ ///
+ public static readonly string LayoutsFolder = Path.Combine(DataFolder, "User Layouts");
+
+ ///
+ /// The current API version for plugins
+ ///
+ public static readonly Version PluginApi = new(1, 0);
+
+ ///
+ /// The plugin info used by core components of Artemis
+ ///
+ public static readonly PluginInfo CorePluginInfo = new()
{
- ///
- /// The Artemis.Core assembly
- ///
- public static readonly Assembly CoreAssembly = typeof(Constants).Assembly;
+ Guid = Guid.Parse("ffffffff-ffff-ffff-ffff-ffffffffffff"), Name = "Artemis Core", Version = new Version(2, 0)
+ };
- ///
- /// The full path to the Artemis application folder
- ///
- public static readonly string ApplicationFolder = Path.GetDirectoryName(typeof(Constants).Assembly.Location)!;
-
- ///
- /// The full path to the Artemis executable
- ///
- public static readonly string ExecutablePath = Utilities.GetCurrentLocation();
-
- ///
- /// The base path for Artemis application data folder
- ///
- public static readonly string BaseFolder = Environment.GetFolderPath(OperatingSystem.IsWindows() ? Environment.SpecialFolder.CommonApplicationData : Environment.SpecialFolder.LocalApplicationData);
-
- ///
- /// The full path to the Artemis data folder
- ///
- public static readonly string DataFolder = Path.Combine(BaseFolder, "Artemis");
-
- ///
- /// The full path to the Artemis logs folder
- ///
- public static readonly string LogsFolder = Path.Combine(DataFolder, "Logs");
-
- ///
- /// The full path to the Artemis plugins folder
- ///
- public static readonly string PluginsFolder = Path.Combine(DataFolder, "Plugins");
-
- ///
- /// The full path to the Artemis user layouts folder
- ///
- public static readonly string LayoutsFolder = Path.Combine(DataFolder, "User Layouts");
-
- ///
- /// The plugin info used by core components of Artemis
- ///
- public static readonly PluginInfo CorePluginInfo = new()
+ ///
+ /// The build information related to the currently running Artemis build
+ /// Information is retrieved from buildinfo.json
+ ///
+ public static readonly BuildInfo BuildInfo = File.Exists(Path.Combine(ApplicationFolder, "buildinfo.json"))
+ ? JsonConvert.DeserializeObject(File.ReadAllText(Path.Combine(ApplicationFolder, "buildinfo.json")))!
+ : new BuildInfo
{
- Guid = Guid.Parse("ffffffff-ffff-ffff-ffff-ffffffffffff"), Name = "Artemis Core", Version = new Version(2, 0)
+ IsLocalBuild = true,
+ BuildId = 1337,
+ BuildNumber = 1337,
+ SourceBranch = "local",
+ SourceVersion = "local"
};
- ///
- /// The build information related to the currently running Artemis build
- /// Information is retrieved from buildinfo.json
- ///
- public static readonly BuildInfo BuildInfo = File.Exists(Path.Combine(ApplicationFolder, "buildinfo.json"))
- ? JsonConvert.DeserializeObject(File.ReadAllText(Path.Combine(ApplicationFolder, "buildinfo.json")))!
- : new BuildInfo
- {
- IsLocalBuild = true,
- BuildId = 1337,
- BuildNumber = 1337,
- SourceBranch = "local",
- SourceVersion = "local"
- };
+ ///
+ /// The plugin used by core components of Artemis
+ ///
+ public static readonly Plugin CorePlugin = new(CorePluginInfo, new DirectoryInfo(ApplicationFolder), null);
- ///
- /// The plugin used by core components of Artemis
- ///
- public static readonly Plugin CorePlugin = new(CorePluginInfo, new DirectoryInfo(ApplicationFolder), null);
+ internal static readonly CorePluginFeature CorePluginFeature = new() {Plugin = CorePlugin, Profiler = CorePlugin.GetProfiler("Feature - Core")};
+ internal static readonly EffectPlaceholderPlugin EffectPlaceholderPlugin = new() {Plugin = CorePlugin, Profiler = CorePlugin.GetProfiler("Feature - Effect Placeholder")};
- internal static readonly CorePluginFeature CorePluginFeature = new() {Plugin = CorePlugin, Profiler = CorePlugin.GetProfiler("Feature - Core")};
- internal static readonly EffectPlaceholderPlugin EffectPlaceholderPlugin = new() {Plugin = CorePlugin, Profiler = CorePlugin.GetProfiler("Feature - Effect Placeholder")};
+ internal static JsonSerializerSettings JsonConvertSettings = new()
+ {
+ Converters = new List {new SKColorConverter(), new NumericJsonConverter(), new ForgivingIntConverter()}
+ };
- internal static JsonSerializerSettings JsonConvertSettings = new()
- {
- Converters = new List {new SKColorConverter(), new NumericJsonConverter(), new ForgivingIntConverter()}
- };
+ internal static JsonSerializerSettings JsonConvertTypedSettings = new()
+ {
+ TypeNameHandling = TypeNameHandling.All,
+ Converters = new List {new SKColorConverter(), new NumericJsonConverter(), new ForgivingIntConverter()}
+ };
- internal static JsonSerializerSettings JsonConvertTypedSettings = new()
- {
- TypeNameHandling = TypeNameHandling.All,
- Converters = new List {new SKColorConverter(), new NumericJsonConverter(), new ForgivingIntConverter()}
- };
+ ///
+ /// A read-only collection containing all primitive numeric types
+ ///
+ public static IReadOnlyCollection NumberTypes = new List
+ {
+ typeof(sbyte),
+ typeof(byte),
+ typeof(short),
+ typeof(ushort),
+ typeof(int),
+ typeof(uint),
+ typeof(long),
+ typeof(ulong),
+ typeof(float),
+ typeof(double),
+ typeof(decimal)
+ };
- ///
- /// A read-only collection containing all primitive numeric types
- ///
- public static IReadOnlyCollection NumberTypes = new List
- {
- typeof(sbyte),
- typeof(byte),
- typeof(short),
- typeof(ushort),
- typeof(int),
- typeof(uint),
- typeof(long),
- typeof(ulong),
- typeof(float),
- typeof(double),
- typeof(decimal)
- };
+ ///
+ /// A read-only collection containing all primitive integral numeric types
+ ///
+ public static IReadOnlyCollection IntegralNumberTypes = new List
+ {
+ typeof(sbyte),
+ typeof(byte),
+ typeof(short),
+ typeof(ushort),
+ typeof(int),
+ typeof(uint),
+ typeof(long),
+ typeof(ulong)
+ };
- ///
- /// A read-only collection containing all primitive integral numeric types
- ///
- public static IReadOnlyCollection IntegralNumberTypes = new List
- {
- typeof(sbyte),
- typeof(byte),
- typeof(short),
- typeof(ushort),
- typeof(int),
- typeof(uint),
- typeof(long),
- typeof(ulong)
- };
+ ///
+ /// A read-only collection containing all primitive floating-point numeric types
+ ///
+ public static IReadOnlyCollection FloatNumberTypes = new List
+ {
+ typeof(float),
+ typeof(double),
+ typeof(decimal)
+ };
- ///
- /// A read-only collection containing all primitive floating-point numeric types
- ///
- public static IReadOnlyCollection FloatNumberTypes = new List
- {
- typeof(float),
- typeof(double),
- typeof(decimal)
- };
-
- ///
- /// Gets the graphics context to be used for rendering by SkiaSharp. Can be set via
- /// .
- ///
- public static IManagedGraphicsContext? ManagedGraphicsContext { get; internal set; }
- }
+ ///
+ /// Gets the graphics context to be used for rendering by SkiaSharp. Can be set via
+ /// .
+ ///
+ public static IManagedGraphicsContext? ManagedGraphicsContext { get; internal set; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/DefaultTypes/Properties/BoolLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/BoolLayerProperty.cs
index ccaecf8b8..9b9ba3f10 100644
--- a/src/Artemis.Core/DefaultTypes/Properties/BoolLayerProperty.cs
+++ b/src/Artemis.Core/DefaultTypes/Properties/BoolLayerProperty.cs
@@ -1,31 +1,30 @@
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+public class BoolLayerProperty : LayerProperty
{
- ///
- public class BoolLayerProperty : LayerProperty
+ internal BoolLayerProperty()
{
- internal BoolLayerProperty()
- {
- }
+ }
- ///
- protected override void OnInitialize()
- {
- KeyframesSupported = false;
- DataBinding.RegisterDataBindingProperty(() => CurrentValue, value => CurrentValue = value, "Value");
- }
+ ///
+ /// Implicitly converts an to a
+ ///
+ public static implicit operator bool(BoolLayerProperty p)
+ {
+ return p.CurrentValue;
+ }
- ///
- /// Implicitly converts an to a
- ///
- public static implicit operator bool(BoolLayerProperty p)
- {
- return p.CurrentValue;
- }
+ ///
+ protected override void OnInitialize()
+ {
+ KeyframesSupported = false;
+ DataBinding.RegisterDataBindingProperty(() => CurrentValue, value => CurrentValue = value, "Value");
+ }
- ///
- protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
- {
- throw new ArtemisCoreException("Boolean properties do not support keyframes.");
- }
+ ///
+ protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
+ {
+ throw new ArtemisCoreException("Boolean properties do not support keyframes.");
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/DefaultTypes/Properties/EnumLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/EnumLayerProperty.cs
index ea7962b7a..482e01487 100644
--- a/src/Artemis.Core/DefaultTypes/Properties/EnumLayerProperty.cs
+++ b/src/Artemis.Core/DefaultTypes/Properties/EnumLayerProperty.cs
@@ -1,35 +1,34 @@
using System;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+public class EnumLayerProperty : LayerProperty where T : Enum
{
- ///
- public class EnumLayerProperty : LayerProperty where T : Enum
+ internal EnumLayerProperty()
{
- internal EnumLayerProperty()
- {
- KeyframesSupported = false;
- }
+ KeyframesSupported = false;
+ }
- ///
- /// Implicitly converts an to a
- ///
- public static implicit operator T(EnumLayerProperty p)
- {
- return p.CurrentValue;
- }
+ ///
+ /// Implicitly converts an to a
+ ///
+ public static implicit operator T(EnumLayerProperty p)
+ {
+ return p.CurrentValue;
+ }
- ///
- /// Implicitly converts an to an
- ///
- public static implicit operator int(EnumLayerProperty p)
- {
- return Convert.ToInt32(p.CurrentValue);
- }
+ ///
+ /// Implicitly converts an to an
+ ///
+ public static implicit operator int(EnumLayerProperty p)
+ {
+ return Convert.ToInt32(p.CurrentValue);
+ }
- ///
- protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
- {
- throw new ArtemisCoreException("Enum properties do not support keyframes.");
- }
+ ///
+ protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
+ {
+ throw new ArtemisCoreException("Enum properties do not support keyframes.");
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/DefaultTypes/Properties/FloatLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/FloatLayerProperty.cs
index 2aec47126..f4076b2b5 100644
--- a/src/Artemis.Core/DefaultTypes/Properties/FloatLayerProperty.cs
+++ b/src/Artemis.Core/DefaultTypes/Properties/FloatLayerProperty.cs
@@ -1,39 +1,38 @@
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+public class FloatLayerProperty : LayerProperty
{
- ///
- public class FloatLayerProperty : LayerProperty
+ internal FloatLayerProperty()
{
- internal FloatLayerProperty()
- {
- }
+ }
- ///
- protected override void OnInitialize()
- {
- DataBinding.RegisterDataBindingProperty(() => CurrentValue, value => CurrentValue = value, "Value");
- }
+ ///
+ /// Implicitly converts an to a
+ ///
+ public static implicit operator float(FloatLayerProperty p)
+ {
+ return p.CurrentValue;
+ }
- ///
- /// Implicitly converts an to a
- ///
- public static implicit operator float(FloatLayerProperty p)
- {
- return p.CurrentValue;
- }
+ ///
+ /// Implicitly converts an to a
+ ///
+ public static implicit operator double(FloatLayerProperty p)
+ {
+ return p.CurrentValue;
+ }
- ///
- /// Implicitly converts an to a
- ///
- public static implicit operator double(FloatLayerProperty p)
- {
- return p.CurrentValue;
- }
+ ///
+ protected override void OnInitialize()
+ {
+ DataBinding.RegisterDataBindingProperty(() => CurrentValue, value => CurrentValue = value, "Value");
+ }
- ///
- protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
- {
- float diff = NextKeyframe!.Value - CurrentKeyframe!.Value;
- CurrentValue = CurrentKeyframe!.Value + diff * keyframeProgressEased;
- }
+ ///
+ protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
+ {
+ float diff = NextKeyframe!.Value - CurrentKeyframe!.Value;
+ CurrentValue = CurrentKeyframe!.Value + diff * keyframeProgressEased;
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/DefaultTypes/Properties/FloatRangeLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/FloatRangeLayerProperty.cs
index 56408b59a..a6658537f 100644
--- a/src/Artemis.Core/DefaultTypes/Properties/FloatRangeLayerProperty.cs
+++ b/src/Artemis.Core/DefaultTypes/Properties/FloatRangeLayerProperty.cs
@@ -1,24 +1,23 @@
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+public class FloatRangeLayerProperty : LayerProperty
{
///
- public class FloatRangeLayerProperty : LayerProperty
+ protected override void OnInitialize()
{
- ///
- protected override void OnInitialize()
- {
- DataBinding.RegisterDataBindingProperty(() => CurrentValue.Start, value => CurrentValue = new FloatRange(value, CurrentValue.End), "Start");
- DataBinding.RegisterDataBindingProperty(() => CurrentValue.End, value => CurrentValue = new FloatRange(CurrentValue.Start, value), "End");
- }
+ DataBinding.RegisterDataBindingProperty(() => CurrentValue.Start, value => CurrentValue = new FloatRange(value, CurrentValue.End), "Start");
+ DataBinding.RegisterDataBindingProperty(() => CurrentValue.End, value => CurrentValue = new FloatRange(CurrentValue.Start, value), "End");
+ }
- ///
- protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
- {
- float startDiff = NextKeyframe!.Value.Start - CurrentKeyframe!.Value.Start;
- float endDiff = NextKeyframe!.Value.End - CurrentKeyframe!.Value.End;
- CurrentValue = new FloatRange(
- (float) (CurrentKeyframe!.Value.Start + startDiff * keyframeProgressEased),
- (float) (CurrentKeyframe!.Value.End + endDiff * keyframeProgressEased)
- );
- }
+ ///
+ protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
+ {
+ float startDiff = NextKeyframe!.Value.Start - CurrentKeyframe!.Value.Start;
+ float endDiff = NextKeyframe!.Value.End - CurrentKeyframe!.Value.End;
+ CurrentValue = new FloatRange(
+ CurrentKeyframe!.Value.Start + startDiff * keyframeProgressEased,
+ CurrentKeyframe!.Value.End + endDiff * keyframeProgressEased
+ );
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/DefaultTypes/Properties/IntLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/IntLayerProperty.cs
index 03681df72..1114c8267 100644
--- a/src/Artemis.Core/DefaultTypes/Properties/IntLayerProperty.cs
+++ b/src/Artemis.Core/DefaultTypes/Properties/IntLayerProperty.cs
@@ -1,49 +1,48 @@
using System;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+public class IntLayerProperty : LayerProperty
{
- ///
- public class IntLayerProperty : LayerProperty
+ internal IntLayerProperty()
{
- internal IntLayerProperty()
- {
- }
+ }
- ///
- protected override void OnInitialize()
- {
- DataBinding.RegisterDataBindingProperty(() => CurrentValue, value => CurrentValue = value, "Value");
- }
+ ///
+ /// Implicitly converts an to an
+ ///
+ public static implicit operator int(IntLayerProperty p)
+ {
+ return p.CurrentValue;
+ }
- ///
- /// Implicitly converts an to an
- ///
- public static implicit operator int(IntLayerProperty p)
- {
- return p.CurrentValue;
- }
+ ///
+ /// Implicitly converts an to a
+ ///
+ public static implicit operator float(IntLayerProperty p)
+ {
+ return p.CurrentValue;
+ }
- ///
- /// Implicitly converts an to a
- ///
- public static implicit operator float(IntLayerProperty p)
- {
- return p.CurrentValue;
- }
+ ///
+ /// Implicitly converts an to a
+ ///
+ public static implicit operator double(IntLayerProperty p)
+ {
+ return p.CurrentValue;
+ }
- ///
- /// Implicitly converts an to a
- ///
- public static implicit operator double(IntLayerProperty p)
- {
- return p.CurrentValue;
- }
+ ///
+ protected override void OnInitialize()
+ {
+ DataBinding.RegisterDataBindingProperty(() => CurrentValue, value => CurrentValue = value, "Value");
+ }
- ///
- protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
- {
- int diff = NextKeyframe!.Value - CurrentKeyframe!.Value;
- CurrentValue = (int) Math.Round(CurrentKeyframe!.Value + diff * keyframeProgressEased, MidpointRounding.AwayFromZero);
- }
+ ///
+ protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
+ {
+ int diff = NextKeyframe!.Value - CurrentKeyframe!.Value;
+ CurrentValue = (int) Math.Round(CurrentKeyframe!.Value + diff * keyframeProgressEased, MidpointRounding.AwayFromZero);
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/DefaultTypes/Properties/IntRangeLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/IntRangeLayerProperty.cs
index 481c8f721..167d4786e 100644
--- a/src/Artemis.Core/DefaultTypes/Properties/IntRangeLayerProperty.cs
+++ b/src/Artemis.Core/DefaultTypes/Properties/IntRangeLayerProperty.cs
@@ -1,24 +1,23 @@
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+public class IntRangeLayerProperty : LayerProperty
{
///
- public class IntRangeLayerProperty : LayerProperty
+ protected override void OnInitialize()
{
- ///
- protected override void OnInitialize()
- {
- DataBinding.RegisterDataBindingProperty(() => CurrentValue.Start, value => CurrentValue = new IntRange(value, CurrentValue.End), "Start");
- DataBinding.RegisterDataBindingProperty(() => CurrentValue.End, value => CurrentValue = new IntRange(CurrentValue.Start, value), "End");
- }
+ DataBinding.RegisterDataBindingProperty(() => CurrentValue.Start, value => CurrentValue = new IntRange(value, CurrentValue.End), "Start");
+ DataBinding.RegisterDataBindingProperty(() => CurrentValue.End, value => CurrentValue = new IntRange(CurrentValue.Start, value), "End");
+ }
- ///
- protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
- {
- float startDiff = NextKeyframe!.Value.Start - CurrentKeyframe!.Value.Start;
- float endDiff = NextKeyframe!.Value.End - CurrentKeyframe!.Value.End;
- CurrentValue = new IntRange(
- (int) (CurrentKeyframe!.Value.Start + startDiff * keyframeProgressEased),
- (int) (CurrentKeyframe!.Value.End + endDiff * keyframeProgressEased)
- );
- }
+ ///
+ protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
+ {
+ float startDiff = NextKeyframe!.Value.Start - CurrentKeyframe!.Value.Start;
+ float endDiff = NextKeyframe!.Value.End - CurrentKeyframe!.Value.End;
+ CurrentValue = new IntRange(
+ (int) (CurrentKeyframe!.Value.Start + startDiff * keyframeProgressEased),
+ (int) (CurrentKeyframe!.Value.End + endDiff * keyframeProgressEased)
+ );
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/DefaultTypes/Properties/LayerBrushReferenceLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/LayerBrushReferenceLayerProperty.cs
index c3341ee32..717e4da27 100644
--- a/src/Artemis.Core/DefaultTypes/Properties/LayerBrushReferenceLayerProperty.cs
+++ b/src/Artemis.Core/DefaultTypes/Properties/LayerBrushReferenceLayerProperty.cs
@@ -1,27 +1,26 @@
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// A special layer property used to configure the selected layer brush
+///
+public class LayerBrushReferenceLayerProperty : LayerProperty
{
- ///
- /// A special layer property used to configure the selected layer brush
- ///
- public class LayerBrushReferenceLayerProperty : LayerProperty
+ internal LayerBrushReferenceLayerProperty()
{
- internal LayerBrushReferenceLayerProperty()
- {
- KeyframesSupported = false;
- }
+ KeyframesSupported = false;
+ }
- ///
- /// Implicitly converts an to an
- ///
- public static implicit operator LayerBrushReference?(LayerBrushReferenceLayerProperty p)
- {
- return p.CurrentValue;
- }
+ ///
+ /// Implicitly converts an to an
+ ///
+ public static implicit operator LayerBrushReference?(LayerBrushReferenceLayerProperty p)
+ {
+ return p.CurrentValue;
+ }
- ///
- protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
- {
- throw new ArtemisCoreException("Layer brush references do not support keyframes.");
- }
+ ///
+ protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
+ {
+ throw new ArtemisCoreException("Layer brush references do not support keyframes.");
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/DefaultTypes/Properties/SKColorLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/SKColorLayerProperty.cs
index 38caad133..b0d1a27bd 100644
--- a/src/Artemis.Core/DefaultTypes/Properties/SKColorLayerProperty.cs
+++ b/src/Artemis.Core/DefaultTypes/Properties/SKColorLayerProperty.cs
@@ -1,34 +1,33 @@
using SkiaSharp;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+public class SKColorLayerProperty : LayerProperty
{
- ///
- public class SKColorLayerProperty : LayerProperty
+ internal SKColorLayerProperty()
{
- internal SKColorLayerProperty()
- {
- }
+ }
- ///
- protected override void OnInitialize()
- {
- DataBinding.RegisterDataBindingProperty(() => CurrentValue, value => CurrentValue = value, "Value");
- }
+ ///
+ /// Implicitly converts an to an ¶
+ ///
+ ///
+ ///
+ public static implicit operator SKColor(SKColorLayerProperty p)
+ {
+ return p.CurrentValue;
+ }
- ///
- /// Implicitly converts an to an ¶
- ///
- ///
- ///
- public static implicit operator SKColor(SKColorLayerProperty p)
- {
- return p.CurrentValue;
- }
+ ///
+ protected override void OnInitialize()
+ {
+ DataBinding.RegisterDataBindingProperty(() => CurrentValue, value => CurrentValue = value, "Value");
+ }
- ///
- protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
- {
- CurrentValue = CurrentKeyframe!.Value.Interpolate(NextKeyframe!.Value, keyframeProgressEased);
- }
+ ///
+ protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
+ {
+ CurrentValue = CurrentKeyframe!.Value.Interpolate(NextKeyframe!.Value, keyframeProgressEased);
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/DefaultTypes/Properties/SKPointLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/SKPointLayerProperty.cs
index df9517eeb..94e24b373 100644
--- a/src/Artemis.Core/DefaultTypes/Properties/SKPointLayerProperty.cs
+++ b/src/Artemis.Core/DefaultTypes/Properties/SKPointLayerProperty.cs
@@ -1,35 +1,34 @@
using SkiaSharp;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+public class SKPointLayerProperty : LayerProperty
{
- ///
- public class SKPointLayerProperty : LayerProperty
+ internal SKPointLayerProperty()
{
- internal SKPointLayerProperty()
- {
- }
+ }
- ///
- protected override void OnInitialize()
- {
- DataBinding.RegisterDataBindingProperty(() => CurrentValue.X, value => CurrentValue = new SKPoint(value, CurrentValue.Y), "X");
- DataBinding.RegisterDataBindingProperty(() => CurrentValue.Y, value => CurrentValue = new SKPoint(CurrentValue.X, value), "Y");
- }
+ ///
+ /// Implicitly converts an to an
+ ///
+ public static implicit operator SKPoint(SKPointLayerProperty p)
+ {
+ return p.CurrentValue;
+ }
- ///
- /// Implicitly converts an to an
- ///
- public static implicit operator SKPoint(SKPointLayerProperty p)
- {
- return p.CurrentValue;
- }
+ ///
+ protected override void OnInitialize()
+ {
+ DataBinding.RegisterDataBindingProperty(() => CurrentValue.X, value => CurrentValue = new SKPoint(value, CurrentValue.Y), "X");
+ DataBinding.RegisterDataBindingProperty(() => CurrentValue.Y, value => CurrentValue = new SKPoint(CurrentValue.X, value), "Y");
+ }
- ///
- protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
- {
- float xDiff = NextKeyframe!.Value.X - CurrentKeyframe!.Value.X;
- float yDiff = NextKeyframe!.Value.Y - CurrentKeyframe!.Value.Y;
- CurrentValue = new SKPoint(CurrentKeyframe!.Value.X + xDiff * keyframeProgressEased, CurrentKeyframe!.Value.Y + yDiff * keyframeProgressEased);
- }
+ ///
+ protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
+ {
+ float xDiff = NextKeyframe!.Value.X - CurrentKeyframe!.Value.X;
+ float yDiff = NextKeyframe!.Value.Y - CurrentKeyframe!.Value.Y;
+ CurrentValue = new SKPoint(CurrentKeyframe!.Value.X + xDiff * keyframeProgressEased, CurrentKeyframe!.Value.Y + yDiff * keyframeProgressEased);
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/DefaultTypes/Properties/SKSizeLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/SKSizeLayerProperty.cs
index e8344e0c9..402f4a320 100644
--- a/src/Artemis.Core/DefaultTypes/Properties/SKSizeLayerProperty.cs
+++ b/src/Artemis.Core/DefaultTypes/Properties/SKSizeLayerProperty.cs
@@ -1,35 +1,34 @@
using SkiaSharp;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+public class SKSizeLayerProperty : LayerProperty
{
- ///
- public class SKSizeLayerProperty : LayerProperty
+ internal SKSizeLayerProperty()
{
- internal SKSizeLayerProperty()
- {
- }
+ }
- ///
- protected override void OnInitialize()
- {
- DataBinding.RegisterDataBindingProperty(() => CurrentValue.Width, (value) => CurrentValue = new SKSize(value, CurrentValue.Height), "Width");
- DataBinding.RegisterDataBindingProperty(() => CurrentValue.Height, (value) => CurrentValue = new SKSize(CurrentValue.Width, value), "Height");
- }
+ ///
+ /// Implicitly converts an to an
+ ///
+ public static implicit operator SKSize(SKSizeLayerProperty p)
+ {
+ return p.CurrentValue;
+ }
- ///
- /// Implicitly converts an to an
- ///
- public static implicit operator SKSize(SKSizeLayerProperty p)
- {
- return p.CurrentValue;
- }
+ ///
+ protected override void OnInitialize()
+ {
+ DataBinding.RegisterDataBindingProperty(() => CurrentValue.Width, value => CurrentValue = new SKSize(value, CurrentValue.Height), "Width");
+ DataBinding.RegisterDataBindingProperty(() => CurrentValue.Height, value => CurrentValue = new SKSize(CurrentValue.Width, value), "Height");
+ }
- ///
- protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
- {
- float widthDiff = NextKeyframe!.Value.Width - CurrentKeyframe!.Value.Width;
- float heightDiff = NextKeyframe!.Value.Height - CurrentKeyframe!.Value.Height;
- CurrentValue = new SKSize(CurrentKeyframe!.Value.Width + widthDiff * keyframeProgressEased, CurrentKeyframe!.Value.Height + heightDiff * keyframeProgressEased);
- }
+ ///
+ protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
+ {
+ float widthDiff = NextKeyframe!.Value.Width - CurrentKeyframe!.Value.Width;
+ float heightDiff = NextKeyframe!.Value.Height - CurrentKeyframe!.Value.Height;
+ CurrentValue = new SKSize(CurrentKeyframe!.Value.Width + widthDiff * keyframeProgressEased, CurrentKeyframe!.Value.Height + heightDiff * keyframeProgressEased);
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/DataModelPathEventArgs.cs b/src/Artemis.Core/Events/DataModelPathEventArgs.cs
index 6e3da98ed..da1a8cc95 100644
--- a/src/Artemis.Core/Events/DataModelPathEventArgs.cs
+++ b/src/Artemis.Core/Events/DataModelPathEventArgs.cs
@@ -1,20 +1,19 @@
using System;
-namespace Artemis.Core
-{
- ///
- /// Provides data about data model path related events
- ///
- public class DataModelPathEventArgs : EventArgs
- {
- internal DataModelPathEventArgs(DataModelPath dataModelPath)
- {
- DataModelPath = dataModelPath;
- }
+namespace Artemis.Core;
- ///
- /// Gets the data model path this event is related to
- ///
- public DataModelPath DataModelPath { get; }
+///
+/// Provides data about data model path related events
+///
+public class DataModelPathEventArgs : EventArgs
+{
+ internal DataModelPathEventArgs(DataModelPath dataModelPath)
+ {
+ DataModelPath = dataModelPath;
}
+
+ ///
+ /// Gets the data model path this event is related to
+ ///
+ public DataModelPath DataModelPath { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/DeviceEventArgs.cs b/src/Artemis.Core/Events/DeviceEventArgs.cs
index 3eaf045bf..4d581763e 100644
--- a/src/Artemis.Core/Events/DeviceEventArgs.cs
+++ b/src/Artemis.Core/Events/DeviceEventArgs.cs
@@ -1,20 +1,19 @@
using System;
-namespace Artemis.Core
-{
- ///
- /// Provides data about device related events
- ///
- public class DeviceEventArgs : EventArgs
- {
- internal DeviceEventArgs(ArtemisDevice device)
- {
- Device = device;
- }
+namespace Artemis.Core;
- ///
- /// Gets the device this event is related to
- ///
- public ArtemisDevice Device { get; }
+///
+/// Provides data about device related events
+///
+public class DeviceEventArgs : EventArgs
+{
+ internal DeviceEventArgs(ArtemisDevice device)
+ {
+ Device = device;
}
+
+ ///
+ /// Gets the device this event is related to
+ ///
+ public ArtemisDevice Device { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/DynamicDataModelChildEventArgs.cs b/src/Artemis.Core/Events/DynamicDataModelChildEventArgs.cs
index 030fd815e..02f6a6b20 100644
--- a/src/Artemis.Core/Events/DynamicDataModelChildEventArgs.cs
+++ b/src/Artemis.Core/Events/DynamicDataModelChildEventArgs.cs
@@ -1,27 +1,26 @@
using System;
using Artemis.Core.Modules;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Provides data about dynamic data model child related events
+///
+public class DynamicDataModelChildEventArgs : EventArgs
{
- ///
- /// Provides data about dynamic data model child related events
- ///
- public class DynamicDataModelChildEventArgs : EventArgs
+ internal DynamicDataModelChildEventArgs(DynamicChild dynamicChild, string key)
{
- internal DynamicDataModelChildEventArgs(DynamicChild dynamicChild, string key)
- {
- DynamicChild = dynamicChild;
- Key = key;
- }
-
- ///
- /// Gets the dynamic data model child
- ///
- public DynamicChild DynamicChild { get; }
-
- ///
- /// Gets the key of the dynamic data model on the parent
- ///
- public string Key { get; }
+ DynamicChild = dynamicChild;
+ Key = key;
}
+
+ ///
+ /// Gets the dynamic data model child
+ ///
+ public DynamicChild DynamicChild { get; }
+
+ ///
+ /// Gets the key of the dynamic data model on the parent
+ ///
+ public string Key { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/FrameRenderedEventArgs.cs b/src/Artemis.Core/Events/FrameRenderedEventArgs.cs
index 65c0c18e9..935375fad 100644
--- a/src/Artemis.Core/Events/FrameRenderedEventArgs.cs
+++ b/src/Artemis.Core/Events/FrameRenderedEventArgs.cs
@@ -1,27 +1,26 @@
using System;
using RGB.NET.Core;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Provides data about frame rendering related events
+///
+public class FrameRenderedEventArgs : EventArgs
{
- ///
- /// Provides data about frame rendering related events
- ///
- public class FrameRenderedEventArgs : EventArgs
+ internal FrameRenderedEventArgs(SKTexture texture, RGBSurface rgbSurface)
{
- internal FrameRenderedEventArgs(SKTexture texture, RGBSurface rgbSurface)
- {
- Texture = texture;
- RgbSurface = rgbSurface;
- }
-
- ///
- /// Gets the texture used to render this frame
- ///
- public SKTexture Texture { get; }
-
- ///
- /// Gets the RGB surface used to render this frame
- ///
- public RGBSurface RgbSurface { get; }
+ Texture = texture;
+ RgbSurface = rgbSurface;
}
+
+ ///
+ /// Gets the texture used to render this frame
+ ///
+ public SKTexture Texture { get; }
+
+ ///
+ /// Gets the RGB surface used to render this frame
+ ///
+ public RGBSurface RgbSurface { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/FrameRenderingEventArgs.cs b/src/Artemis.Core/Events/FrameRenderingEventArgs.cs
index 1b1c0e747..56394587f 100644
--- a/src/Artemis.Core/Events/FrameRenderingEventArgs.cs
+++ b/src/Artemis.Core/Events/FrameRenderingEventArgs.cs
@@ -2,33 +2,32 @@
using RGB.NET.Core;
using SkiaSharp;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Provides data about frame rendered related events
+///
+public class FrameRenderingEventArgs : EventArgs
{
- ///
- /// Provides data about frame rendered related events
- ///
- public class FrameRenderingEventArgs : EventArgs
+ internal FrameRenderingEventArgs(SKCanvas canvas, double deltaTime, RGBSurface rgbSurface)
{
- internal FrameRenderingEventArgs(SKCanvas canvas, double deltaTime, RGBSurface rgbSurface)
- {
- Canvas = canvas;
- DeltaTime = deltaTime;
- RgbSurface = rgbSurface;
- }
-
- ///
- /// Gets the canvas this frame is rendering on
- ///
- public SKCanvas Canvas { get; }
-
- ///
- /// Gets the delta time since the last frame was rendered
- ///
- public double DeltaTime { get; }
-
- ///
- /// Gets the RGB surface used to render this frame
- ///
- public RGBSurface RgbSurface { get; }
+ Canvas = canvas;
+ DeltaTime = deltaTime;
+ RgbSurface = rgbSurface;
}
+
+ ///
+ /// Gets the canvas this frame is rendering on
+ ///
+ public SKCanvas Canvas { get; }
+
+ ///
+ /// Gets the delta time since the last frame was rendered
+ ///
+ public double DeltaTime { get; }
+
+ ///
+ /// Gets the RGB surface used to render this frame
+ ///
+ public RGBSurface RgbSurface { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/ModuleEventArgs.cs b/src/Artemis.Core/Events/ModuleEventArgs.cs
index 44db160a3..dd9d2c8c8 100644
--- a/src/Artemis.Core/Events/ModuleEventArgs.cs
+++ b/src/Artemis.Core/Events/ModuleEventArgs.cs
@@ -1,21 +1,20 @@
using System;
using Artemis.Core.Modules;
-namespace Artemis.Core
-{
- ///
- /// Provides data about module events
- ///
- public class ModuleEventArgs : EventArgs
- {
- internal ModuleEventArgs(Module module)
- {
- Module = module;
- }
+namespace Artemis.Core;
- ///
- /// Gets the module this event is related to
- ///
- public Module Module { get; }
+///
+/// Provides data about module events
+///
+public class ModuleEventArgs : EventArgs
+{
+ internal ModuleEventArgs(Module module)
+ {
+ Module = module;
}
+
+ ///
+ /// Gets the module this event is related to
+ ///
+ public Module Module { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/Plugins/PluginEventArgs.cs b/src/Artemis.Core/Events/Plugins/PluginEventArgs.cs
index aa21536bc..fad23069a 100644
--- a/src/Artemis.Core/Events/Plugins/PluginEventArgs.cs
+++ b/src/Artemis.Core/Events/Plugins/PluginEventArgs.cs
@@ -1,20 +1,19 @@
using System;
-namespace Artemis.Core
-{
- ///
- /// Provides data about plugin related events
- ///
- public class PluginEventArgs : EventArgs
- {
- internal PluginEventArgs(Plugin plugin)
- {
- Plugin = plugin;
- }
+namespace Artemis.Core;
- ///
- /// Gets the plugin this event is related to
- ///
- public Plugin Plugin { get; }
+///
+/// Provides data about plugin related events
+///
+public class PluginEventArgs : EventArgs
+{
+ internal PluginEventArgs(Plugin plugin)
+ {
+ Plugin = plugin;
}
+
+ ///
+ /// Gets the plugin this event is related to
+ ///
+ public Plugin Plugin { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/Plugins/PluginFeatureEventArgs.cs b/src/Artemis.Core/Events/Plugins/PluginFeatureEventArgs.cs
index d16789b82..121a76759 100644
--- a/src/Artemis.Core/Events/Plugins/PluginFeatureEventArgs.cs
+++ b/src/Artemis.Core/Events/Plugins/PluginFeatureEventArgs.cs
@@ -1,36 +1,35 @@
using System;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Provides data about plugin feature related events
+///
+public class PluginFeatureEventArgs : EventArgs
{
- ///
- /// Provides data about plugin feature related events
- ///
- public class PluginFeatureEventArgs : EventArgs
+ internal PluginFeatureEventArgs(PluginFeature pluginFeature)
{
- internal PluginFeatureEventArgs(PluginFeature pluginFeature)
- {
- PluginFeature = pluginFeature;
- }
-
- ///
- /// Gets the plugin feature this event is related to
- ///
- public PluginFeature PluginFeature { get; }
+ PluginFeature = pluginFeature;
}
///
- /// Provides data about plugin feature info related events
+ /// Gets the plugin feature this event is related to
///
- public class PluginFeatureInfoEventArgs : EventArgs
- {
- internal PluginFeatureInfoEventArgs(PluginFeatureInfo pluginFeatureInfo)
- {
- PluginFeatureInfo = pluginFeatureInfo;
- }
+ public PluginFeature PluginFeature { get; }
+}
- ///
- /// Gets the plugin feature this event is related to
- ///
- public PluginFeatureInfo PluginFeatureInfo { get; }
+///
+/// Provides data about plugin feature info related events
+///
+public class PluginFeatureInfoEventArgs : EventArgs
+{
+ internal PluginFeatureInfoEventArgs(PluginFeatureInfo pluginFeatureInfo)
+ {
+ PluginFeatureInfo = pluginFeatureInfo;
}
+
+ ///
+ /// Gets the plugin feature this event is related to
+ ///
+ public PluginFeatureInfo PluginFeatureInfo { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/Profiles/DataBindingEventArgs.cs b/src/Artemis.Core/Events/Profiles/DataBindingEventArgs.cs
index c01cfae65..927e1b849 100644
--- a/src/Artemis.Core/Events/Profiles/DataBindingEventArgs.cs
+++ b/src/Artemis.Core/Events/Profiles/DataBindingEventArgs.cs
@@ -1,20 +1,19 @@
using System;
-namespace Artemis.Core
-{
- ///
- /// Provides data for data binding events.
- ///
- public class DataBindingEventArgs : EventArgs
- {
- internal DataBindingEventArgs(IDataBinding dataBinding)
- {
- DataBinding = dataBinding;
- }
+namespace Artemis.Core;
- ///
- /// Gets the data binding this event is related to
- ///
- public IDataBinding DataBinding { get; }
+///
+/// Provides data for data binding events.
+///
+public class DataBindingEventArgs : EventArgs
+{
+ internal DataBindingEventArgs(IDataBinding dataBinding)
+ {
+ DataBinding = dataBinding;
}
+
+ ///
+ /// Gets the data binding this event is related to
+ ///
+ public IDataBinding DataBinding { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/Profiles/DataBindingPropertyUpdatedEvent.cs b/src/Artemis.Core/Events/Profiles/DataBindingPropertyUpdatedEvent.cs
index 33ea09229..f67aa3dcb 100644
--- a/src/Artemis.Core/Events/Profiles/DataBindingPropertyUpdatedEvent.cs
+++ b/src/Artemis.Core/Events/Profiles/DataBindingPropertyUpdatedEvent.cs
@@ -1,21 +1,20 @@
using System;
-namespace Artemis.Core
-{
- ///
- /// Provides data for the event.
- ///
- ///
- public class DataBindingPropertyUpdatedEvent : EventArgs
- {
- internal DataBindingPropertyUpdatedEvent(T value)
- {
- Value = value;
- }
+namespace Artemis.Core;
- ///
- /// The updated value that should be applied to the layer property
- ///
- public T Value { get; }
+///
+/// Provides data for the event.
+///
+///
+public class DataBindingPropertyUpdatedEvent : EventArgs
+{
+ internal DataBindingPropertyUpdatedEvent(T value)
+ {
+ Value = value;
}
+
+ ///
+ /// The updated value that should be applied to the layer property
+ ///
+ public T Value { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/Profiles/LayerPropertyEventArgs.cs b/src/Artemis.Core/Events/Profiles/LayerPropertyEventArgs.cs
index 86904790a..49bbb0768 100644
--- a/src/Artemis.Core/Events/Profiles/LayerPropertyEventArgs.cs
+++ b/src/Artemis.Core/Events/Profiles/LayerPropertyEventArgs.cs
@@ -1,20 +1,19 @@
using System;
-namespace Artemis.Core
-{
- ///
- /// Provides data for layer property events.
- ///
- public class LayerPropertyEventArgs : EventArgs
- {
- internal LayerPropertyEventArgs(ILayerProperty layerProperty)
- {
- LayerProperty = layerProperty;
- }
+namespace Artemis.Core;
- ///
- /// Gets the layer property this event is related to
- ///
- public ILayerProperty LayerProperty { get; }
+///
+/// Provides data for layer property events.
+///
+public class LayerPropertyEventArgs : EventArgs
+{
+ internal LayerPropertyEventArgs(ILayerProperty layerProperty)
+ {
+ LayerProperty = layerProperty;
}
+
+ ///
+ /// Gets the layer property this event is related to
+ ///
+ public ILayerProperty LayerProperty { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/Profiles/ProfileConfigurationEventArgs.cs b/src/Artemis.Core/Events/Profiles/ProfileConfigurationEventArgs.cs
index 4bfa83c26..faec37c0d 100644
--- a/src/Artemis.Core/Events/Profiles/ProfileConfigurationEventArgs.cs
+++ b/src/Artemis.Core/Events/Profiles/ProfileConfigurationEventArgs.cs
@@ -1,20 +1,19 @@
using System;
-namespace Artemis.Core
-{
- ///
- /// Provides data for profile configuration events.
- ///
- public class ProfileConfigurationEventArgs : EventArgs
- {
- internal ProfileConfigurationEventArgs(ProfileConfiguration profileConfiguration)
- {
- ProfileConfiguration = profileConfiguration;
- }
+namespace Artemis.Core;
- ///
- /// Gets the profile configuration this event is related to
- ///
- public ProfileConfiguration ProfileConfiguration { get; }
+///
+/// Provides data for profile configuration events.
+///
+public class ProfileConfigurationEventArgs : EventArgs
+{
+ internal ProfileConfigurationEventArgs(ProfileConfiguration profileConfiguration)
+ {
+ ProfileConfiguration = profileConfiguration;
}
+
+ ///
+ /// Gets the profile configuration this event is related to
+ ///
+ public ProfileConfiguration ProfileConfiguration { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/Profiles/ProfileElementEventArgs.cs b/src/Artemis.Core/Events/Profiles/ProfileElementEventArgs.cs
index 4f4a740e4..3906d1762 100644
--- a/src/Artemis.Core/Events/Profiles/ProfileElementEventArgs.cs
+++ b/src/Artemis.Core/Events/Profiles/ProfileElementEventArgs.cs
@@ -1,20 +1,19 @@
using System;
-namespace Artemis.Core
-{
- ///
- /// Provides data for profile element events.
- ///
- public class ProfileElementEventArgs : EventArgs
- {
- internal ProfileElementEventArgs(ProfileElement profileElement)
- {
- ProfileElement = profileElement;
- }
+namespace Artemis.Core;
- ///
- /// Gets the profile element this event is related to
- ///
- public ProfileElement ProfileElement { get; }
+///
+/// Provides data for profile element events.
+///
+public class ProfileElementEventArgs : EventArgs
+{
+ internal ProfileElementEventArgs(ProfileElement profileElement)
+ {
+ ProfileElement = profileElement;
}
+
+ ///
+ /// Gets the profile element this event is related to
+ ///
+ public ProfileElement ProfileElement { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/RestartEventArgs.cs b/src/Artemis.Core/Events/RestartEventArgs.cs
index 1fe2b1fae..08458baff 100644
--- a/src/Artemis.Core/Events/RestartEventArgs.cs
+++ b/src/Artemis.Core/Events/RestartEventArgs.cs
@@ -1,33 +1,32 @@
using System;
using System.Collections.Generic;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Provides data about application restart events
+///
+public class RestartEventArgs : EventArgs
{
- ///
- /// Provides data about application restart events
- ///
- public class RestartEventArgs : EventArgs
+ internal RestartEventArgs(bool elevate, TimeSpan delay, List? extraArgs)
{
- internal RestartEventArgs(bool elevate, TimeSpan delay, List? extraArgs)
- {
- Elevate = elevate;
- Delay = delay;
- ExtraArgs = extraArgs;
- }
-
- ///
- /// Gets a boolean indicating whether the application should be restarted with elevated permissions
- ///
- public bool Elevate { get; }
-
- ///
- /// Gets the delay before killing process and restarting
- ///
- public TimeSpan Delay { get; }
-
- ///
- /// A list of extra arguments to pass to Artemis when restarting
- ///
- public List? ExtraArgs { get; }
+ Elevate = elevate;
+ Delay = delay;
+ ExtraArgs = extraArgs;
}
+
+ ///
+ /// Gets a boolean indicating whether the application should be restarted with elevated permissions
+ ///
+ public bool Elevate { get; }
+
+ ///
+ /// Gets the delay before killing process and restarting
+ ///
+ public TimeSpan Delay { get; }
+
+ ///
+ /// A list of extra arguments to pass to Artemis when restarting
+ ///
+ public List? ExtraArgs { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/Stores/DataModelStoreEvent.cs b/src/Artemis.Core/Events/Stores/DataModelStoreEvent.cs
index eb1132422..15d9e84fb 100644
--- a/src/Artemis.Core/Events/Stores/DataModelStoreEvent.cs
+++ b/src/Artemis.Core/Events/Stores/DataModelStoreEvent.cs
@@ -1,12 +1,11 @@
-namespace Artemis.Core
-{
- internal class DataModelStoreEvent
- {
- public DataModelStoreEvent(DataModelRegistration registration)
- {
- Registration = registration;
- }
+namespace Artemis.Core;
- public DataModelRegistration Registration { get; }
+internal class DataModelStoreEvent
+{
+ public DataModelStoreEvent(DataModelRegistration registration)
+ {
+ Registration = registration;
}
+
+ public DataModelRegistration Registration { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/Stores/LayerBrushStoreEvent.cs b/src/Artemis.Core/Events/Stores/LayerBrushStoreEvent.cs
index 6d80a46fb..b8c147d86 100644
--- a/src/Artemis.Core/Events/Stores/LayerBrushStoreEvent.cs
+++ b/src/Artemis.Core/Events/Stores/LayerBrushStoreEvent.cs
@@ -1,12 +1,11 @@
-namespace Artemis.Core
-{
- internal class LayerBrushStoreEvent
- {
- public LayerBrushStoreEvent(LayerBrushRegistration registration)
- {
- Registration = registration;
- }
+namespace Artemis.Core;
- public LayerBrushRegistration Registration { get; }
+internal class LayerBrushStoreEvent
+{
+ public LayerBrushStoreEvent(LayerBrushRegistration registration)
+ {
+ Registration = registration;
}
+
+ public LayerBrushRegistration Registration { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/Stores/LayerEffectStoreEvent.cs b/src/Artemis.Core/Events/Stores/LayerEffectStoreEvent.cs
index 8abcecb7f..fc7978d80 100644
--- a/src/Artemis.Core/Events/Stores/LayerEffectStoreEvent.cs
+++ b/src/Artemis.Core/Events/Stores/LayerEffectStoreEvent.cs
@@ -1,12 +1,11 @@
-namespace Artemis.Core
-{
- internal class LayerEffectStoreEvent
- {
- public LayerEffectStoreEvent(LayerEffectRegistration registration)
- {
- Registration = registration;
- }
+namespace Artemis.Core;
- public LayerEffectRegistration Registration { get; }
+internal class LayerEffectStoreEvent
+{
+ public LayerEffectStoreEvent(LayerEffectRegistration registration)
+ {
+ Registration = registration;
}
+
+ public LayerEffectRegistration Registration { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/Stores/NodeTypeStoreEvent.cs b/src/Artemis.Core/Events/Stores/NodeTypeStoreEvent.cs
index e91d27b6a..ac641e729 100644
--- a/src/Artemis.Core/Events/Stores/NodeTypeStoreEvent.cs
+++ b/src/Artemis.Core/Events/Stores/NodeTypeStoreEvent.cs
@@ -1,12 +1,11 @@
-namespace Artemis.Core
-{
- internal class NodeTypeStoreEvent
- {
- public NodeTypeStoreEvent(NodeTypeRegistration typeRegistration)
- {
- TypeRegistration = typeRegistration;
- }
+namespace Artemis.Core;
- public NodeTypeRegistration TypeRegistration { get; }
+internal class NodeTypeStoreEvent
+{
+ public NodeTypeStoreEvent(NodeTypeRegistration typeRegistration)
+ {
+ TypeRegistration = typeRegistration;
}
+
+ public NodeTypeRegistration TypeRegistration { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Events/SurfaceConfigurationEventArgs.cs b/src/Artemis.Core/Events/SurfaceConfigurationEventArgs.cs
index 52f8192a9..68514ccf6 100644
--- a/src/Artemis.Core/Events/SurfaceConfigurationEventArgs.cs
+++ b/src/Artemis.Core/Events/SurfaceConfigurationEventArgs.cs
@@ -1,21 +1,20 @@
using System;
using System.Collections.Generic;
-namespace Artemis.Core
-{
- ///
- /// Provides data about device configuration related events
- ///
- public class SurfaceConfigurationEventArgs : EventArgs
- {
- internal SurfaceConfigurationEventArgs(List devices)
- {
- Devices = devices;
- }
+namespace Artemis.Core;
- ///
- /// Gets the current list of devices
- ///
- public List Devices { get; }
+///
+/// Provides data about device configuration related events
+///
+public class SurfaceConfigurationEventArgs : EventArgs
+{
+ internal SurfaceConfigurationEventArgs(List devices)
+ {
+ Devices = devices;
}
+
+ ///
+ /// Gets the current list of devices
+ ///
+ public List Devices { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Exceptions/ArtemisCoreException.cs b/src/Artemis.Core/Exceptions/ArtemisCoreException.cs
index 44faa3083..0718c5548 100644
--- a/src/Artemis.Core/Exceptions/ArtemisCoreException.cs
+++ b/src/Artemis.Core/Exceptions/ArtemisCoreException.cs
@@ -1,18 +1,17 @@
using System;
-namespace Artemis.Core
-{
- ///
- /// Represents errors that occur within the Artemis Core
- ///
- public class ArtemisCoreException : Exception
- {
- internal ArtemisCoreException(string message) : base(message)
- {
- }
+namespace Artemis.Core;
- internal ArtemisCoreException(string message, Exception inner) : base(message, inner)
- {
- }
+///
+/// Represents errors that occur within the Artemis Core
+///
+public class ArtemisCoreException : Exception
+{
+ internal ArtemisCoreException(string message) : base(message)
+ {
+ }
+
+ internal ArtemisCoreException(string message, Exception inner) : base(message, inner)
+ {
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Exceptions/ArtemisGraphicsContextException.cs b/src/Artemis.Core/Exceptions/ArtemisGraphicsContextException.cs
index 975dd8c04..6970b445a 100644
--- a/src/Artemis.Core/Exceptions/ArtemisGraphicsContextException.cs
+++ b/src/Artemis.Core/Exceptions/ArtemisGraphicsContextException.cs
@@ -1,25 +1,24 @@
using System;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents SkiaSharp graphics-context related errors
+///
+public class ArtemisGraphicsContextException : Exception
{
- ///
- /// Represents SkiaSharp graphics-context related errors
- ///
- public class ArtemisGraphicsContextException : Exception
+ ///
+ public ArtemisGraphicsContextException()
{
- ///
- public ArtemisGraphicsContextException()
- {
- }
+ }
- ///
- public ArtemisGraphicsContextException(string message) : base(message)
- {
- }
+ ///
+ public ArtemisGraphicsContextException(string message) : base(message)
+ {
+ }
- ///
- public ArtemisGraphicsContextException(string message, Exception innerException) : base(message, innerException)
- {
- }
+ ///
+ public ArtemisGraphicsContextException(string message, Exception innerException) : base(message, innerException)
+ {
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Exceptions/ArtemisPluginException.cs b/src/Artemis.Core/Exceptions/ArtemisPluginException.cs
index 0e8827443..8e49b0e19 100644
--- a/src/Artemis.Core/Exceptions/ArtemisPluginException.cs
+++ b/src/Artemis.Core/Exceptions/ArtemisPluginException.cs
@@ -1,53 +1,52 @@
using System;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// An exception thrown when a plugin-related error occurs
+///
+public class ArtemisPluginException : Exception
{
///
- /// An exception thrown when a plugin-related error occurs
+ /// Creates a new instance of the class
///
- public class ArtemisPluginException : Exception
+ public ArtemisPluginException(Plugin plugin)
{
- ///
- /// Creates a new instance of the class
- ///
- public ArtemisPluginException(Plugin plugin)
- {
- Plugin = plugin;
- }
-
- ///
- /// Creates a new instance of the class
- ///
- public ArtemisPluginException(Plugin plugin, string message) : base(message)
- {
- Plugin = plugin;
- }
-
- ///
- /// Creates a new instance of the class
- ///
- public ArtemisPluginException(Plugin plugin, string message, Exception inner) : base(message, inner)
- {
- Plugin = plugin;
- }
-
- ///
- /// Creates a new instance of the class
- ///
- public ArtemisPluginException(string message) : base(message)
- {
- }
-
- ///
- /// Creates a new instance of the class
- ///
- public ArtemisPluginException(string message, Exception inner) : base(message, inner)
- {
- }
-
- ///
- /// Gets the plugin the error is related to
- ///
- public Plugin? Plugin { get; }
+ Plugin = plugin;
}
+
+ ///
+ /// Creates a new instance of the class
+ ///
+ public ArtemisPluginException(Plugin plugin, string message) : base(message)
+ {
+ Plugin = plugin;
+ }
+
+ ///
+ /// Creates a new instance of the class
+ ///
+ public ArtemisPluginException(Plugin plugin, string message, Exception inner) : base(message, inner)
+ {
+ Plugin = plugin;
+ }
+
+ ///
+ /// Creates a new instance of the class
+ ///
+ public ArtemisPluginException(string message) : base(message)
+ {
+ }
+
+ ///
+ /// Creates a new instance of the class
+ ///
+ public ArtemisPluginException(string message, Exception inner) : base(message, inner)
+ {
+ }
+
+ ///
+ /// Gets the plugin the error is related to
+ ///
+ public Plugin? Plugin { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Exceptions/ArtemisPluginFeatureException.cs b/src/Artemis.Core/Exceptions/ArtemisPluginFeatureException.cs
index 3e1766bd7..6b0a6867c 100644
--- a/src/Artemis.Core/Exceptions/ArtemisPluginFeatureException.cs
+++ b/src/Artemis.Core/Exceptions/ArtemisPluginFeatureException.cs
@@ -1,30 +1,29 @@
using System;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// An exception thrown when a plugin feature-related error occurs
+///
+public class ArtemisPluginFeatureException : Exception
{
- ///
- /// An exception thrown when a plugin feature-related error occurs
- ///
- public class ArtemisPluginFeatureException : Exception
+ internal ArtemisPluginFeatureException(PluginFeature pluginFeature)
{
- internal ArtemisPluginFeatureException(PluginFeature pluginFeature)
- {
- PluginFeature = pluginFeature;
- }
-
- internal ArtemisPluginFeatureException(PluginFeature pluginFeature, string message) : base(message)
- {
- PluginFeature = pluginFeature;
- }
-
- internal ArtemisPluginFeatureException(PluginFeature pluginFeature, string message, Exception inner) : base(message, inner)
- {
- PluginFeature = pluginFeature;
- }
-
- ///
- /// Gets the plugin feature the error is related to
- ///
- public PluginFeature PluginFeature { get; }
+ PluginFeature = pluginFeature;
}
+
+ internal ArtemisPluginFeatureException(PluginFeature pluginFeature, string message) : base(message)
+ {
+ PluginFeature = pluginFeature;
+ }
+
+ internal ArtemisPluginFeatureException(PluginFeature pluginFeature, string message, Exception inner) : base(message, inner)
+ {
+ PluginFeature = pluginFeature;
+ }
+
+ ///
+ /// Gets the plugin feature the error is related to
+ ///
+ public PluginFeature PluginFeature { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Exceptions/ArtemisPluginLockException.cs b/src/Artemis.Core/Exceptions/ArtemisPluginLockException.cs
index e95d27272..e601e6e26 100644
--- a/src/Artemis.Core/Exceptions/ArtemisPluginLockException.cs
+++ b/src/Artemis.Core/Exceptions/ArtemisPluginLockException.cs
@@ -1,21 +1,20 @@
using System;
-namespace Artemis.Core
-{
- ///
- /// An exception thrown when a plugin lock file error occurs
- ///
- public class ArtemisPluginLockException : Exception
- {
- internal ArtemisPluginLockException(Exception? innerException) : base(CreateExceptionMessage(innerException), innerException)
- {
- }
+namespace Artemis.Core;
- private static string CreateExceptionMessage(Exception? innerException)
- {
- return innerException != null
- ? "Found a lock file, skipping load, see inner exception for last known exception."
- : "Found a lock file, skipping load.";
- }
+///
+/// An exception thrown when a plugin lock file error occurs
+///
+public class ArtemisPluginLockException : Exception
+{
+ internal ArtemisPluginLockException(Exception? innerException) : base(CreateExceptionMessage(innerException), innerException)
+ {
+ }
+
+ private static string CreateExceptionMessage(Exception? innerException)
+ {
+ return innerException != null
+ ? "Found a lock file, skipping load, see inner exception for last known exception."
+ : "Found a lock file, skipping load.";
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Exceptions/ArtemisPluginPrerequisiteException.cs b/src/Artemis.Core/Exceptions/ArtemisPluginPrerequisiteException.cs
index e2f3a850d..7951ccbbd 100644
--- a/src/Artemis.Core/Exceptions/ArtemisPluginPrerequisiteException.cs
+++ b/src/Artemis.Core/Exceptions/ArtemisPluginPrerequisiteException.cs
@@ -1,30 +1,29 @@
using System;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// An exception thrown when a plugin prerequisite-related error occurs
+///
+public class ArtemisPluginPrerequisiteException : Exception
{
- ///
- /// An exception thrown when a plugin prerequisite-related error occurs
- ///
- public class ArtemisPluginPrerequisiteException : Exception
+ internal ArtemisPluginPrerequisiteException(IPrerequisitesSubject subject)
{
- internal ArtemisPluginPrerequisiteException(IPrerequisitesSubject subject)
- {
- Subject = subject;
- }
-
- internal ArtemisPluginPrerequisiteException(IPrerequisitesSubject subject, string message) : base(message)
- {
- Subject = subject;
- }
-
- internal ArtemisPluginPrerequisiteException(IPrerequisitesSubject subject, string message, Exception inner) : base(message, inner)
- {
- Subject = subject;
- }
-
- ///
- /// Gets the subject the error is related to
- ///
- public IPrerequisitesSubject Subject { get; }
+ Subject = subject;
}
+
+ internal ArtemisPluginPrerequisiteException(IPrerequisitesSubject subject, string message) : base(message)
+ {
+ Subject = subject;
+ }
+
+ internal ArtemisPluginPrerequisiteException(IPrerequisitesSubject subject, string message, Exception inner) : base(message, inner)
+ {
+ Subject = subject;
+ }
+
+ ///
+ /// Gets the subject the error is related to
+ ///
+ public IPrerequisitesSubject Subject { get; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Extensions/DirectoryInfoExtensions.cs b/src/Artemis.Core/Extensions/DirectoryInfoExtensions.cs
index fda99d3b5..5a6864273 100644
--- a/src/Artemis.Core/Extensions/DirectoryInfoExtensions.cs
+++ b/src/Artemis.Core/Extensions/DirectoryInfoExtensions.cs
@@ -1,32 +1,31 @@
using System.IO;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+internal static class DirectoryInfoExtensions
{
- internal static class DirectoryInfoExtensions
+ public static void CopyFilesRecursively(this DirectoryInfo source, DirectoryInfo target)
{
- public static void CopyFilesRecursively(this DirectoryInfo source, DirectoryInfo target)
+ foreach (DirectoryInfo dir in source.GetDirectories())
+ CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name));
+ foreach (FileInfo file in source.GetFiles())
+ file.CopyTo(Path.Combine(target.FullName, file.Name));
+ }
+
+ public static void DeleteRecursively(this DirectoryInfo baseDir)
+ {
+ if (!baseDir.Exists)
+ return;
+
+ foreach (DirectoryInfo dir in baseDir.EnumerateDirectories())
+ DeleteRecursively(dir);
+ FileInfo[] files = baseDir.GetFiles();
+ foreach (FileInfo file in files)
{
- foreach (DirectoryInfo dir in source.GetDirectories())
- CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name));
- foreach (FileInfo file in source.GetFiles())
- file.CopyTo(Path.Combine(target.FullName, file.Name));
+ file.IsReadOnly = false;
+ file.Delete();
}
- public static void DeleteRecursively(this DirectoryInfo baseDir)
- {
- if (!baseDir.Exists)
- return;
-
- foreach (DirectoryInfo dir in baseDir.EnumerateDirectories())
- DeleteRecursively(dir);
- FileInfo[] files = baseDir.GetFiles();
- foreach (FileInfo file in files)
- {
- file.IsReadOnly = false;
- file.Delete();
- }
-
- baseDir.Delete();
- }
+ baseDir.Delete();
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Extensions/DoubleExtensions.cs b/src/Artemis.Core/Extensions/DoubleExtensions.cs
index 796f247fb..b8620dc92 100644
--- a/src/Artemis.Core/Extensions/DoubleExtensions.cs
+++ b/src/Artemis.Core/Extensions/DoubleExtensions.cs
@@ -1,22 +1,21 @@
using System;
using System.Runtime.CompilerServices;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// A static class providing extensions
+///
+public static class DoubleExtensions
{
///
- /// A static class providing extensions
+ /// Rounds the provided number away to zero and casts the result to an
///
- public static class DoubleExtensions
+ /// The number to round
+ /// The rounded number as an integer
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static int RoundToInt(this double number)
{
- ///
- /// Rounds the provided number away to zero and casts the result to an
- ///
- /// The number to round
- /// The rounded number as an integer
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static int RoundToInt(this double number)
- {
- return (int) Math.Round(number, MidpointRounding.AwayFromZero);
- }
+ return (int) Math.Round(number, MidpointRounding.AwayFromZero);
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Extensions/FloatExtensions.cs b/src/Artemis.Core/Extensions/FloatExtensions.cs
index 0a4cb9568..4ce95dfc4 100644
--- a/src/Artemis.Core/Extensions/FloatExtensions.cs
+++ b/src/Artemis.Core/Extensions/FloatExtensions.cs
@@ -1,22 +1,21 @@
using System;
using System.Runtime.CompilerServices;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// A static class providing extensions
+///
+public static class FloatExtensions
{
///
- /// A static class providing extensions
+ /// Rounds the provided number away to zero and casts the result to an
///
- public static class FloatExtensions
+ /// The number to round
+ /// The rounded number as an integer
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static int RoundToInt(this float number)
{
- ///
- /// Rounds the provided number away to zero and casts the result to an
- ///
- /// The number to round
- /// The rounded number as an integer
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static int RoundToInt(this float number)
- {
- return (int) MathF.Round(number, MidpointRounding.AwayFromZero);
- }
+ return (int) MathF.Round(number, MidpointRounding.AwayFromZero);
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Extensions/IEnumerableExtensions.cs b/src/Artemis.Core/Extensions/IEnumerableExtensions.cs
index 111851187..5504bfe11 100644
--- a/src/Artemis.Core/Extensions/IEnumerableExtensions.cs
+++ b/src/Artemis.Core/Extensions/IEnumerableExtensions.cs
@@ -19,35 +19,33 @@
#endregion
-using System;
using System.Collections.Generic;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// A static class providing extensions
+///
+// ReSharper disable once InconsistentNaming
+public static class IEnumerableExtensions
{
///
- /// A static class providing extensions
+ /// Returns the index of the provided element inside the read only collection
///
- // ReSharper disable once InconsistentNaming
- public static class IEnumerableExtensions
+ /// The type of element to find
+ /// The collection to search in
+ /// The element to find
+ /// If found, the index of the element to find; otherwise -1
+ public static int IndexOf(this IReadOnlyCollection self, T elementToFind)
{
- ///
- /// Returns the index of the provided element inside the read only collection
- ///
- /// The type of element to find
- /// The collection to search in
- /// The element to find
- /// If found, the index of the element to find; otherwise -1
- public static int IndexOf(this IReadOnlyCollection self, T elementToFind)
+ int i = 0;
+ foreach (T element in self)
{
- int i = 0;
- foreach (T element in self)
- {
- if (Equals(element, elementToFind))
- return i;
- i++;
- }
-
- return -1;
+ if (Equals(element, elementToFind))
+ return i;
+ i++;
}
+
+ return -1;
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Extensions/ProcessExtensions.cs b/src/Artemis.Core/Extensions/ProcessExtensions.cs
index 8b9ee1213..27475a988 100644
--- a/src/Artemis.Core/Extensions/ProcessExtensions.cs
+++ b/src/Artemis.Core/Extensions/ProcessExtensions.cs
@@ -1,41 +1,41 @@
using System;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Text;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// A static class providing extensions
+///
+[SuppressMessage("Design", "CA1060:Move pinvokes to native methods class", Justification = "I don't care, piss off")]
+public static class ProcessExtensions
{
///
- /// A static class providing extensions
+ /// Gets the file name of the given process
///
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1060:Move pinvokes to native methods class", Justification = "I don't care, piss off")]
- public static class ProcessExtensions
+ /// The process
+ /// The filename of the given process
+ public static string GetProcessFilename(this Process p)
{
- ///
- /// Gets the file name of the given process
- ///
- /// The process
- /// The filename of the given process
- public static string GetProcessFilename(this Process p)
- {
- int capacity = 2000;
- StringBuilder builder = new(capacity);
- IntPtr ptr = OpenProcess(ProcessAccessFlags.QueryLimitedInformation, false, p.Id);
- if (!QueryFullProcessImageName(ptr, 0, builder, ref capacity)) return string.Empty;
+ int capacity = 2000;
+ StringBuilder builder = new(capacity);
+ IntPtr ptr = OpenProcess(ProcessAccessFlags.QueryLimitedInformation, false, p.Id);
+ if (!QueryFullProcessImageName(ptr, 0, builder, ref capacity)) return string.Empty;
- return builder.ToString();
- }
+ return builder.ToString();
+ }
- [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
- private static extern bool QueryFullProcessImageName([In] IntPtr hProcess, [In] int dwFlags, [Out] StringBuilder lpExeName, ref int lpdwSize);
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ private static extern bool QueryFullProcessImageName([In] IntPtr hProcess, [In] int dwFlags, [Out] StringBuilder lpExeName, ref int lpdwSize);
- [DllImport("kernel32.dll")]
- private static extern IntPtr OpenProcess(ProcessAccessFlags processAccess, bool bInheritHandle, int processId);
+ [DllImport("kernel32.dll")]
+ private static extern IntPtr OpenProcess(ProcessAccessFlags processAccess, bool bInheritHandle, int processId);
- [Flags]
- private enum ProcessAccessFlags : uint
- {
- QueryLimitedInformation = 0x00001000
- }
+ [Flags]
+ private enum ProcessAccessFlags : uint
+ {
+ QueryLimitedInformation = 0x00001000
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Extensions/RgbDeviceExtensions.cs b/src/Artemis.Core/Extensions/RgbDeviceExtensions.cs
index c6139f30c..11871df5c 100644
--- a/src/Artemis.Core/Extensions/RgbDeviceExtensions.cs
+++ b/src/Artemis.Core/Extensions/RgbDeviceExtensions.cs
@@ -2,39 +2,38 @@
using RGB.NET.Core;
using SkiaSharp;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+internal static class RgbDeviceExtensions
{
- internal static class RgbDeviceExtensions
+ public static string GetDeviceIdentifier(this IRGBDevice rgbDevice)
{
- public static string GetDeviceIdentifier(this IRGBDevice rgbDevice)
- {
- StringBuilder builder = new();
- builder.Append(rgbDevice.DeviceInfo.DeviceName);
- builder.Append('-');
- builder.Append(rgbDevice.DeviceInfo.Manufacturer);
- builder.Append('-');
- builder.Append(rgbDevice.DeviceInfo.Model);
- builder.Append('-');
- builder.Append(rgbDevice.DeviceInfo.DeviceType);
- return builder.ToString();
- }
+ StringBuilder builder = new();
+ builder.Append(rgbDevice.DeviceInfo.DeviceName);
+ builder.Append('-');
+ builder.Append(rgbDevice.DeviceInfo.Manufacturer);
+ builder.Append('-');
+ builder.Append(rgbDevice.DeviceInfo.Model);
+ builder.Append('-');
+ builder.Append(rgbDevice.DeviceInfo.DeviceType);
+ return builder.ToString();
+ }
+}
+
+internal static class RgbRectangleExtensions
+{
+ public static SKRect ToSKRect(this Rectangle rectangle)
+ {
+ return SKRect.Create(
+ rectangle.Location.X,
+ rectangle.Location.Y,
+ rectangle.Size.Width,
+ rectangle.Size.Height
+ );
}
- internal static class RgbRectangleExtensions
+ public static SKRectI ToSKRectI(this Rectangle rectangle)
{
- public static SKRect ToSKRect(this Rectangle rectangle)
- {
- return SKRect.Create(
- rectangle.Location.X,
- rectangle.Location.Y,
- rectangle.Size.Width,
- rectangle.Size.Height
- );
- }
-
- public static SKRectI ToSKRectI(this Rectangle rectangle)
- {
- return SKRectI.Round(ToSKRect(rectangle));
- }
+ return SKRectI.Round(ToSKRect(rectangle));
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Extensions/SKColorExtensions.cs b/src/Artemis.Core/Extensions/SKColorExtensions.cs
index f1e9297ec..b18e35e0f 100644
--- a/src/Artemis.Core/Extensions/SKColorExtensions.cs
+++ b/src/Artemis.Core/Extensions/SKColorExtensions.cs
@@ -2,77 +2,76 @@
using RGB.NET.Core;
using SkiaSharp;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// A static class providing extensions
+///
+public static class SKColorExtensions
{
///
- /// A static class providing extensions
+ /// Converts hte SKColor to an RGB.NET color
///
- public static class SKColorExtensions
+ /// The color to convert
+ /// The RGB.NET color
+ public static Color ToRgbColor(this SKColor color)
{
- ///
- /// Converts hte SKColor to an RGB.NET color
- ///
- /// The color to convert
- /// The RGB.NET color
- public static Color ToRgbColor(this SKColor color)
- {
- return new Color(color.Alpha, color.Red, color.Green, color.Blue);
- }
+ return new Color(color.Alpha, color.Red, color.Green, color.Blue);
+ }
- ///
- /// Interpolates a color between the and color.
- ///
- /// The first color
- /// The second color
- /// A value between 0 and 1
- /// The interpolated color
- public static SKColor Interpolate(this SKColor from, SKColor to, float progress)
- {
- int redDiff = to.Red - from.Red;
- int greenDiff = to.Green - from.Green;
- int blueDiff = to.Blue - from.Blue;
- int alphaDiff = to.Alpha - from.Alpha;
+ ///
+ /// Interpolates a color between the and color.
+ ///
+ /// The first color
+ /// The second color
+ /// A value between 0 and 1
+ /// The interpolated color
+ public static SKColor Interpolate(this SKColor from, SKColor to, float progress)
+ {
+ int redDiff = to.Red - from.Red;
+ int greenDiff = to.Green - from.Green;
+ int blueDiff = to.Blue - from.Blue;
+ int alphaDiff = to.Alpha - from.Alpha;
- return new SKColor(
- ClampToByte(from.Red + redDiff * progress),
- ClampToByte(from.Green + greenDiff * progress),
- ClampToByte(from.Blue + blueDiff * progress),
- ClampToByte(from.Alpha + alphaDiff * progress)
- );
- }
+ return new SKColor(
+ ClampToByte(from.Red + redDiff * progress),
+ ClampToByte(from.Green + greenDiff * progress),
+ ClampToByte(from.Blue + blueDiff * progress),
+ ClampToByte(from.Alpha + alphaDiff * progress)
+ );
+ }
- ///
- /// Adds the two colors together
- ///
- /// The first color
- /// The second color
- /// The sum of the two colors
- public static SKColor Sum(this SKColor a, SKColor b)
- {
- return new SKColor(
- ClampToByte(a.Red + b.Red),
- ClampToByte(a.Green + b.Green),
- ClampToByte(a.Blue + b.Blue),
- ClampToByte(a.Alpha + b.Alpha)
- );
- }
+ ///
+ /// Adds the two colors together
+ ///
+ /// The first color
+ /// The second color
+ /// The sum of the two colors
+ public static SKColor Sum(this SKColor a, SKColor b)
+ {
+ return new SKColor(
+ ClampToByte(a.Red + b.Red),
+ ClampToByte(a.Green + b.Green),
+ ClampToByte(a.Blue + b.Blue),
+ ClampToByte(a.Alpha + b.Alpha)
+ );
+ }
- ///
- /// Darkens the color by the specified amount
- ///
- /// The color to darken
- /// The brightness of the new color
- /// The darkened color
- public static SKColor Darken(this SKColor c, float amount)
- {
- c.ToHsl(out float h, out float s, out float l);
- l *= 1f - amount;
- return SKColor.FromHsl(h, s, l);
- }
+ ///
+ /// Darkens the color by the specified amount
+ ///
+ /// The color to darken
+ /// The brightness of the new color
+ /// The darkened color
+ public static SKColor Darken(this SKColor c, float amount)
+ {
+ c.ToHsl(out float h, out float s, out float l);
+ l *= 1f - amount;
+ return SKColor.FromHsl(h, s, l);
+ }
- private static byte ClampToByte(float value)
- {
- return (byte) Math.Clamp(value, 0, 255);
- }
+ private static byte ClampToByte(float value)
+ {
+ return (byte) Math.Clamp(value, 0, 255);
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Extensions/SKPaintExtensions.cs b/src/Artemis.Core/Extensions/SKPaintExtensions.cs
index ec2ebe6e2..eea179e7a 100644
--- a/src/Artemis.Core/Extensions/SKPaintExtensions.cs
+++ b/src/Artemis.Core/Extensions/SKPaintExtensions.cs
@@ -1,16 +1,15 @@
using SkiaSharp;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+internal static class SKPaintExtensions
{
- internal static class SKPaintExtensions
+ internal static void DisposeSelfAndProperties(this SKPaint paint)
{
- internal static void DisposeSelfAndProperties(this SKPaint paint)
- {
- paint.ImageFilter?.Dispose();
- paint.ColorFilter?.Dispose();
- paint.MaskFilter?.Dispose();
- paint.Shader?.Dispose();
- paint.Dispose();
- }
+ paint.ImageFilter?.Dispose();
+ paint.ColorFilter?.Dispose();
+ paint.MaskFilter?.Dispose();
+ paint.Shader?.Dispose();
+ paint.Dispose();
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Extensions/StreamExtensions.cs b/src/Artemis.Core/Extensions/StreamExtensions.cs
index a6b350fd2..cc33dbaa3 100644
--- a/src/Artemis.Core/Extensions/StreamExtensions.cs
+++ b/src/Artemis.Core/Extensions/StreamExtensions.cs
@@ -25,110 +25,108 @@
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
-using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+internal static class StreamExtensions
{
- internal static class StreamExtensions
+ private const int DefaultBufferSize = 81920;
+
+ ///
+ /// Copies a stream to another stream
+ ///
+ /// The source to copy from
+ /// The length of the source stream, if known - used for progress reporting
+ /// The destination to copy to
+ /// The size of the copy block buffer
+ /// An implementation for reporting progress
+ /// A cancellation token
+ /// A task representing the operation
+ public static async Task CopyToAsync(
+ this Stream source,
+ long sourceLength,
+ Stream destination,
+ int bufferSize,
+ IProgress<(long, long)> progress,
+ CancellationToken cancellationToken)
{
- private const int DefaultBufferSize = 81920;
+ if (source == null)
+ throw new ArgumentNullException(nameof(source));
+ if (!source.CanRead)
+ throw new ArgumentException("Has to be readable", nameof(source));
+ if (destination == null)
+ throw new ArgumentNullException(nameof(destination));
+ if (!destination.CanWrite)
+ throw new ArgumentException("Has to be writable", nameof(destination));
+ if (bufferSize <= 0)
+ bufferSize = DefaultBufferSize;
- ///
- /// Copies a stream to another stream
- ///
- /// The source to copy from
- /// The length of the source stream, if known - used for progress reporting
- /// The destination to copy to
- /// The size of the copy block buffer
- /// An implementation for reporting progress
- /// A cancellation token
- /// A task representing the operation
- public static async Task CopyToAsync(
- this Stream source,
- long sourceLength,
- Stream destination,
- int bufferSize,
- IProgress<(long, long)> progress,
- CancellationToken cancellationToken)
+ byte[] buffer = new byte[bufferSize];
+ long totalBytesRead = 0;
+ int bytesRead;
+ while ((bytesRead = await source.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) != 0)
{
- if (source == null)
- throw new ArgumentNullException(nameof(source));
- if (!source.CanRead)
- throw new ArgumentException("Has to be readable", nameof(source));
- if (destination == null)
- throw new ArgumentNullException(nameof(destination));
- if (!destination.CanWrite)
- throw new ArgumentException("Has to be writable", nameof(destination));
- if (bufferSize <= 0)
- bufferSize = DefaultBufferSize;
-
- byte[] buffer = new byte[bufferSize];
- long totalBytesRead = 0;
- int bytesRead;
- while ((bytesRead = await source.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) != 0)
- {
- await destination.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false);
- totalBytesRead += bytesRead;
- progress?.Report((totalBytesRead, sourceLength));
- }
-
+ await destination.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false);
+ totalBytesRead += bytesRead;
progress?.Report((totalBytesRead, sourceLength));
- cancellationToken.ThrowIfCancellationRequested();
}
- ///
- /// Copies a stream to another stream
- ///
- /// The source to copy from
- /// The length of the source stream, if known - used for progress reporting
- /// The destination to copy to
- /// An implementation for reporting progress
- /// A cancellation token
- /// A task representing the operation
- public static Task CopyToAsync(this Stream source, long sourceLength, Stream destination, IProgress<(long, long)> progress, CancellationToken cancellationToken)
- {
- return CopyToAsync(source, sourceLength, destination, 0, progress, cancellationToken);
- }
+ progress?.Report((totalBytesRead, sourceLength));
+ cancellationToken.ThrowIfCancellationRequested();
+ }
- ///
- /// Copies a stream to another stream
- ///
- /// The source to copy from
- /// The destination to copy to
- /// An implementation for reporting progress
- /// A cancellation token
- /// A task representing the operation
- public static Task CopyToAsync(this Stream source, Stream destination, IProgress<(long, long)> progress, CancellationToken cancellationToken)
- {
- return CopyToAsync(source, 0L, destination, 0, progress, cancellationToken);
- }
+ ///
+ /// Copies a stream to another stream
+ ///
+ /// The source to copy from
+ /// The length of the source stream, if known - used for progress reporting
+ /// The destination to copy to
+ /// An implementation for reporting progress
+ /// A cancellation token
+ /// A task representing the operation
+ public static Task CopyToAsync(this Stream source, long sourceLength, Stream destination, IProgress<(long, long)> progress, CancellationToken cancellationToken)
+ {
+ return CopyToAsync(source, sourceLength, destination, 0, progress, cancellationToken);
+ }
- ///
- /// Copies a stream to another stream
- ///
- /// The source to copy from
- /// The length of the source stream, if known - used for progress reporting
- /// The destination to copy to
- /// An implementation for reporting progress
- /// A task representing the operation
- public static Task CopyToAsync(this Stream source, long sourceLength, Stream destination, IProgress<(long, long)> progress)
- {
- return CopyToAsync(source, sourceLength, destination, 0, progress, default);
- }
+ ///
+ /// Copies a stream to another stream
+ ///
+ /// The source to copy from
+ /// The destination to copy to
+ /// An implementation for reporting progress
+ /// A cancellation token
+ /// A task representing the operation
+ public static Task CopyToAsync(this Stream source, Stream destination, IProgress<(long, long)> progress, CancellationToken cancellationToken)
+ {
+ return CopyToAsync(source, 0L, destination, 0, progress, cancellationToken);
+ }
- ///
- /// Copies a stream to another stream
- ///
- /// The source to copy from
- /// The destination to copy to
- /// An implementation for reporting progress
- /// A task representing the operation
- public static Task CopyToAsync(this Stream source, Stream destination, IProgress<(long, long)> progress)
- {
- return CopyToAsync(source, 0L, destination, 0, progress, default);
- }
+ ///
+ /// Copies a stream to another stream
+ ///
+ /// The source to copy from
+ /// The length of the source stream, if known - used for progress reporting
+ /// The destination to copy to
+ /// An implementation for reporting progress
+ /// A task representing the operation
+ public static Task CopyToAsync(this Stream source, long sourceLength, Stream destination, IProgress<(long, long)> progress)
+ {
+ return CopyToAsync(source, sourceLength, destination, 0, progress, default);
+ }
+
+ ///
+ /// Copies a stream to another stream
+ ///
+ /// The source to copy from
+ /// The destination to copy to
+ /// An implementation for reporting progress
+ /// A task representing the operation
+ public static Task CopyToAsync(this Stream source, Stream destination, IProgress<(long, long)> progress)
+ {
+ return CopyToAsync(source, 0L, destination, 0, progress, default);
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Extensions/TypeExtensions.cs b/src/Artemis.Core/Extensions/TypeExtensions.cs
index ed5c5e36e..9e6ba83e3 100644
--- a/src/Artemis.Core/Extensions/TypeExtensions.cs
+++ b/src/Artemis.Core/Extensions/TypeExtensions.cs
@@ -5,249 +5,250 @@ using System.Linq;
using System.Reflection;
using Humanizer;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// A static class providing extensions
+///
+public static class TypeExtensions
{
- ///
- /// A static class providing extensions
- ///
- public static class TypeExtensions
+ private static readonly Dictionary> PrimitiveTypeConversions = new()
{
- private static readonly Dictionary> PrimitiveTypeConversions = new()
- {
- {typeof(decimal), new List {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(char)}},
- {typeof(double), new List {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(char), typeof(float)}},
- {typeof(float), new List {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(char), typeof(float)}},
- {typeof(ulong), new List {typeof(byte), typeof(ushort), typeof(uint), typeof(char)}},
- {typeof(long), new List {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(char)}},
- {typeof(uint), new List {typeof(byte), typeof(ushort), typeof(char)}},
- {typeof(int), new List {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(char)}},
- {typeof(ushort), new List {typeof(byte), typeof(char)}},
- {typeof(short), new List {typeof(byte)}}
- };
+ {typeof(decimal), new List {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(char)}},
+ {typeof(double), new List {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(char), typeof(float)}},
+ {typeof(float), new List {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(char), typeof(float)}},
+ {typeof(ulong), new List {typeof(byte), typeof(ushort), typeof(uint), typeof(char)}},
+ {typeof(long), new List {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(char)}},
+ {typeof(uint), new List {typeof(byte), typeof(ushort), typeof(char)}},
+ {typeof(int), new List {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(char)}},
+ {typeof(ushort), new List {typeof(byte), typeof(char)}},
+ {typeof(short), new List {typeof(byte)}}
+ };
- private static readonly Dictionary TypeKeywords = new()
- {
- {typeof(bool), "bool"},
- {typeof(byte), "byte"},
- {typeof(sbyte), "sbyte"},
- {typeof(char), "char"},
- {typeof(decimal), "decimal"},
- {typeof(double), "double"},
- {typeof(float), "float"},
- {typeof(int), "int"},
- {typeof(uint), "uint"},
- {typeof(long), "long"},
- {typeof(ulong), "ulong"},
- {typeof(short), "short"},
- {typeof(ushort), "ushort"},
- {typeof(object), "object"},
- {typeof(string), "string"}
- };
+ private static readonly Dictionary TypeKeywords = new()
+ {
+ {typeof(bool), "bool"},
+ {typeof(byte), "byte"},
+ {typeof(sbyte), "sbyte"},
+ {typeof(char), "char"},
+ {typeof(decimal), "decimal"},
+ {typeof(double), "double"},
+ {typeof(float), "float"},
+ {typeof(int), "int"},
+ {typeof(uint), "uint"},
+ {typeof(long), "long"},
+ {typeof(ulong), "ulong"},
+ {typeof(short), "short"},
+ {typeof(ushort), "ushort"},
+ {typeof(object), "object"},
+ {typeof(string), "string"}
+ };
- ///
- /// Determines whether the provided type is of a specified generic type
- ///
- /// The type to check
- /// The generic type to match
- /// True if the is generic and of generic type
- public static bool IsGenericType(this Type? type, Type genericType)
- {
- if (type == null)
- return false;
+ ///
+ /// Determines whether the provided type is of a specified generic type
+ ///
+ /// The type to check
+ /// The generic type to match
+ /// True if the is generic and of generic type
+ public static bool IsGenericType(this Type? type, Type genericType)
+ {
+ if (type == null)
+ return false;
- return type.BaseType?.GetGenericTypeDefinition() == genericType;
- }
+ return type.BaseType?.GetGenericTypeDefinition() == genericType;
+ }
- ///
- /// Determines whether the provided type is a struct
- ///
- /// The type to check
- /// if the type is a struct, otherwise
- public static bool IsStruct(this Type type)
- {
- return type.IsValueType && !type.IsPrimitive && !type.IsEnum;
- }
+ ///
+ /// Determines whether the provided type is a struct
+ ///
+ /// The type to check
+ /// if the type is a struct, otherwise
+ public static bool IsStruct(this Type type)
+ {
+ return type.IsValueType && !type.IsPrimitive && !type.IsEnum;
+ }
- ///
- /// Determines whether the provided type is any kind of numeric type
- ///
- /// The type to check
- /// if the type a numeric type, otherwise
- public static bool TypeIsNumber(this Type type)
- {
- return type == typeof(sbyte)
- || type == typeof(byte)
- || type == typeof(short)
- || type == typeof(ushort)
- || type == typeof(int)
- || type == typeof(uint)
- || type == typeof(long)
- || type == typeof(ulong)
- || type == typeof(float)
- || type == typeof(double)
- || type == typeof(decimal);
- }
+ ///
+ /// Determines whether the provided type is any kind of numeric type
+ ///
+ /// The type to check
+ /// if the type a numeric type, otherwise
+ public static bool TypeIsNumber(this Type type)
+ {
+ return type == typeof(sbyte)
+ || type == typeof(byte)
+ || type == typeof(short)
+ || type == typeof(ushort)
+ || type == typeof(int)
+ || type == typeof(uint)
+ || type == typeof(long)
+ || type == typeof(ulong)
+ || type == typeof(float)
+ || type == typeof(double)
+ || type == typeof(decimal);
+ }
- ///
- /// Determines whether the provided value is any kind of numeric type
- ///
- /// The value to check
- /// if the value is of a numeric type, otherwise
- public static bool IsNumber([NotNullWhenAttribute(true)] this object? value)
- {
- return value is sbyte or byte or short or ushort or int or uint or long or ulong or float or double or decimal;
- }
+ ///
+ /// Determines whether the provided value is any kind of numeric type
+ ///
+ /// The value to check
+ /// if the value is of a numeric type, otherwise
+ public static bool IsNumber([NotNullWhenAttribute(true)] this object? value)
+ {
+ return value is sbyte or byte or short or ushort or int or uint or long or ulong or float or double or decimal;
+ }
- // From https://stackoverflow.com/a/2224421/5015269 but inverted and renamed to match similar framework methods
- ///
- /// Determines whether an instance of a specified type can be casted to a variable of the current type
- ///
- ///
- public static bool IsCastableFrom(this Type to, Type from)
- {
- if (to.TypeIsNumber() && from.TypeIsNumber())
- return true;
- if (to.IsAssignableFrom(from))
- return true;
- if (PrimitiveTypeConversions.ContainsKey(to) && PrimitiveTypeConversions[to].Contains(from))
- return true;
- bool castable = from.GetMethods(BindingFlags.Public | BindingFlags.Static)
- .Any(m => m.ReturnType == to && (m.Name == "op_Implicit" || m.Name == "op_Explicit"));
- return castable;
- }
+ // From https://stackoverflow.com/a/2224421/5015269 but inverted and renamed to match similar framework methods
+ ///
+ /// Determines whether an instance of a specified type can be casted to a variable of the current type
+ ///
+ ///
+ public static bool IsCastableFrom(this Type to, Type from)
+ {
+ if (to.TypeIsNumber() && from.TypeIsNumber())
+ return true;
+ if (to.IsAssignableFrom(from))
+ return true;
+ if (PrimitiveTypeConversions.ContainsKey(to) && PrimitiveTypeConversions[to].Contains(from))
+ return true;
+ bool castable = from.GetMethods(BindingFlags.Public | BindingFlags.Static)
+ .Any(m => m.ReturnType == to && (m.Name == "op_Implicit" || m.Name == "op_Explicit"));
+ return castable;
+ }
- ///
- /// Scores how well the two types can be casted from one to another, 5 being a perfect match and 0 being not castable
- /// at all
- ///
- ///
- public static int ScoreCastability(this Type to, Type? from)
- {
- if (from == null)
- return 0;
-
- if (to == from)
- return 5;
- if (to.TypeIsNumber() && from.TypeIsNumber())
- return 4;
- if (PrimitiveTypeConversions.ContainsKey(to) && PrimitiveTypeConversions[to].Contains(from))
- return 3;
- bool castable = from.GetMethods(BindingFlags.Public | BindingFlags.Static)
- .Any(m => m.ReturnType == to && (m.Name == "op_Implicit" || m.Name == "op_Explicit"));
- if (castable)
- return 2;
- if (to.IsAssignableFrom(from))
- return 1;
+ ///
+ /// Scores how well the two types can be casted from one to another, 5 being a perfect match and 0 being not castable
+ /// at all
+ ///
+ ///
+ public static int ScoreCastability(this Type to, Type? from)
+ {
+ if (from == null)
return 0;
+
+ if (to == from)
+ return 5;
+ if (to.TypeIsNumber() && from.TypeIsNumber())
+ return 4;
+ if (PrimitiveTypeConversions.ContainsKey(to) && PrimitiveTypeConversions[to].Contains(from))
+ return 3;
+ bool castable = from.GetMethods(BindingFlags.Public | BindingFlags.Static)
+ .Any(m => m.ReturnType == to && (m.Name == "op_Implicit" || m.Name == "op_Explicit"));
+ if (castable)
+ return 2;
+ if (to.IsAssignableFrom(from))
+ return 1;
+ return 0;
+ }
+
+ ///
+ /// Returns the default value of the given type
+ ///
+ public static object? GetDefault(this Type type)
+ {
+ return type.IsValueType ? Activator.CreateInstance(type) : null;
+ }
+
+ ///
+ /// Determines whether the given type is a generic enumerable
+ ///
+ public static bool IsGenericEnumerable(this Type type)
+ {
+ // String is an IEnumerable to be fair, but not for us
+ if (type == typeof(string))
+ return false;
+ // It may actually be one instead of implementing one ;)
+ if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
+ return true;
+
+ return type.GetInterfaces().Any(x =>
+ x.IsGenericType &&
+ x.GetGenericTypeDefinition() == typeof(IEnumerable<>));
+ }
+
+ ///
+ /// Determines the type of the provided generic enumerable type
+ ///
+ public static Type? GetGenericEnumerableType(this Type type)
+ {
+ // It may actually be one instead of implementing one ;)
+ if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
+ return type.GenericTypeArguments[0];
+
+ Type? enumerableType = type.GetInterfaces().FirstOrDefault(x =>
+ x.IsGenericType &&
+ x.GetGenericTypeDefinition() == typeof(IEnumerable<>));
+
+ return enumerableType?.GenericTypeArguments[0];
+ }
+
+ ///
+ /// Determines if the is of a certain .
+ ///
+ /// The type to check.
+ /// The generic type it should be or implement
+ public static bool IsOfGenericType(this Type typeToCheck, Type genericType)
+ {
+ return typeToCheck.IsOfGenericType(genericType, out Type? _);
+ }
+
+ ///
+ /// Determines a display name for the given type
+ ///
+ /// The type to determine the name for
+ /// Whether or not to humanize the result, defaults to false
+ ///
+ public static string GetDisplayName(this Type type, bool humanize = false)
+ {
+ if (!type.IsGenericType)
+ {
+ string displayValue = TypeKeywords.TryGetValue(type, out string? keyword) ? keyword! : type.Name;
+ return humanize ? displayValue.Humanize() : displayValue;
}
- ///
- /// Returns the default value of the given type
- ///
- public static object? GetDefault(this Type type)
- {
- return type.IsValueType ? Activator.CreateInstance(type) : null;
- }
+ Type genericTypeDefinition = type.GetGenericTypeDefinition();
+ if (genericTypeDefinition == typeof(Nullable<>))
+ return type.GenericTypeArguments[0].GetDisplayName(humanize) + "?";
- ///
- /// Determines whether the given type is a generic enumerable
- ///
- public static bool IsGenericEnumerable(this Type type)
+ string stripped = genericTypeDefinition.Name.Split('`')[0];
+ return $"{stripped}<{string.Join(", ", type.GenericTypeArguments.Select(t => t.GetDisplayName(humanize)))}>";
+ }
+
+ private static bool IsOfGenericType(this Type? typeToCheck, Type genericType, out Type? concreteGenericType)
+ {
+ while (true)
{
- // String is an IEnumerable to be fair, but not for us
- if (type == typeof(string))
+ concreteGenericType = null;
+
+ if (genericType == null)
+ throw new ArgumentNullException(nameof(genericType));
+
+ if (!genericType.IsGenericTypeDefinition)
+ throw new ArgumentException("The definition needs to be a GenericTypeDefinition", nameof(genericType));
+
+ if (typeToCheck == null || typeToCheck == typeof(object))
return false;
- // It may actually be one instead of implementing one ;)
- if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
+
+ if (typeToCheck == genericType)
+ {
+ concreteGenericType = typeToCheck;
return true;
-
- return type.GetInterfaces().Any(x =>
- x.IsGenericType &&
- x.GetGenericTypeDefinition() == typeof(IEnumerable<>));
- }
-
- ///
- /// Determines the type of the provided generic enumerable type
- ///
- public static Type? GetGenericEnumerableType(this Type type)
- {
- // It may actually be one instead of implementing one ;)
- if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
- return type.GenericTypeArguments[0];
-
- Type? enumerableType = type.GetInterfaces().FirstOrDefault(x =>
- x.IsGenericType &&
- x.GetGenericTypeDefinition() == typeof(IEnumerable<>));
-
- return enumerableType?.GenericTypeArguments[0];
- }
-
- ///
- /// Determines if the is of a certain .
- ///
- /// The type to check.
- /// The generic type it should be or implement
- public static bool IsOfGenericType(this Type typeToCheck, Type genericType)
- {
- return typeToCheck.IsOfGenericType(genericType, out Type? _);
- }
-
- private static bool IsOfGenericType(this Type? typeToCheck, Type genericType, out Type? concreteGenericType)
- {
- while (true)
- {
- concreteGenericType = null;
-
- if (genericType == null)
- throw new ArgumentNullException(nameof(genericType));
-
- if (!genericType.IsGenericTypeDefinition)
- throw new ArgumentException("The definition needs to be a GenericTypeDefinition", nameof(genericType));
-
- if (typeToCheck == null || typeToCheck == typeof(object))
- return false;
-
- if (typeToCheck == genericType)
- {
- concreteGenericType = typeToCheck;
- return true;
- }
-
- if ((typeToCheck.IsGenericType ? typeToCheck.GetGenericTypeDefinition() : typeToCheck) == genericType)
- {
- concreteGenericType = typeToCheck;
- return true;
- }
-
- if (genericType.IsInterface)
- foreach (Type i in typeToCheck.GetInterfaces())
- if (i.IsOfGenericType(genericType, out concreteGenericType))
- return true;
-
- typeToCheck = typeToCheck.BaseType;
- }
- }
-
- ///
- /// Determines a display name for the given type
- ///
- /// The type to determine the name for
- /// Whether or not to humanize the result, defaults to false
- ///
- public static string GetDisplayName(this Type type, bool humanize = false)
- {
- if (!type.IsGenericType)
- {
- string displayValue = TypeKeywords.TryGetValue(type, out string? keyword) ? keyword! : type.Name;
- return humanize ? displayValue.Humanize() : displayValue;
}
- Type genericTypeDefinition = type.GetGenericTypeDefinition();
- if (genericTypeDefinition == typeof(Nullable<>))
- return type.GenericTypeArguments[0].GetDisplayName(humanize) + "?";
+ if ((typeToCheck.IsGenericType ? typeToCheck.GetGenericTypeDefinition() : typeToCheck) == genericType)
+ {
+ concreteGenericType = typeToCheck;
+ return true;
+ }
- string stripped = genericTypeDefinition.Name.Split('`')[0];
- return $"{stripped}<{string.Join(", ", type.GenericTypeArguments.Select(t => t.GetDisplayName(humanize)))}>";
+ if (genericType.IsInterface)
+ foreach (Type i in typeToCheck.GetInterfaces())
+ {
+ if (i.IsOfGenericType(genericType, out concreteGenericType))
+ return true;
+ }
+
+ typeToCheck = typeToCheck.BaseType;
}
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/JsonConverters/ForgivingIntConverter.cs b/src/Artemis.Core/JsonConverters/ForgivingIntConverter.cs
index 05845fc2e..c43fa7bf8 100644
--- a/src/Artemis.Core/JsonConverters/ForgivingIntConverter.cs
+++ b/src/Artemis.Core/JsonConverters/ForgivingIntConverter.cs
@@ -2,32 +2,31 @@ using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
-namespace Artemis.Core.JsonConverters
+namespace Artemis.Core.JsonConverters;
+
+///
+/// An int converter that, if required, will round float values
+///
+internal class ForgivingIntConverter : JsonConverter
{
- ///
- /// An int converter that, if required, will round float values
- ///
- internal class ForgivingIntConverter : JsonConverter
+ public override bool CanWrite => false;
+
+ public override void WriteJson(JsonWriter writer, int value, JsonSerializer serializer)
{
- public override bool CanWrite => false;
-
- public override void WriteJson(JsonWriter writer, int value, JsonSerializer serializer)
- {
- throw new NotImplementedException();
- }
-
- public override int ReadJson(JsonReader reader, Type objectType, int existingValue, bool hasExistingValue, JsonSerializer serializer)
- {
- JValue? jsonValue = serializer.Deserialize(reader);
- if (jsonValue == null)
- throw new JsonReaderException("Failed to deserialize forgiving int value");
-
- if (jsonValue.Type == JTokenType.Float)
- return (int) Math.Round(jsonValue.Value());
- if (jsonValue.Type == JTokenType.Integer)
- return jsonValue.Value();
+ throw new NotImplementedException();
+ }
+ public override int ReadJson(JsonReader reader, Type objectType, int existingValue, bool hasExistingValue, JsonSerializer serializer)
+ {
+ JValue? jsonValue = serializer.Deserialize(reader);
+ if (jsonValue == null)
throw new JsonReaderException("Failed to deserialize forgiving int value");
- }
+
+ if (jsonValue.Type == JTokenType.Float)
+ return (int) Math.Round(jsonValue.Value());
+ if (jsonValue.Type == JTokenType.Integer)
+ return jsonValue.Value();
+
+ throw new JsonReaderException("Failed to deserialize forgiving int value");
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/JsonConverters/NumericJsonConverter.cs b/src/Artemis.Core/JsonConverters/NumericJsonConverter.cs
index e2ffd62a0..0dea83b5e 100644
--- a/src/Artemis.Core/JsonConverters/NumericJsonConverter.cs
+++ b/src/Artemis.Core/JsonConverters/NumericJsonConverter.cs
@@ -1,25 +1,24 @@
using System;
using Newtonsoft.Json;
-namespace Artemis.Core.JsonConverters
+namespace Artemis.Core.JsonConverters;
+
+internal class NumericJsonConverter : JsonConverter
{
- internal class NumericJsonConverter : JsonConverter
+ #region Overrides of JsonConverter
+
+ ///
+ public override void WriteJson(JsonWriter writer, Numeric value, JsonSerializer serializer)
{
- #region Overrides of JsonConverter
-
- ///
- public override void WriteJson(JsonWriter writer, Numeric value, JsonSerializer serializer)
- {
- float floatValue = value;
- writer.WriteValue(floatValue);
- }
-
- ///
- public override Numeric ReadJson(JsonReader reader, Type objectType, Numeric existingValue, bool hasExistingValue, JsonSerializer serializer)
- {
- return new Numeric(reader.Value);
- }
-
- #endregion
+ float floatValue = value;
+ writer.WriteValue(floatValue);
}
+
+ ///
+ public override Numeric ReadJson(JsonReader reader, Type objectType, Numeric existingValue, bool hasExistingValue, JsonSerializer serializer)
+ {
+ return new Numeric(reader.Value);
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/src/Artemis.Core/JsonConverters/SKColorConverter.cs b/src/Artemis.Core/JsonConverters/SKColorConverter.cs
index b12e1d7c4..40912c153 100644
--- a/src/Artemis.Core/JsonConverters/SKColorConverter.cs
+++ b/src/Artemis.Core/JsonConverters/SKColorConverter.cs
@@ -2,21 +2,20 @@
using Newtonsoft.Json;
using SkiaSharp;
-namespace Artemis.Core.JsonConverters
+namespace Artemis.Core.JsonConverters;
+
+internal class SKColorConverter : JsonConverter
{
- internal class SKColorConverter : JsonConverter
+ public override void WriteJson(JsonWriter writer, SKColor value, JsonSerializer serializer)
{
- public override void WriteJson(JsonWriter writer, SKColor value, JsonSerializer serializer)
- {
- writer.WriteValue(value.ToString());
- }
+ writer.WriteValue(value.ToString());
+ }
- public override SKColor ReadJson(JsonReader reader, Type objectType, SKColor existingValue, bool hasExistingValue, JsonSerializer serializer)
- {
- if (reader.Value is string value && !string.IsNullOrWhiteSpace(value))
- return SKColor.Parse(value);
+ public override SKColor ReadJson(JsonReader reader, Type objectType, SKColor existingValue, bool hasExistingValue, JsonSerializer serializer)
+ {
+ if (reader.Value is string value && !string.IsNullOrWhiteSpace(value))
+ return SKColor.Parse(value);
- return SKColor.Empty;
- }
+ return SKColor.Empty;
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/JsonConverters/StreamConverter.cs b/src/Artemis.Core/JsonConverters/StreamConverter.cs
index 26e638d0e..7ce3529ee 100644
--- a/src/Artemis.Core/JsonConverters/StreamConverter.cs
+++ b/src/Artemis.Core/JsonConverters/StreamConverter.cs
@@ -2,44 +2,43 @@
using System.IO;
using Newtonsoft.Json;
-namespace Artemis.Core.JsonConverters
+namespace Artemis.Core.JsonConverters;
+
+///
+public class StreamConverter : JsonConverter
{
+ #region Overrides of JsonConverter
+
///
- public class StreamConverter : JsonConverter
+ public override void WriteJson(JsonWriter writer, Stream? value, JsonSerializer serializer)
{
- #region Overrides of JsonConverter
-
- ///
- public override void WriteJson(JsonWriter writer, Stream? value, JsonSerializer serializer)
+ if (value == null)
{
- if (value == null)
- {
- writer.WriteNull();
- return;
- }
-
- using MemoryStream memoryStream = new();
- value.Position = 0;
- value.CopyTo(memoryStream);
- writer.WriteValue(memoryStream.ToArray());
+ writer.WriteNull();
+ return;
}
- ///
- public override Stream? ReadJson(JsonReader reader, Type objectType, Stream? existingValue, bool hasExistingValue, JsonSerializer serializer)
- {
- if (reader.Value is not string base64)
- return null;
-
- if (existingValue == null || !hasExistingValue || !existingValue.CanRead)
- return new MemoryStream(Convert.FromBase64String(base64));
-
- using MemoryStream memoryStream = new(Convert.FromBase64String(base64));
- existingValue.Position = 0;
- memoryStream.CopyTo(existingValue);
- existingValue.Position = 0;
- return existingValue;
- }
-
- #endregion
+ using MemoryStream memoryStream = new();
+ value.Position = 0;
+ value.CopyTo(memoryStream);
+ writer.WriteValue(memoryStream.ToArray());
}
+
+ ///
+ public override Stream? ReadJson(JsonReader reader, Type objectType, Stream? existingValue, bool hasExistingValue, JsonSerializer serializer)
+ {
+ if (reader.Value is not string base64)
+ return null;
+
+ if (existingValue == null || !hasExistingValue || !existingValue.CanRead)
+ return new MemoryStream(Convert.FromBase64String(base64));
+
+ using MemoryStream memoryStream = new(Convert.FromBase64String(base64));
+ existingValue.Position = 0;
+ memoryStream.CopyTo(existingValue);
+ existingValue.Position = 0;
+ return existingValue;
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/src/Artemis.Core/MVVM/CorePropertyChanged.cs b/src/Artemis.Core/MVVM/CorePropertyChanged.cs
index b9bd735e0..8ab50083a 100644
--- a/src/Artemis.Core/MVVM/CorePropertyChanged.cs
+++ b/src/Artemis.Core/MVVM/CorePropertyChanged.cs
@@ -2,73 +2,68 @@
using System.Runtime.CompilerServices;
using Artemis.Core.Properties;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents a basic bindable class which notifies when a property value changes.
+///
+public abstract class CorePropertyChanged : INotifyPropertyChanged
{
///
- /// Represents a basic bindable class which notifies when a property value changes.
+ /// Occurs when a property value changes.
///
- public abstract class CorePropertyChanged : INotifyPropertyChanged
+ public event PropertyChangedEventHandler? PropertyChanged;
+
+ #region Methods
+
+ ///
+ /// Checks if the property already matches the desired value or needs to be updated.
+ ///
+ /// Type of the property.
+ /// Reference to the backing-filed.
+ /// Value to apply.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ protected bool RequiresUpdate(ref T storage, T value)
{
- #region Events
-
- ///
- /// Occurs when a property value changes.
- ///
- public event PropertyChangedEventHandler? PropertyChanged;
-
- #endregion
-
- #region Methods
-
- ///
- /// Checks if the property already matches the desired value or needs to be updated.
- ///
- /// Type of the property.
- /// Reference to the backing-filed.
- /// Value to apply.
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- protected bool RequiresUpdate(ref T storage, T value)
- {
- return !Equals(storage, value);
- }
-
- ///
- /// Checks if the property already matches the desired value and updates it if not.
- ///
- /// Type of the property.
- /// Reference to the backing-filed.
- /// Value to apply.
- ///
- /// Name of the property used to notify listeners. This value is optional
- /// and can be provided automatically when invoked from compilers that support
- /// .
- ///
- /// true if the value was changed, false if the existing value matched the desired value.
- [NotifyPropertyChangedInvocator]
- protected bool SetAndNotify(ref T storage, T value, [CallerMemberName] string? propertyName = null)
- {
- if (!RequiresUpdate(ref storage, value)) return false;
-
- storage = value;
- // ReSharper disable once ExplicitCallerInfoArgument
- OnPropertyChanged(propertyName);
- return true;
- }
-
- ///
- /// Triggers the -event when a a property value has changed.
- ///
- ///
- /// Name of the property used to notify listeners. This value is optional
- /// and can be provided automatically when invoked from compilers that support
- /// .
- ///
- protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
-
- #endregion
+ return !Equals(storage, value);
}
+
+ ///
+ /// Checks if the property already matches the desired value and updates it if not.
+ ///
+ /// Type of the property.
+ /// Reference to the backing-filed.
+ /// Value to apply.
+ ///
+ /// Name of the property used to notify listeners. This value is optional
+ /// and can be provided automatically when invoked from compilers that support
+ /// .
+ ///
+ /// true if the value was changed, false if the existing value matched the desired value.
+ [NotifyPropertyChangedInvocator]
+ protected bool SetAndNotify(ref T storage, T value, [CallerMemberName] string? propertyName = null)
+ {
+ if (!RequiresUpdate(ref storage, value)) return false;
+
+ storage = value;
+ // ReSharper disable once ExplicitCallerInfoArgument
+ OnPropertyChanged(propertyName);
+ return true;
+ }
+
+ ///
+ /// Triggers the -event when a a property value has changed.
+ ///
+ ///
+ /// Name of the property used to notify listeners. This value is optional
+ /// and can be provided automatically when invoked from compilers that support
+ /// .
+ ///
+ protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/BreakableModel.cs b/src/Artemis.Core/Models/BreakableModel.cs
index 97bd761cb..7276b6adb 100644
--- a/src/Artemis.Core/Models/BreakableModel.cs
+++ b/src/Artemis.Core/Models/BreakableModel.cs
@@ -1,92 +1,91 @@
using System;
using System.Collections.Generic;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Provides a default implementation for models that can have a broken state
+///
+public abstract class BreakableModel : CorePropertyChanged, IBreakableModel
{
+ private string? _brokenState;
+ private Exception? _brokenStateException;
+
///
- /// Provides a default implementation for models that can have a broken state
+ /// Invokes the event
///
- public abstract class BreakableModel : CorePropertyChanged, IBreakableModel
+ protected virtual void OnBrokenStateChanged()
{
- private string? _brokenState;
- private Exception? _brokenStateException;
-
- ///
- /// Invokes the event
- ///
- protected virtual void OnBrokenStateChanged()
- {
- BrokenStateChanged?.Invoke(this, EventArgs.Empty);
- }
-
- ///
- public abstract string BrokenDisplayName { get; }
-
- ///
- /// Gets or sets the broken state of this breakable model, if this model is not broken.
- /// Note: If setting this manually you are also responsible for invoking
- ///
- public string? BrokenState
- {
- get => _brokenState;
- set => SetAndNotify(ref _brokenState, value);
- }
-
- ///
- /// Gets or sets the exception that caused the broken state
- /// Note: If setting this manually you are also responsible for invoking
- ///
- public Exception? BrokenStateException
- {
- get => _brokenStateException;
- set => SetAndNotify(ref _brokenStateException, value);
- }
-
- ///
- public bool TryOrBreak(Action action, string breakMessage)
- {
- try
- {
- action();
- ClearBrokenState(breakMessage);
- return true;
- }
- catch (Exception e)
- {
- SetBrokenState(breakMessage, e);
- return false;
- }
- }
-
- ///
- public void SetBrokenState(string state, Exception? exception)
- {
- BrokenState = state ?? throw new ArgumentNullException(nameof(state));
- BrokenStateException = exception;
- OnBrokenStateChanged();
- }
-
- ///
- public void ClearBrokenState(string state)
- {
- if (state == null) throw new ArgumentNullException(nameof(state));
- if (BrokenState == null)
- return;
-
- if (BrokenState != state) return;
- BrokenState = null;
- BrokenStateException = null;
- OnBrokenStateChanged();
- }
-
- ///
- public virtual IEnumerable GetBrokenHierarchy()
- {
- if (BrokenState != null)
- yield return this;
- }
-
- ///
- public event EventHandler? BrokenStateChanged;
+ BrokenStateChanged?.Invoke(this, EventArgs.Empty);
}
+
+ ///
+ public abstract string BrokenDisplayName { get; }
+
+ ///
+ /// Gets or sets the broken state of this breakable model, if this model is not broken.
+ /// Note: If setting this manually you are also responsible for invoking
+ ///
+ public string? BrokenState
+ {
+ get => _brokenState;
+ set => SetAndNotify(ref _brokenState, value);
+ }
+
+ ///
+ /// Gets or sets the exception that caused the broken state
+ /// Note: If setting this manually you are also responsible for invoking
+ ///
+ public Exception? BrokenStateException
+ {
+ get => _brokenStateException;
+ set => SetAndNotify(ref _brokenStateException, value);
+ }
+
+ ///
+ public bool TryOrBreak(Action action, string breakMessage)
+ {
+ try
+ {
+ action();
+ ClearBrokenState(breakMessage);
+ return true;
+ }
+ catch (Exception e)
+ {
+ SetBrokenState(breakMessage, e);
+ return false;
+ }
+ }
+
+ ///
+ public void SetBrokenState(string state, Exception? exception)
+ {
+ BrokenState = state ?? throw new ArgumentNullException(nameof(state));
+ BrokenStateException = exception;
+ OnBrokenStateChanged();
+ }
+
+ ///
+ public void ClearBrokenState(string state)
+ {
+ if (state == null) throw new ArgumentNullException(nameof(state));
+ if (BrokenState == null)
+ return;
+
+ if (BrokenState != state) return;
+ BrokenState = null;
+ BrokenStateException = null;
+ OnBrokenStateChanged();
+ }
+
+ ///
+ public virtual IEnumerable GetBrokenHierarchy()
+ {
+ if (BrokenState != null)
+ yield return this;
+ }
+
+ ///
+ public event EventHandler? BrokenStateChanged;
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/IBreakableModel.cs b/src/Artemis.Core/Models/IBreakableModel.cs
index 88a5762d6..715a5f34e 100644
--- a/src/Artemis.Core/Models/IBreakableModel.cs
+++ b/src/Artemis.Core/Models/IBreakableModel.cs
@@ -1,59 +1,58 @@
using System;
using System.Collections.Generic;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents a model that can have a broken state
+///
+public interface IBreakableModel
{
///
- /// Represents a model that can have a broken state
+ /// Gets the display name of this breakable model
///
- public interface IBreakableModel
- {
- ///
- /// Gets the display name of this breakable model
- ///
- string BrokenDisplayName { get; }
+ string BrokenDisplayName { get; }
- ///
- /// Gets or sets the broken state of this breakable model, if this model is not broken.
- ///
- string? BrokenState { get; set; }
+ ///
+ /// Gets or sets the broken state of this breakable model, if this model is not broken.
+ ///
+ string? BrokenState { get; set; }
- ///
- /// Gets or sets the exception that caused the broken state
- ///
- Exception? BrokenStateException { get; set; }
+ ///
+ /// Gets or sets the exception that caused the broken state
+ ///
+ Exception? BrokenStateException { get; set; }
- ///
- /// Try to execute the provided action. If the action succeeded the broken state is cleared if it matches
- /// , if the action throws an exception and
- /// are set accordingly.
- ///
- /// The action to attempt to execute
- /// The message to clear on succeed or set on failure (exception)
- /// if the action succeeded; otherwise .
- bool TryOrBreak(Action action, string breakMessage);
+ ///
+ /// Try to execute the provided action. If the action succeeded the broken state is cleared if it matches
+ /// , if the action throws an exception and
+ /// are set accordingly.
+ ///
+ /// The action to attempt to execute
+ /// The message to clear on succeed or set on failure (exception)
+ /// if the action succeeded; otherwise .
+ bool TryOrBreak(Action action, string breakMessage);
- ///
- /// Sets the broken state to the provided state and optional exception.
- ///
- /// The state to set the broken state to
- /// The exception that caused the broken state
- public void SetBrokenState(string state, Exception? exception);
+ ///
+ /// Sets the broken state to the provided state and optional exception.
+ ///
+ /// The state to set the broken state to
+ /// The exception that caused the broken state
+ public void SetBrokenState(string state, Exception? exception);
- ///
- /// Clears the broken state and exception if equals .
- ///
- ///
- public void ClearBrokenState(string state);
-
- ///
- /// Returns a list containing all broken models, including self and any children
- ///
- IEnumerable GetBrokenHierarchy();
+ ///
+ /// Clears the broken state and exception if equals .
+ ///
+ ///
+ public void ClearBrokenState(string state);
- ///
- /// Occurs when the broken state of this model changes
- ///
- event EventHandler BrokenStateChanged;
- }
+ ///
+ /// Returns a list containing all broken models, including self and any children
+ ///
+ IEnumerable GetBrokenHierarchy();
+
+ ///
+ /// Occurs when the broken state of this model changes
+ ///
+ event EventHandler BrokenStateChanged;
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/IStorageModel.cs b/src/Artemis.Core/Models/IStorageModel.cs
index ce76eb0cd..cb23af0ff 100644
--- a/src/Artemis.Core/Models/IStorageModel.cs
+++ b/src/Artemis.Core/Models/IStorageModel.cs
@@ -1,18 +1,17 @@
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents a model that can be loaded and saved to persistent storage
+///
+public interface IStorageModel
{
///
- /// Represents a model that can be loaded and saved to persistent storage
+ /// Loads the model from its associated entity
///
- public interface IStorageModel
- {
- ///
- /// Loads the model from its associated entity
- ///
- void Load();
+ void Load();
- ///
- /// Saves the model to its associated entity
- ///
- void Save();
- }
+ ///
+ /// Saves the model to its associated entity
+ ///
+ void Save();
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/IUpdateModel.cs b/src/Artemis.Core/Models/IUpdateModel.cs
index 24c480c73..0fdd1da37 100644
--- a/src/Artemis.Core/Models/IUpdateModel.cs
+++ b/src/Artemis.Core/Models/IUpdateModel.cs
@@ -1,14 +1,13 @@
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents a model that updates using a delta time
+///
+public interface IUpdateModel
{
///
- /// Represents a model that updates using a delta time
+ /// Performs an update on the model
///
- public interface IUpdateModel
- {
- ///
- /// Performs an update on the model
- ///
- /// The timeline to apply during update
- void Update(Timeline timeline);
- }
+ /// The timeline to apply during update
+ void Update(Timeline timeline);
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/AdaptionHints/CategoryAdaptionHint.cs b/src/Artemis.Core/Models/Profile/AdaptionHints/CategoryAdaptionHint.cs
index 18e87f574..1d526f4b0 100644
--- a/src/Artemis.Core/Models/Profile/AdaptionHints/CategoryAdaptionHint.cs
+++ b/src/Artemis.Core/Models/Profile/AdaptionHints/CategoryAdaptionHint.cs
@@ -2,98 +2,97 @@
using System.Linq;
using Artemis.Storage.Entities.Profile.AdaptionHints;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents a hint that adapts layers to a certain category of devices
+///
+public class CategoryAdaptionHint : CorePropertyChanged, IAdaptionHint
{
+ private int _amount;
+ private DeviceCategory _category;
+ private bool _limitAmount;
+ private int _skip;
+
///
- /// Represents a hint that adapts layers to a certain category of devices
+ /// Creates a new instance of the class
///
- public class CategoryAdaptionHint : CorePropertyChanged, IAdaptionHint
+ public CategoryAdaptionHint()
{
- private DeviceCategory _category;
- private int _skip;
- private bool _limitAmount;
- private int _amount;
-
- ///
- /// Creates a new instance of the class
- ///
- public CategoryAdaptionHint()
- {
- }
-
- internal CategoryAdaptionHint(CategoryAdaptionHintEntity entity)
- {
- Category = (DeviceCategory) entity.Category;
- Skip = entity.Skip;
- LimitAmount = entity.LimitAmount;
- Amount = entity.Amount;
- }
-
- ///
- /// Gets or sets the category of devices LEDs will be applied to
- ///
- public DeviceCategory Category
- {
- get => _category;
- set => SetAndNotify(ref _category, value);
- }
-
- ///
- /// Gets or sets the amount of devices to skip
- ///
- public int Skip
- {
- get => _skip;
- set => SetAndNotify(ref _skip, value);
- }
-
- ///
- /// Gets or sets a boolean indicating whether a limited amount of devices should be used
- ///
- public bool LimitAmount
- {
- get => _limitAmount;
- set => SetAndNotify(ref _limitAmount, value);
- }
-
- ///
- /// Gets or sets the amount of devices to limit to if is
- ///
- public int Amount
- {
- get => _amount;
- set => SetAndNotify(ref _amount, value);
- }
-
- ///
- public override string ToString()
- {
- return $"Category adaption - {nameof(Category)}: {Category}, {nameof(Skip)}: {Skip}, {nameof(LimitAmount)}: {LimitAmount}, {nameof(Amount)}: {Amount}";
- }
-
- #region Implementation of IAdaptionHint
-
- ///
- public void Apply(Layer layer, List devices)
- {
- IEnumerable matches = devices
- .Where(d => d.Categories.Contains(Category))
- .OrderBy(d => d.Rectangle.Top)
- .ThenBy(d => d.Rectangle.Left)
- .Skip(Skip);
- if (LimitAmount)
- matches = matches.Take(Amount);
-
- foreach (ArtemisDevice artemisDevice in matches)
- layer.AddLeds(artemisDevice.Leds);
- }
-
- ///
- public IAdaptionHintEntity GetEntry()
- {
- return new CategoryAdaptionHintEntity {Amount = Amount, LimitAmount = LimitAmount, Category = (int) Category, Skip = Skip};
- }
-
- #endregion
}
+
+ internal CategoryAdaptionHint(CategoryAdaptionHintEntity entity)
+ {
+ Category = (DeviceCategory) entity.Category;
+ Skip = entity.Skip;
+ LimitAmount = entity.LimitAmount;
+ Amount = entity.Amount;
+ }
+
+ ///
+ /// Gets or sets the category of devices LEDs will be applied to
+ ///
+ public DeviceCategory Category
+ {
+ get => _category;
+ set => SetAndNotify(ref _category, value);
+ }
+
+ ///
+ /// Gets or sets the amount of devices to skip
+ ///
+ public int Skip
+ {
+ get => _skip;
+ set => SetAndNotify(ref _skip, value);
+ }
+
+ ///
+ /// Gets or sets a boolean indicating whether a limited amount of devices should be used
+ ///
+ public bool LimitAmount
+ {
+ get => _limitAmount;
+ set => SetAndNotify(ref _limitAmount, value);
+ }
+
+ ///
+ /// Gets or sets the amount of devices to limit to if is
+ ///
+ public int Amount
+ {
+ get => _amount;
+ set => SetAndNotify(ref _amount, value);
+ }
+
+ ///
+ public override string ToString()
+ {
+ return $"Category adaption - {nameof(Category)}: {Category}, {nameof(Skip)}: {Skip}, {nameof(LimitAmount)}: {LimitAmount}, {nameof(Amount)}: {Amount}";
+ }
+
+ #region Implementation of IAdaptionHint
+
+ ///
+ public void Apply(Layer layer, List devices)
+ {
+ IEnumerable matches = devices
+ .Where(d => d.Categories.Contains(Category))
+ .OrderBy(d => d.Rectangle.Top)
+ .ThenBy(d => d.Rectangle.Left)
+ .Skip(Skip);
+ if (LimitAmount)
+ matches = matches.Take(Amount);
+
+ foreach (ArtemisDevice artemisDevice in matches)
+ layer.AddLeds(artemisDevice.Leds);
+ }
+
+ ///
+ public IAdaptionHintEntity GetEntry()
+ {
+ return new CategoryAdaptionHintEntity {Amount = Amount, LimitAmount = LimitAmount, Category = (int) Category, Skip = Skip};
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/AdaptionHints/DeviceAdaptionHint.cs b/src/Artemis.Core/Models/Profile/AdaptionHints/DeviceAdaptionHint.cs
index 62ed05b85..d7936bae7 100644
--- a/src/Artemis.Core/Models/Profile/AdaptionHints/DeviceAdaptionHint.cs
+++ b/src/Artemis.Core/Models/Profile/AdaptionHints/DeviceAdaptionHint.cs
@@ -3,98 +3,97 @@ using System.Linq;
using Artemis.Storage.Entities.Profile.AdaptionHints;
using RGB.NET.Core;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents a hint that adapts layers to a certain type of devices
+///
+public class DeviceAdaptionHint : CorePropertyChanged, IAdaptionHint
{
+ private int _amount;
+ private RGBDeviceType _deviceType;
+ private bool _limitAmount;
+ private int _skip;
+
///
- /// Represents a hint that adapts layers to a certain type of devices
+ /// Creates a new instance of the class
///
- public class DeviceAdaptionHint : CorePropertyChanged, IAdaptionHint
+ public DeviceAdaptionHint()
{
- private RGBDeviceType _deviceType;
- private int _skip;
- private bool _limitAmount;
- private int _amount;
-
- ///
- /// Creates a new instance of the class
- ///
- public DeviceAdaptionHint()
- {
- }
-
- internal DeviceAdaptionHint(DeviceAdaptionHintEntity entity)
- {
- DeviceType = (RGBDeviceType) entity.DeviceType;
- Skip = entity.Skip;
- LimitAmount = entity.LimitAmount;
- Amount = entity.Amount;
- }
-
- ///
- /// Gets or sets the type of devices LEDs will be applied to
- ///
- public RGBDeviceType DeviceType
- {
- get => _deviceType;
- set => SetAndNotify(ref _deviceType, value);
- }
-
- ///
- /// Gets or sets the amount of devices to skip
- ///
- public int Skip
- {
- get => _skip;
- set => SetAndNotify(ref _skip, value);
- }
-
- ///
- /// Gets or sets a boolean indicating whether a limited amount of devices should be used
- ///
- public bool LimitAmount
- {
- get => _limitAmount;
- set => SetAndNotify(ref _limitAmount, value);
- }
-
- ///
- /// Gets or sets the amount of devices to limit to if is
- ///
- public int Amount
- {
- get => _amount;
- set => SetAndNotify(ref _amount, value);
- }
-
- #region Implementation of IAdaptionHint
-
- ///
- public void Apply(Layer layer, List devices)
- {
- IEnumerable matches = devices
- .Where(d => DeviceType == RGBDeviceType.All || d.DeviceType == DeviceType)
- .OrderBy(d => d.Rectangle.Top)
- .ThenBy(d => d.Rectangle.Left)
- .Skip(Skip);
- if (LimitAmount)
- matches = matches.Take(Amount);
-
- foreach (ArtemisDevice artemisDevice in matches)
- layer.AddLeds(artemisDevice.Leds);
- }
-
- ///
- public IAdaptionHintEntity GetEntry()
- {
- return new DeviceAdaptionHintEntity {Amount = Amount, LimitAmount = LimitAmount, DeviceType = (int) DeviceType, Skip = Skip};
- }
-
- ///
- public override string ToString()
- {
- return $"Device adaption - {nameof(DeviceType)}: {DeviceType}, {nameof(Skip)}: {Skip}, {nameof(LimitAmount)}: {LimitAmount}, {nameof(Amount)}: {Amount}";
- }
-
- #endregion
}
+
+ internal DeviceAdaptionHint(DeviceAdaptionHintEntity entity)
+ {
+ DeviceType = (RGBDeviceType) entity.DeviceType;
+ Skip = entity.Skip;
+ LimitAmount = entity.LimitAmount;
+ Amount = entity.Amount;
+ }
+
+ ///
+ /// Gets or sets the type of devices LEDs will be applied to
+ ///
+ public RGBDeviceType DeviceType
+ {
+ get => _deviceType;
+ set => SetAndNotify(ref _deviceType, value);
+ }
+
+ ///
+ /// Gets or sets the amount of devices to skip
+ ///
+ public int Skip
+ {
+ get => _skip;
+ set => SetAndNotify(ref _skip, value);
+ }
+
+ ///
+ /// Gets or sets a boolean indicating whether a limited amount of devices should be used
+ ///
+ public bool LimitAmount
+ {
+ get => _limitAmount;
+ set => SetAndNotify(ref _limitAmount, value);
+ }
+
+ ///
+ /// Gets or sets the amount of devices to limit to if is
+ ///
+ public int Amount
+ {
+ get => _amount;
+ set => SetAndNotify(ref _amount, value);
+ }
+
+ #region Implementation of IAdaptionHint
+
+ ///
+ public void Apply(Layer layer, List devices)
+ {
+ IEnumerable matches = devices
+ .Where(d => DeviceType == RGBDeviceType.All || d.DeviceType == DeviceType)
+ .OrderBy(d => d.Rectangle.Top)
+ .ThenBy(d => d.Rectangle.Left)
+ .Skip(Skip);
+ if (LimitAmount)
+ matches = matches.Take(Amount);
+
+ foreach (ArtemisDevice artemisDevice in matches)
+ layer.AddLeds(artemisDevice.Leds);
+ }
+
+ ///
+ public IAdaptionHintEntity GetEntry()
+ {
+ return new DeviceAdaptionHintEntity {Amount = Amount, LimitAmount = LimitAmount, DeviceType = (int) DeviceType, Skip = Skip};
+ }
+
+ ///
+ public override string ToString()
+ {
+ return $"Device adaption - {nameof(DeviceType)}: {DeviceType}, {nameof(Skip)}: {Skip}, {nameof(LimitAmount)}: {LimitAmount}, {nameof(Amount)}: {Amount}";
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/AdaptionHints/IAdaptionHint.cs b/src/Artemis.Core/Models/Profile/AdaptionHints/IAdaptionHint.cs
index 48c3dc29a..cd86f4606 100644
--- a/src/Artemis.Core/Models/Profile/AdaptionHints/IAdaptionHint.cs
+++ b/src/Artemis.Core/Models/Profile/AdaptionHints/IAdaptionHint.cs
@@ -1,23 +1,22 @@
using System.Collections.Generic;
using Artemis.Storage.Entities.Profile.AdaptionHints;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents an adaption hint that's used to adapt a layer to a set of devices
+///
+public interface IAdaptionHint
{
///
- /// Represents an adaption hint that's used to adapt a layer to a set of devices
+ /// Applies the adaptive action to the provided layer
///
- public interface IAdaptionHint
- {
- ///
- /// Applies the adaptive action to the provided layer
- ///
- /// The layer to adapt
- /// The devices to adapt the layer for
- void Apply(Layer layer, List devices);
+ /// The layer to adapt
+ /// The devices to adapt the layer for
+ void Apply(Layer layer, List devices);
- ///
- /// Returns an adaption hint entry for this adaption hint used for persistent storage
- ///
- IAdaptionHintEntity GetEntry();
- }
+ ///
+ /// Returns an adaption hint entry for this adaption hint used for persistent storage
+ ///
+ IAdaptionHintEntity GetEntry();
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/AdaptionHints/KeyboardSectionAdaptionHint.cs b/src/Artemis.Core/Models/Profile/AdaptionHints/KeyboardSectionAdaptionHint.cs
index cf61108c4..2415a9082 100644
--- a/src/Artemis.Core/Models/Profile/AdaptionHints/KeyboardSectionAdaptionHint.cs
+++ b/src/Artemis.Core/Models/Profile/AdaptionHints/KeyboardSectionAdaptionHint.cs
@@ -4,89 +4,88 @@ using System.Linq;
using Artemis.Storage.Entities.Profile.AdaptionHints;
using RGB.NET.Core;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents a hint that adapts layers to a certain region of keyboards
+///
+public class KeyboardSectionAdaptionHint : CorePropertyChanged, IAdaptionHint
+{
+ private static readonly Dictionary> RegionLedIds = new()
+ {
+ {KeyboardSection.MacroKeys, Enum.GetValues().Where(l => l >= LedId.Keyboard_Programmable1 && l <= LedId.Keyboard_Programmable32).ToList()},
+ {KeyboardSection.LedStrips, Enum.GetValues().Where(l => l >= LedId.LedStripe1 && l <= LedId.LedStripe128).ToList()},
+ {KeyboardSection.Extra, Enum.GetValues().Where(l => l >= LedId.Keyboard_Custom1 && l <= LedId.Keyboard_Custom64).ToList()}
+ };
+
+ private KeyboardSection _section;
+
+ ///
+ /// Creates a new instance of the class
+ ///
+ public KeyboardSectionAdaptionHint()
+ {
+ }
+
+ internal KeyboardSectionAdaptionHint(KeyboardSectionAdaptionHintEntity entity)
+ {
+ Section = (KeyboardSection) entity.Section;
+ }
+
+ ///
+ /// Gets or sets the section this hint will apply LEDs to
+ ///
+ public KeyboardSection Section
+ {
+ get => _section;
+ set => SetAndNotify(ref _section, value);
+ }
+
+ #region Implementation of IAdaptionHint
+
+ ///
+ public void Apply(Layer layer, List devices)
+ {
+ // Only keyboards should have the LEDs we care about
+ foreach (ArtemisDevice keyboard in devices.Where(d => d.DeviceType == RGBDeviceType.Keyboard))
+ {
+ List ledIds = RegionLedIds[Section];
+ layer.AddLeds(keyboard.Leds.Where(l => ledIds.Contains(l.RgbLed.Id)));
+ }
+ }
+
+ ///
+ public IAdaptionHintEntity GetEntry()
+ {
+ return new KeyboardSectionAdaptionHintEntity {Section = (int) Section};
+ }
+
+ ///
+ public override string ToString()
+ {
+ return $"Keyboard section adaption - {nameof(Section)}: {Section}";
+ }
+
+ #endregion
+}
+
+///
+/// Represents a section of LEDs on a keyboard
+///
+public enum KeyboardSection
{
///
- /// Represents a hint that adapts layers to a certain region of keyboards
+ /// A region containing the macro keys of a keyboard
///
- public class KeyboardSectionAdaptionHint : CorePropertyChanged, IAdaptionHint
- {
- private static readonly Dictionary> RegionLedIds = new()
- {
- {KeyboardSection.MacroKeys, Enum.GetValues().Where(l => l >= LedId.Keyboard_Programmable1 && l <= LedId.Keyboard_Programmable32).ToList()},
- {KeyboardSection.LedStrips, Enum.GetValues().Where(l => l >= LedId.LedStripe1 && l <= LedId.LedStripe128).ToList()},
- {KeyboardSection.Extra, Enum.GetValues().Where(l => l >= LedId.Keyboard_Custom1 && l <= LedId.Keyboard_Custom64).ToList()}
- };
-
- private KeyboardSection _section;
-
- ///
- /// Creates a new instance of the class
- ///
- public KeyboardSectionAdaptionHint()
- {
- }
-
- internal KeyboardSectionAdaptionHint(KeyboardSectionAdaptionHintEntity entity)
- {
- Section = (KeyboardSection) entity.Section;
- }
-
- ///
- /// Gets or sets the section this hint will apply LEDs to
- ///
- public KeyboardSection Section
- {
- get => _section;
- set => SetAndNotify(ref _section, value);
- }
-
- #region Implementation of IAdaptionHint
-
- ///
- public void Apply(Layer layer, List devices)
- {
- // Only keyboards should have the LEDs we care about
- foreach (ArtemisDevice keyboard in devices.Where(d => d.DeviceType == RGBDeviceType.Keyboard))
- {
- List ledIds = RegionLedIds[Section];
- layer.AddLeds(keyboard.Leds.Where(l => ledIds.Contains(l.RgbLed.Id)));
- }
- }
-
- ///
- public IAdaptionHintEntity GetEntry()
- {
- return new KeyboardSectionAdaptionHintEntity {Section = (int) Section};
- }
-
- ///
- public override string ToString()
- {
- return $"Keyboard section adaption - {nameof(Section)}: {Section}";
- }
-
- #endregion
- }
+ MacroKeys,
///
- /// Represents a section of LEDs on a keyboard
+ /// A region containing the LED strips of a keyboard
///
- public enum KeyboardSection
- {
- ///
- /// A region containing the macro keys of a keyboard
- ///
- MacroKeys,
+ LedStrips,
- ///
- /// A region containing the LED strips of a keyboard
- ///
- LedStrips,
-
- ///
- /// A region containing extra non-standard LEDs of a keyboard
- ///
- Extra
- }
+ ///
+ /// A region containing extra non-standard LEDs of a keyboard
+ ///
+ Extra
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs b/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs
index 1e34d5348..bd9fe7c7a 100644
--- a/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs
+++ b/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs
@@ -83,14 +83,10 @@ public class ColorGradient : IList, IList, INotifyCollectionC
{
List result = new();
if (timesToRepeat == 0)
- {
result = this.Select(c => c.Color).ToList();
- }
else
- {
for (int i = 0; i <= timesToRepeat; i++)
result.AddRange(this.Select(c => c.Color));
- }
if (seamless && !IsSeamless())
result.Add(result[0]);
@@ -413,8 +409,10 @@ public class ColorGradient : IList, IList, INotifyCollectionC
return false;
for (int i = 0; i < Count; i++)
+ {
if (!Equals(this[i], other[i]))
return false;
+ }
return true;
}
diff --git a/src/Artemis.Core/Models/Profile/Colors/ColorGradientStop.cs b/src/Artemis.Core/Models/Profile/Colors/ColorGradientStop.cs
index 205c772ff..8ccddbf24 100644
--- a/src/Artemis.Core/Models/Profile/Colors/ColorGradientStop.cs
+++ b/src/Artemis.Core/Models/Profile/Colors/ColorGradientStop.cs
@@ -1,69 +1,68 @@
using System;
using SkiaSharp;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// A color with a position, usually contained in a
+///
+public class ColorGradientStop : CorePropertyChanged
{
+ private SKColor _color;
+ private float _position;
+
///
- /// A color with a position, usually contained in a
+ /// Creates a new instance of the class
///
- public class ColorGradientStop : CorePropertyChanged
+ public ColorGradientStop(SKColor color, float position)
{
- #region Equality members
-
- ///
- protected bool Equals(ColorGradientStop other)
- {
- return _color.Equals(other._color) && _position.Equals(other._position);
- }
-
- ///
- public override bool Equals(object? obj)
- {
- if (ReferenceEquals(null, obj))
- return false;
- if (ReferenceEquals(this, obj))
- return true;
- if (obj.GetType() != GetType())
- return false;
- return Equals((ColorGradientStop) obj);
- }
-
- ///
- public override int GetHashCode()
- {
- return HashCode.Combine(_color, _position);
- }
-
- #endregion
-
- private SKColor _color;
- private float _position;
-
- ///
- /// Creates a new instance of the class
- ///
- public ColorGradientStop(SKColor color, float position)
- {
- Color = color;
- Position = position;
- }
-
- ///
- /// Gets or sets the color of the stop
- ///
- public SKColor Color
- {
- get => _color;
- set => SetAndNotify(ref _color, value);
- }
-
- ///
- /// Gets or sets the position of the stop
- ///
- public float Position
- {
- get => _position;
- set => SetAndNotify(ref _position, value);
- }
+ Color = color;
+ Position = position;
}
+
+ ///
+ /// Gets or sets the color of the stop
+ ///
+ public SKColor Color
+ {
+ get => _color;
+ set => SetAndNotify(ref _color, value);
+ }
+
+ ///
+ /// Gets or sets the position of the stop
+ ///
+ public float Position
+ {
+ get => _position;
+ set => SetAndNotify(ref _position, value);
+ }
+
+ #region Equality members
+
+ ///
+ protected bool Equals(ColorGradientStop other)
+ {
+ return _color.Equals(other._color) && _position.Equals(other._position);
+ }
+
+ ///
+ public override bool Equals(object? obj)
+ {
+ if (ReferenceEquals(null, obj))
+ return false;
+ if (ReferenceEquals(this, obj))
+ return true;
+ if (obj.GetType() != GetType())
+ return false;
+ return Equals((ColorGradientStop) obj);
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ return HashCode.Combine(_color, _position);
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/Conditions/AlwaysOnCondition.cs b/src/Artemis.Core/Models/Profile/Conditions/AlwaysOnCondition.cs
index a5463dfd3..eeeece9c5 100644
--- a/src/Artemis.Core/Models/Profile/Conditions/AlwaysOnCondition.cs
+++ b/src/Artemis.Core/Models/Profile/Conditions/AlwaysOnCondition.cs
@@ -2,89 +2,84 @@
using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.Conditions;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents a condition that is always true.
+///
+public class AlwaysOnCondition : ICondition
{
///
- /// Represents a condition that is always true.
+ /// Creates a new instance of the class.
///
- public class AlwaysOnCondition : ICondition
+ /// The profile element this condition applies to.
+ public AlwaysOnCondition(RenderProfileElement profileElement)
{
- ///
- /// Creates a new instance of the class.
- ///
- /// The profile element this condition applies to.
- public AlwaysOnCondition(RenderProfileElement profileElement)
- {
- ProfileElement = profileElement;
- Entity = new AlwaysOnConditionEntity();
- }
-
- ///
- /// Creates a new instance of the class.
- ///
- /// The entity used to store this condition.
- /// The profile element this condition applies to.
- public AlwaysOnCondition(AlwaysOnConditionEntity alwaysOnConditionEntity, RenderProfileElement profileElement)
- {
- ProfileElement = profileElement;
- Entity = alwaysOnConditionEntity;
- }
-
- #region Implementation of IDisposable
-
- ///
- public void Dispose()
- {
- }
-
- #endregion
-
- #region Implementation of IStorageModel
-
- ///
- public void Load()
- {
- }
-
- ///
- public void Save()
- {
- }
-
- #endregion
-
- #region Implementation of ICondition
-
- ///
- public IConditionEntity Entity { get; }
-
- ///
- public RenderProfileElement ProfileElement { get; }
-
- ///
- public bool IsMet { get; private set; }
-
- ///
- public void Update()
- {
- if (ProfileElement.Parent is RenderProfileElement parent)
- IsMet = parent.DisplayConditionMet;
- else
- IsMet = true;
- }
-
- ///
- public void UpdateTimeline(double deltaTime)
- {
- ProfileElement.Timeline.Update(TimeSpan.FromSeconds(deltaTime), true);
- }
-
- ///
- public void OverrideTimeline(TimeSpan position)
- {
- ProfileElement.Timeline.Override(position, position > ProfileElement.Timeline.Length);
- }
-
- #endregion
+ ProfileElement = profileElement;
+ Entity = new AlwaysOnConditionEntity();
}
+
+ ///
+ /// Creates a new instance of the class.
+ ///
+ /// The entity used to store this condition.
+ /// The profile element this condition applies to.
+ public AlwaysOnCondition(AlwaysOnConditionEntity alwaysOnConditionEntity, RenderProfileElement profileElement)
+ {
+ ProfileElement = profileElement;
+ Entity = alwaysOnConditionEntity;
+ }
+
+ ///
+ public void Dispose()
+ {
+ }
+
+ #region Implementation of IStorageModel
+
+ ///
+ public void Load()
+ {
+ }
+
+ ///
+ public void Save()
+ {
+ }
+
+ #endregion
+
+ #region Implementation of ICondition
+
+ ///
+ public IConditionEntity Entity { get; }
+
+ ///
+ public RenderProfileElement ProfileElement { get; }
+
+ ///
+ public bool IsMet { get; private set; }
+
+ ///
+ public void Update()
+ {
+ if (ProfileElement.Parent is RenderProfileElement parent)
+ IsMet = parent.DisplayConditionMet;
+ else
+ IsMet = true;
+ }
+
+ ///
+ public void UpdateTimeline(double deltaTime)
+ {
+ ProfileElement.Timeline.Update(TimeSpan.FromSeconds(deltaTime), true);
+ }
+
+ ///
+ public void OverrideTimeline(TimeSpan position)
+ {
+ ProfileElement.Timeline.Override(position, position > ProfileElement.Timeline.Length);
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/Conditions/EventCondition.cs b/src/Artemis.Core/Models/Profile/Conditions/EventCondition.cs
index 011805946..a517cd0e6 100644
--- a/src/Artemis.Core/Models/Profile/Conditions/EventCondition.cs
+++ b/src/Artemis.Core/Models/Profile/Conditions/EventCondition.cs
@@ -14,15 +14,15 @@ public class EventCondition : CorePropertyChanged, INodeScriptCondition
{
private readonly string _displayName;
private readonly EventConditionEntity _entity;
- private IEventConditionNode _startNode;
private DataModelPath? _eventPath;
- private NodeScript _script;
- private bool _wasMet;
private DateTime _lastProcessedTrigger;
private object? _lastProcessedValue;
private EventOverlapMode _overlapMode;
- private EventTriggerMode _triggerMode;
+ private NodeScript _script;
+ private IEventConditionNode _startNode;
private EventToggleOffMode _toggleOffMode;
+ private EventTriggerMode _triggerMode;
+ private bool _wasMet;
///
/// Creates a new instance of the class
@@ -87,7 +87,8 @@ public class EventCondition : CorePropertyChanged, INodeScriptCondition
}
///
- /// Gets or sets the mode for render elements when toggling off the event when using .
+ /// Gets or sets the mode for render elements when toggling off the event when using
+ /// .
///
public EventToggleOffMode ToggleOffMode
{
@@ -119,7 +120,9 @@ public class EventCondition : CorePropertyChanged, INodeScriptCondition
_startNode = eventNode;
}
else
+ {
eventNode = node;
+ }
IDataModelEvent? dataModelEvent = EventPath?.GetValue() as IDataModelEvent;
eventNode.CreatePins(dataModelEvent);
@@ -136,13 +139,25 @@ public class EventCondition : CorePropertyChanged, INodeScriptCondition
ReplaceStartNode(valueChangedNode);
}
else
+ {
valueChangedNode = node;
+ }
valueChangedNode.UpdateOutputPins(EventPath);
}
+
Script.Save();
}
+ ///
+ /// Gets the start node of the event script, if any
+ ///
+ /// The start node of the event script, if any.
+ public INode GetStartNode()
+ {
+ return _startNode;
+ }
+
private void ReplaceStartNode(IEventConditionNode newStartNode)
{
if (Script.Nodes.Contains(_startNode))
@@ -153,15 +168,6 @@ public class EventCondition : CorePropertyChanged, INodeScriptCondition
Script.AddNode(_startNode);
}
- ///
- /// Gets the start node of the event script, if any
- ///
- /// The start node of the event script, if any.
- public INode GetStartNode()
- {
- return _startNode;
- }
-
private bool Evaluate()
{
if (EventPath == null)
@@ -271,7 +277,7 @@ public class EventCondition : CorePropertyChanged, INodeScriptCondition
Script = _entity.Script != null
? new NodeScript($"Activate {_displayName}", $"Whether or not the event should activate the {_displayName}", _entity.Script, ProfileElement.Profile)
- : new NodeScript($"Activate {_displayName}", $"Whether or not the event should activate the {_displayName}", ProfileElement.Profile);
+ : new NodeScript($"Activate {_displayName}", $"Whether or not the event should activate the {_displayName}", ProfileElement.Profile);
UpdateEventNode();
}
@@ -356,7 +362,8 @@ public enum EventOverlapMode
}
///
-/// Represents a mode for render elements when toggling off the event when using .
+/// Represents a mode for render elements when toggling off the event when using
+/// .
///
public enum EventToggleOffMode
{
diff --git a/src/Artemis.Core/Models/Profile/Conditions/ICondition.cs b/src/Artemis.Core/Models/Profile/Conditions/ICondition.cs
index bddd6867b..ef3b17c13 100644
--- a/src/Artemis.Core/Models/Profile/Conditions/ICondition.cs
+++ b/src/Artemis.Core/Models/Profile/Conditions/ICondition.cs
@@ -30,12 +30,12 @@ public interface ICondition : IDisposable, IStorageModel
void Update();
///
- /// Updates the timeline according to the provided as the display condition sees fit.
+ /// Updates the timeline according to the provided as the display condition sees fit.
///
void UpdateTimeline(double deltaTime);
///
- /// Overrides the timeline to the provided as the display condition sees fit.
+ /// Overrides the timeline to the provided as the display condition sees fit.
///
void OverrideTimeline(TimeSpan position);
}
diff --git a/src/Artemis.Core/Models/Profile/Conditions/PlayOnceCondition.cs b/src/Artemis.Core/Models/Profile/Conditions/PlayOnceCondition.cs
index 459e24e19..40178ad6e 100644
--- a/src/Artemis.Core/Models/Profile/Conditions/PlayOnceCondition.cs
+++ b/src/Artemis.Core/Models/Profile/Conditions/PlayOnceCondition.cs
@@ -2,89 +2,84 @@
using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.Conditions;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents a condition that plays once when its script evaluates to .
+///
+public class PlayOnceCondition : ICondition
{
///
- /// Represents a condition that plays once when its script evaluates to .
+ /// Creates a new instance of the class.
///
- public class PlayOnceCondition : ICondition
+ /// The profile element this condition applies to.
+ public PlayOnceCondition(RenderProfileElement profileElement)
{
- ///
- /// Creates a new instance of the class.
- ///
- /// The profile element this condition applies to.
- public PlayOnceCondition(RenderProfileElement profileElement)
- {
- ProfileElement = profileElement;
- Entity = new PlayOnceConditionEntity();
- }
-
- ///
- /// Creates a new instance of the class.
- ///
- /// The entity used to store this condition.
- /// The profile element this condition applies to.
- public PlayOnceCondition(PlayOnceConditionEntity entity, RenderProfileElement profileElement)
- {
- ProfileElement = profileElement;
- Entity = entity;
- }
-
- #region Implementation of IDisposable
-
- ///
- public void Dispose()
- {
- }
-
- #endregion
-
- #region Implementation of IStorageModel
-
- ///
- public void Load()
- {
- }
-
- ///
- public void Save()
- {
- }
-
- #endregion
-
- #region Implementation of ICondition
-
- ///
- public IConditionEntity Entity { get; }
-
- ///
- public RenderProfileElement ProfileElement { get; }
-
- ///
- public bool IsMet { get; private set; }
-
- ///
- public void Update()
- {
- if (ProfileElement.Parent is RenderProfileElement parent)
- IsMet = parent.DisplayConditionMet;
- else
- IsMet = true;
- }
-
- ///
- public void UpdateTimeline(double deltaTime)
- {
- ProfileElement.Timeline.Update(TimeSpan.FromSeconds(deltaTime), false);
- }
-
- ///
- public void OverrideTimeline(TimeSpan position)
- {
- ProfileElement.Timeline.Override(position, false);
- }
-
- #endregion
+ ProfileElement = profileElement;
+ Entity = new PlayOnceConditionEntity();
}
+
+ ///
+ /// Creates a new instance of the class.
+ ///
+ /// The entity used to store this condition.
+ /// The profile element this condition applies to.
+ public PlayOnceCondition(PlayOnceConditionEntity entity, RenderProfileElement profileElement)
+ {
+ ProfileElement = profileElement;
+ Entity = entity;
+ }
+
+ ///
+ public void Dispose()
+ {
+ }
+
+ #region Implementation of IStorageModel
+
+ ///
+ public void Load()
+ {
+ }
+
+ ///
+ public void Save()
+ {
+ }
+
+ #endregion
+
+ #region Implementation of ICondition
+
+ ///
+ public IConditionEntity Entity { get; }
+
+ ///
+ public RenderProfileElement ProfileElement { get; }
+
+ ///
+ public bool IsMet { get; private set; }
+
+ ///
+ public void Update()
+ {
+ if (ProfileElement.Parent is RenderProfileElement parent)
+ IsMet = parent.DisplayConditionMet;
+ else
+ IsMet = true;
+ }
+
+ ///
+ public void UpdateTimeline(double deltaTime)
+ {
+ ProfileElement.Timeline.Update(TimeSpan.FromSeconds(deltaTime), false);
+ }
+
+ ///
+ public void OverrideTimeline(TimeSpan position)
+ {
+ ProfileElement.Timeline.Override(position, false);
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/Conditions/StaticCondition.cs b/src/Artemis.Core/Models/Profile/Conditions/StaticCondition.cs
index 8ab4abd96..5ab81e22c 100644
--- a/src/Artemis.Core/Models/Profile/Conditions/StaticCondition.cs
+++ b/src/Artemis.Core/Models/Profile/Conditions/StaticCondition.cs
@@ -3,191 +3,192 @@ using System.Linq;
using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.Conditions;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents a condition that is based on a data model value
+///
+public class StaticCondition : CorePropertyChanged, INodeScriptCondition
+{
+ private readonly string _displayName;
+ private readonly StaticConditionEntity _entity;
+ private StaticPlayMode _playMode;
+ private StaticStopMode _stopMode;
+ private bool _wasMet;
+
+ ///
+ /// Creates a new instance of the class
+ ///
+ public StaticCondition(RenderProfileElement profileElement)
+ {
+ _entity = new StaticConditionEntity();
+ _displayName = profileElement.GetType().Name;
+
+ ProfileElement = profileElement;
+ Script = new NodeScript($"Activate {_displayName}", $"Whether or not this {_displayName} should be active", profileElement.Profile);
+ }
+
+ internal StaticCondition(StaticConditionEntity entity, RenderProfileElement profileElement)
+ {
+ _entity = entity;
+ _displayName = profileElement.GetType().Name;
+
+ ProfileElement = profileElement;
+ Script = null!;
+
+ Load();
+ }
+
+ ///
+ /// Gets the script that drives the static condition
+ ///
+ public NodeScript Script { get; private set; }
+
+ ///
+ /// Gets or sets the mode in which the render element starts its timeline when display conditions are met
+ ///
+ public StaticPlayMode PlayMode
+ {
+ get => _playMode;
+ set => SetAndNotify(ref _playMode, value);
+ }
+
+ ///
+ /// Gets or sets the mode in which the render element stops its timeline when display conditions are no longer met
+ ///
+ public StaticStopMode StopMode
+ {
+ get => _stopMode;
+ set => SetAndNotify(ref _stopMode, value);
+ }
+
+ ///
+ public IConditionEntity Entity => _entity;
+
+ ///
+ public RenderProfileElement ProfileElement { get; }
+
+ ///
+ public bool IsMet { get; private set; }
+
+ ///
+ public void Update()
+ {
+ _wasMet = IsMet;
+
+ // No need to run the script if the parent isn't met anyway
+ bool parentConditionMet = ProfileElement.Parent is not RenderProfileElement renderProfileElement || renderProfileElement.DisplayConditionMet;
+ if (!parentConditionMet)
+ {
+ IsMet = false;
+ return;
+ }
+
+ if (!Script.ExitNodeConnected)
+ {
+ IsMet = true;
+ }
+ else
+ {
+ Script.Run();
+ IsMet = Script.Result;
+ }
+ }
+
+ ///
+ public void UpdateTimeline(double deltaTime)
+ {
+ if (IsMet && !_wasMet && ProfileElement.Timeline.IsFinished)
+ ProfileElement.Timeline.JumpToStart();
+ else if (!IsMet && _wasMet && StopMode == StaticStopMode.SkipToEnd)
+ ProfileElement.Timeline.JumpToEndSegment();
+
+ ProfileElement.Timeline.Update(TimeSpan.FromSeconds(deltaTime), PlayMode == StaticPlayMode.Repeat && IsMet);
+ }
+
+ ///
+ public void OverrideTimeline(TimeSpan position)
+ {
+ ProfileElement.Timeline.Override(position, PlayMode == StaticPlayMode.Repeat && position > ProfileElement.Timeline.Length);
+ }
+
+ ///
+ public void Dispose()
+ {
+ Script.Dispose();
+ }
+
+ #region Storage
+
+ ///
+ public void Load()
+ {
+ PlayMode = (StaticPlayMode) _entity.PlayMode;
+ StopMode = (StaticStopMode) _entity.StopMode;
+
+ Script = _entity.Script != null
+ ? new NodeScript($"Activate {_displayName}", $"Whether or not this {_displayName} should be active", _entity.Script, ProfileElement.Profile)
+ : new NodeScript($"Activate {_displayName}", $"Whether or not this {_displayName} should be active", ProfileElement.Profile);
+ }
+
+ ///
+ public void Save()
+ {
+ _entity.PlayMode = (int) PlayMode;
+ _entity.StopMode = (int) StopMode;
+
+ // If the exit node isn't connected and there is only the exit node, don't save the script
+ if (!Script.ExitNodeConnected && Script.Nodes.Count() == 1)
+ {
+ _entity.Script = null;
+ }
+ else
+ {
+ Script.Save();
+ _entity.Script = Script.Entity;
+ }
+ }
+
+ ///
+ public INodeScript? NodeScript => Script;
+
+ ///
+ public void LoadNodeScript()
+ {
+ Script.Load();
+ }
+
+ #endregion
+}
+
+///
+/// Represents a mode for render elements to start their timeline when display conditions are met
+///
+public enum StaticPlayMode
{
///
- /// Represents a condition that is based on a data model value
+ /// Continue repeating the main segment of the timeline while the condition is met
///
- public class StaticCondition : CorePropertyChanged, INodeScriptCondition
- {
- private readonly string _displayName;
- private readonly StaticConditionEntity _entity;
- private StaticPlayMode _playMode;
- private StaticStopMode _stopMode;
- private bool _wasMet;
-
- ///
- /// Creates a new instance of the class
- ///
- public StaticCondition(RenderProfileElement profileElement)
- {
- _entity = new StaticConditionEntity();
- _displayName = profileElement.GetType().Name;
-
- ProfileElement = profileElement;
- Script = new NodeScript($"Activate {_displayName}", $"Whether or not this {_displayName} should be active", profileElement.Profile);
- }
-
- internal StaticCondition(StaticConditionEntity entity, RenderProfileElement profileElement)
- {
- _entity = entity;
- _displayName = profileElement.GetType().Name;
-
- ProfileElement = profileElement;
- Script = null!;
-
- Load();
- }
-
- ///
- /// Gets the script that drives the static condition
- ///
- public NodeScript Script { get; private set; }
-
- ///
- public IConditionEntity Entity => _entity;
-
- ///
- public RenderProfileElement ProfileElement { get; }
-
- ///
- public bool IsMet { get; private set; }
-
- ///
- /// Gets or sets the mode in which the render element starts its timeline when display conditions are met
- ///
- public StaticPlayMode PlayMode
- {
- get => _playMode;
- set => SetAndNotify(ref _playMode, value);
- }
-
- ///
- /// Gets or sets the mode in which the render element stops its timeline when display conditions are no longer met
- ///
- public StaticStopMode StopMode
- {
- get => _stopMode;
- set => SetAndNotify(ref _stopMode, value);
- }
-
- ///
- public void Update()
- {
- _wasMet = IsMet;
-
- // No need to run the script if the parent isn't met anyway
- bool parentConditionMet = ProfileElement.Parent is not RenderProfileElement renderProfileElement || renderProfileElement.DisplayConditionMet;
- if (!parentConditionMet)
- {
- IsMet = false;
- return;
- }
-
- if (!Script.ExitNodeConnected)
- IsMet = true;
- else
- {
- Script.Run();
- IsMet = Script.Result;
- }
- }
-
- ///
- public void UpdateTimeline(double deltaTime)
- {
- if (IsMet && !_wasMet && ProfileElement.Timeline.IsFinished)
- ProfileElement.Timeline.JumpToStart();
- else if (!IsMet && _wasMet && StopMode == StaticStopMode.SkipToEnd)
- ProfileElement.Timeline.JumpToEndSegment();
-
- ProfileElement.Timeline.Update(TimeSpan.FromSeconds(deltaTime), PlayMode == StaticPlayMode.Repeat && IsMet);
- }
-
- ///
- public void OverrideTimeline(TimeSpan position)
- {
- ProfileElement.Timeline.Override(position, PlayMode == StaticPlayMode.Repeat && position > ProfileElement.Timeline.Length);
- }
-
- ///
- public void Dispose()
- {
- Script.Dispose();
- }
-
- #region Storage
-
- ///
- public void Load()
- {
- PlayMode = (StaticPlayMode) _entity.PlayMode;
- StopMode = (StaticStopMode) _entity.StopMode;
-
- Script = _entity.Script != null
- ? new NodeScript($"Activate {_displayName}", $"Whether or not this {_displayName} should be active", _entity.Script, ProfileElement.Profile)
- : new NodeScript($"Activate {_displayName}", $"Whether or not this {_displayName} should be active", ProfileElement.Profile);
- }
-
- ///
- public void Save()
- {
- _entity.PlayMode = (int) PlayMode;
- _entity.StopMode = (int) StopMode;
-
- // If the exit node isn't connected and there is only the exit node, don't save the script
- if (!Script.ExitNodeConnected && Script.Nodes.Count() == 1)
- {
- _entity.Script = null;
- }
- else
- {
- Script.Save();
- _entity.Script = Script.Entity;
- }
- }
-
- ///
- public INodeScript? NodeScript => Script;
-
- ///
- public void LoadNodeScript()
- {
- Script.Load();
- }
-
- #endregion
- }
+ Repeat,
///
- /// Represents a mode for render elements to start their timeline when display conditions are met
+ /// Only play the timeline once when the condition is met
///
- public enum StaticPlayMode
- {
- ///
- /// Continue repeating the main segment of the timeline while the condition is met
- ///
- Repeat,
+ Once
+}
- ///
- /// Only play the timeline once when the condition is met
- ///
- Once
- }
+///
+/// Represents a mode for render elements to stop their timeline when display conditions are no longer met
+///
+public enum StaticStopMode
+{
+ ///
+ /// When conditions are no longer met, finish the the current run of the main timeline
+ ///
+ Finish,
///
- /// Represents a mode for render elements to stop their timeline when display conditions are no longer met
+ /// When conditions are no longer met, skip to the end segment of the timeline
///
- public enum StaticStopMode
- {
- ///
- /// When conditions are no longer met, finish the the current run of the main timeline
- ///
- Finish,
-
- ///
- /// When conditions are no longer met, skip to the end segment of the timeline
- ///
- SkipToEnd
- }
+ SkipToEnd
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs b/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs
index d4bdc6d13..42b10ccde 100644
--- a/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs
+++ b/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs
@@ -4,242 +4,243 @@ using System.Collections.ObjectModel;
using System.Linq;
using Artemis.Storage.Entities.Profile.DataBindings;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+public class DataBinding : IDataBinding
{
- ///
- public class DataBinding : IDataBinding
+ private readonly List _properties = new();
+ private bool _disposed;
+ private bool _isEnabled;
+ private DataBindingNodeScript _script;
+
+ internal DataBinding(LayerProperty layerProperty)
{
- private readonly List _properties = new();
- private bool _disposed;
- private bool _isEnabled;
- private DataBindingNodeScript _script;
+ LayerProperty = layerProperty;
- internal DataBinding(LayerProperty layerProperty)
- {
- LayerProperty = layerProperty;
+ Entity = new DataBindingEntity();
+ _script = new DataBindingNodeScript(GetScriptName(), "The value to put into the data binding", this, LayerProperty.ProfileElement.Profile);
- Entity = new DataBindingEntity();
- _script = new DataBindingNodeScript(GetScriptName(), "The value to put into the data binding", this, LayerProperty.ProfileElement.Profile);
-
- Save();
- }
-
- internal DataBinding(LayerProperty layerProperty, DataBindingEntity entity)
- {
- LayerProperty = layerProperty;
-
- Entity = entity;
- _script = new DataBindingNodeScript(GetScriptName(), "The value to put into the data binding", this, LayerProperty.ProfileElement.Profile);
-
- // Load will add children so be initialized before that
- Load();
- }
-
- ///
- /// Gets the layer property this data binding targets
- ///
- public LayerProperty LayerProperty { get; }
-
- ///
- public INodeScript Script => _script;
-
- ///
- /// Gets the data binding entity this data binding uses for persistent storage
- ///
- public DataBindingEntity Entity { get; }
-
- ///
- /// Updates the pending values of this data binding
- ///
- public void Update()
- {
- if (_disposed)
- throw new ObjectDisposedException("DataBinding");
-
- if (!IsEnabled)
- return;
-
- // TODO: Update the 'base value' node
-
- Script.Run();
- }
-
- ///
- /// Registers a data binding property so that is available to the data binding system
- ///
- /// The type of the layer property
- /// The function to call to get the value of the property
- /// The action to call to set the value of the property
- /// The display name of the data binding property
- public DataBindingProperty RegisterDataBindingProperty(Func getter, Action setter, string displayName)
- {
- if (_disposed)
- throw new ObjectDisposedException("DataBinding");
- if (Properties.Any(d => d.DisplayName == displayName))
- throw new ArtemisCoreException($"A data binding property named '{displayName}' is already registered.");
-
- DataBindingProperty property = new(getter, setter, displayName);
- _properties.Add(property);
-
- OnDataBindingPropertyRegistered();
- return property;
- }
-
- ///
- /// Removes all data binding properties so they are no longer available to the data binding system
- ///
- public void ClearDataBindingProperties()
- {
- if (_disposed)
- throw new ObjectDisposedException("LayerProperty");
-
- _properties.Clear();
- OnDataBindingPropertiesCleared();
- }
-
- ///
- /// Releases the unmanaged resources used by the object and optionally releases the managed resources.
- ///
- ///
- /// to release both managed and unmanaged resources;
- /// to release only unmanaged resources.
- ///
- protected virtual void Dispose(bool disposing)
- {
- if (disposing)
- {
- _disposed = true;
- _isEnabled = false;
-
- Script.Dispose();
- }
- }
-
- ///
- /// Invokes the event
- ///
- protected virtual void OnDataBindingPropertyRegistered()
- {
- DataBindingPropertyRegistered?.Invoke(this, new DataBindingEventArgs(this));
- }
-
- ///
- /// Invokes the event
- ///
- protected virtual void OnDataBindingPropertiesCleared()
- {
- DataBindingPropertiesCleared?.Invoke(this, new DataBindingEventArgs(this));
- }
-
- ///
- /// Invokes the event
- ///
- protected virtual void OnDataBindingEnabled(DataBindingEventArgs e)
- {
- DataBindingEnabled?.Invoke(this, e);
- }
-
- ///
- /// Invokes the event
- ///
- protected virtual void OnDataBindingDisabled(DataBindingEventArgs e)
- {
- DataBindingDisabled?.Invoke(this, e);
- }
-
- private string GetScriptName()
- {
- return LayerProperty.PropertyDescription.Name ?? LayerProperty.Path;
- }
-
- ///
- public ILayerProperty BaseLayerProperty => LayerProperty;
-
- ///
- public bool IsEnabled
- {
- get => _isEnabled;
- set
- {
- _isEnabled = value;
-
- if (_isEnabled)
- OnDataBindingEnabled(new DataBindingEventArgs(this));
- else
- OnDataBindingDisabled(new DataBindingEventArgs(this));
- }
- }
-
- ///
- public ReadOnlyCollection Properties => _properties.AsReadOnly();
-
- ///
- public void Apply()
- {
- if (_disposed)
- throw new ObjectDisposedException("DataBinding");
-
- if (!IsEnabled)
- return;
-
- _script.DataBindingExitNode.ApplyToDataBinding();
- }
-
- ///
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- ///
- public event EventHandler? DataBindingPropertyRegistered;
-
- ///
- public event EventHandler? DataBindingPropertiesCleared;
-
- ///
- public event EventHandler? DataBindingEnabled;
-
- ///
- public event EventHandler? DataBindingDisabled;
-
- #region Storage
-
- ///
- public void Load()
- {
- if (_disposed)
- throw new ObjectDisposedException("DataBinding");
-
- IsEnabled = Entity.IsEnabled;
- }
-
- ///
- public void LoadNodeScript()
- {
- _script.Dispose();
- _script = Entity.NodeScript != null
- ? new DataBindingNodeScript(GetScriptName(), "The value to put into the data binding", this, Entity.NodeScript, LayerProperty.ProfileElement.Profile)
- : new DataBindingNodeScript(GetScriptName(), "The value to put into the data binding", this, LayerProperty.ProfileElement.Profile);
- }
-
- ///
- public void Save()
- {
- if (_disposed)
- throw new ObjectDisposedException("DataBinding");
-
- Entity.IsEnabled = IsEnabled;
- if (_script.ExitNodeConnected || _script.Nodes.Count() > 1)
- {
- _script.Save();
- Entity.NodeScript = _script.Entity;
- }
- else
- Entity.NodeScript = null;
- }
-
- #endregion
+ Save();
}
+
+ internal DataBinding(LayerProperty layerProperty, DataBindingEntity entity)
+ {
+ LayerProperty = layerProperty;
+
+ Entity = entity;
+ _script = new DataBindingNodeScript(GetScriptName(), "The value to put into the data binding", this, LayerProperty.ProfileElement.Profile);
+
+ // Load will add children so be initialized before that
+ Load();
+ }
+
+ ///
+ /// Gets the layer property this data binding targets
+ ///
+ public LayerProperty LayerProperty { get; }
+
+ ///
+ /// Gets the data binding entity this data binding uses for persistent storage
+ ///
+ public DataBindingEntity Entity { get; }
+
+ ///
+ /// Updates the pending values of this data binding
+ ///
+ public void Update()
+ {
+ if (_disposed)
+ throw new ObjectDisposedException("DataBinding");
+
+ if (!IsEnabled)
+ return;
+
+ // TODO: Update the 'base value' node
+
+ Script.Run();
+ }
+
+ ///
+ /// Registers a data binding property so that is available to the data binding system
+ ///
+ /// The type of the layer property
+ /// The function to call to get the value of the property
+ /// The action to call to set the value of the property
+ /// The display name of the data binding property
+ public DataBindingProperty RegisterDataBindingProperty(Func getter, Action setter, string displayName)
+ {
+ if (_disposed)
+ throw new ObjectDisposedException("DataBinding");
+ if (Properties.Any(d => d.DisplayName == displayName))
+ throw new ArtemisCoreException($"A data binding property named '{displayName}' is already registered.");
+
+ DataBindingProperty property = new(getter, setter, displayName);
+ _properties.Add(property);
+
+ OnDataBindingPropertyRegistered();
+ return property;
+ }
+
+ ///
+ /// Removes all data binding properties so they are no longer available to the data binding system
+ ///
+ public void ClearDataBindingProperties()
+ {
+ if (_disposed)
+ throw new ObjectDisposedException("LayerProperty");
+
+ _properties.Clear();
+ OnDataBindingPropertiesCleared();
+ }
+
+ ///
+ /// Releases the unmanaged resources used by the object and optionally releases the managed resources.
+ ///
+ ///
+ /// to release both managed and unmanaged resources;
+ /// to release only unmanaged resources.
+ ///
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ _disposed = true;
+ _isEnabled = false;
+
+ Script.Dispose();
+ }
+ }
+
+ ///
+ /// Invokes the event
+ ///
+ protected virtual void OnDataBindingPropertyRegistered()
+ {
+ DataBindingPropertyRegistered?.Invoke(this, new DataBindingEventArgs(this));
+ }
+
+ ///
+ /// Invokes the event
+ ///
+ protected virtual void OnDataBindingPropertiesCleared()
+ {
+ DataBindingPropertiesCleared?.Invoke(this, new DataBindingEventArgs(this));
+ }
+
+ ///
+ /// Invokes the event
+ ///
+ protected virtual void OnDataBindingEnabled(DataBindingEventArgs e)
+ {
+ DataBindingEnabled?.Invoke(this, e);
+ }
+
+ ///
+ /// Invokes the event
+ ///
+ protected virtual void OnDataBindingDisabled(DataBindingEventArgs e)
+ {
+ DataBindingDisabled?.Invoke(this, e);
+ }
+
+ private string GetScriptName()
+ {
+ return LayerProperty.PropertyDescription.Name ?? LayerProperty.Path;
+ }
+
+ ///
+ public INodeScript Script => _script;
+
+ ///
+ public ILayerProperty BaseLayerProperty => LayerProperty;
+
+ ///
+ public bool IsEnabled
+ {
+ get => _isEnabled;
+ set
+ {
+ _isEnabled = value;
+
+ if (_isEnabled)
+ OnDataBindingEnabled(new DataBindingEventArgs(this));
+ else
+ OnDataBindingDisabled(new DataBindingEventArgs(this));
+ }
+ }
+
+ ///
+ public ReadOnlyCollection Properties => _properties.AsReadOnly();
+
+ ///
+ public void Apply()
+ {
+ if (_disposed)
+ throw new ObjectDisposedException("DataBinding");
+
+ if (!IsEnabled)
+ return;
+
+ _script.DataBindingExitNode.ApplyToDataBinding();
+ }
+
+ ///
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ ///
+ public event EventHandler? DataBindingPropertyRegistered;
+
+ ///
+ public event EventHandler? DataBindingPropertiesCleared;
+
+ ///
+ public event EventHandler? DataBindingEnabled;
+
+ ///
+ public event EventHandler? DataBindingDisabled;
+
+ #region Storage
+
+ ///
+ public void Load()
+ {
+ if (_disposed)
+ throw new ObjectDisposedException("DataBinding");
+
+ IsEnabled = Entity.IsEnabled;
+ }
+
+ ///
+ public void LoadNodeScript()
+ {
+ _script.Dispose();
+ _script = Entity.NodeScript != null
+ ? new DataBindingNodeScript(GetScriptName(), "The value to put into the data binding", this, Entity.NodeScript, LayerProperty.ProfileElement.Profile)
+ : new DataBindingNodeScript(GetScriptName(), "The value to put into the data binding", this, LayerProperty.ProfileElement.Profile);
+ }
+
+ ///
+ public void Save()
+ {
+ if (_disposed)
+ throw new ObjectDisposedException("DataBinding");
+
+ Entity.IsEnabled = IsEnabled;
+ if (_script.ExitNodeConnected || _script.Nodes.Count() > 1)
+ {
+ _script.Save();
+ Entity.NodeScript = _script.Entity;
+ }
+ else
+ {
+ Entity.NodeScript = null;
+ }
+ }
+
+ #endregion
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/DataBindings/DataBindingProperty.cs b/src/Artemis.Core/Models/Profile/DataBindings/DataBindingProperty.cs
index 7c09381fd..13a5c9e27 100644
--- a/src/Artemis.Core/Models/Profile/DataBindings/DataBindingProperty.cs
+++ b/src/Artemis.Core/Models/Profile/DataBindings/DataBindingProperty.cs
@@ -1,63 +1,62 @@
using System;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+public class DataBindingProperty : IDataBindingProperty
{
- ///
- public class DataBindingProperty : IDataBindingProperty
+ internal DataBindingProperty(Func getter, Action setter, string displayName)
{
- internal DataBindingProperty(Func getter, Action setter, string displayName)
+ Getter = getter ?? throw new ArgumentNullException(nameof(getter));
+ Setter = setter ?? throw new ArgumentNullException(nameof(setter));
+ DisplayName = displayName ?? throw new ArgumentNullException(nameof(displayName));
+ }
+
+ ///
+ /// Gets the function to call to get the value of the property
+ ///
+ public Func Getter { get; }
+
+ ///
+ /// Gets the action to call to set the value of the property
+ ///
+ public Action Setter { get; }
+
+ ///
+ public string DisplayName { get; }
+
+ ///
+ public Type ValueType => typeof(TProperty);
+
+ ///
+ public object? GetValue()
+ {
+ return Getter();
+ }
+
+ ///
+ public void SetValue(object? value)
+ {
+ // Numeric has a bunch of conversion, this seems the cheapest way to use them :)
+ switch (value)
{
- Getter = getter ?? throw new ArgumentNullException(nameof(getter));
- Setter = setter ?? throw new ArgumentNullException(nameof(setter));
- DisplayName = displayName ?? throw new ArgumentNullException(nameof(displayName));
- }
-
- ///
- /// Gets the function to call to get the value of the property
- ///
- public Func Getter { get; }
-
- ///
- /// Gets the action to call to set the value of the property
- ///
- public Action Setter { get; }
-
- ///
- public string DisplayName { get; }
-
- ///
- public Type ValueType => typeof(TProperty);
-
- ///
- public object? GetValue()
- {
- return Getter();
- }
-
- ///
- public void SetValue(object? value)
- {
- // Numeric has a bunch of conversion, this seems the cheapest way to use them :)
- switch (value)
- {
- case TProperty match:
- Setter(match);
- break;
- case Numeric numeric when Setter is Action floatSetter:
- floatSetter(numeric);
- break;
- case Numeric numeric when Setter is Action intSetter:
- intSetter(numeric);
- break;
- case Numeric numeric when Setter is Action doubleSetter:
- doubleSetter(numeric);
- break;
- case Numeric numeric when Setter is Action byteSetter:
- byteSetter(numeric);
- break;
- default:
- throw new ArgumentException("Value must match the type of the data binding registration", nameof(value));
- }
+ case TProperty match:
+ Setter(match);
+ break;
+ case Numeric numeric when Setter is Action floatSetter:
+ floatSetter(numeric);
+ break;
+ case Numeric numeric when Setter is Action intSetter:
+ intSetter(numeric);
+ break;
+ case Numeric numeric when Setter is Action doubleSetter:
+ doubleSetter(numeric);
+ break;
+ case Numeric numeric when Setter is Action byteSetter:
+ byteSetter(numeric);
+ break;
+ default:
+ throw new ArgumentException("Value must match the type of the data binding registration", nameof(value));
}
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/DataBindings/IDataBinding.cs b/src/Artemis.Core/Models/Profile/DataBindings/IDataBinding.cs
index 8c56aa298..a5856d018 100644
--- a/src/Artemis.Core/Models/Profile/DataBindings/IDataBinding.cs
+++ b/src/Artemis.Core/Models/Profile/DataBindings/IDataBinding.cs
@@ -2,62 +2,61 @@
using System.Collections.ObjectModel;
using Artemis.Core.Modules;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents a data binding that binds a certain to a value inside a
+///
+///
+public interface IDataBinding : IStorageModel, IDisposable
{
///
- /// Represents a data binding that binds a certain to a value inside a
- ///
+ /// Gets the layer property the data binding is applied to
///
- public interface IDataBinding : IStorageModel, IDisposable
- {
- ///
- /// Gets the layer property the data binding is applied to
- ///
- ILayerProperty BaseLayerProperty { get; }
+ ILayerProperty BaseLayerProperty { get; }
- ///
- /// Gets the script used to populate the data binding
- ///
- INodeScript Script { get; }
+ ///
+ /// Gets the script used to populate the data binding
+ ///
+ INodeScript Script { get; }
- ///
- /// Gets a list of sub-properties this data binding applies to
- ///
- ReadOnlyCollection Properties { get; }
+ ///
+ /// Gets a list of sub-properties this data binding applies to
+ ///
+ ReadOnlyCollection Properties { get; }
- ///
- /// Gets a boolean indicating whether the data binding is enabled or not
- ///
- bool IsEnabled { get; set; }
+ ///
+ /// Gets a boolean indicating whether the data binding is enabled or not
+ ///
+ bool IsEnabled { get; set; }
- ///
- /// Applies the pending value of the data binding to the property
- ///
- void Apply();
+ ///
+ /// Applies the pending value of the data binding to the property
+ ///
+ void Apply();
- ///
- /// If the data binding is enabled, loads the node script for that data binding
- ///
- void LoadNodeScript();
+ ///
+ /// If the data binding is enabled, loads the node script for that data binding
+ ///
+ void LoadNodeScript();
- ///
- /// Occurs when a data binding property has been added
- ///
- public event EventHandler? DataBindingPropertyRegistered;
+ ///
+ /// Occurs when a data binding property has been added
+ ///
+ public event EventHandler? DataBindingPropertyRegistered;
- ///
- /// Occurs when all data binding properties have been removed
- ///
- public event EventHandler? DataBindingPropertiesCleared;
+ ///
+ /// Occurs when all data binding properties have been removed
+ ///
+ public event EventHandler? DataBindingPropertiesCleared;
- ///
- /// Occurs when a data binding has been enabled
- ///
- public event EventHandler? DataBindingEnabled;
+ ///
+ /// Occurs when a data binding has been enabled
+ ///
+ public event EventHandler? DataBindingEnabled;
- ///
- /// Occurs when a data binding has been disabled
- ///
- public event EventHandler? DataBindingDisabled;
- }
+ ///
+ /// Occurs when a data binding has been disabled
+ ///
+ public event EventHandler? DataBindingDisabled;
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/DataBindings/IDataBindingProperty.cs b/src/Artemis.Core/Models/Profile/DataBindings/IDataBindingProperty.cs
index c6f299766..7d5dc49bd 100644
--- a/src/Artemis.Core/Models/Profile/DataBindings/IDataBindingProperty.cs
+++ b/src/Artemis.Core/Models/Profile/DataBindings/IDataBindingProperty.cs
@@ -1,32 +1,31 @@
using System;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents a data binding registration
+///
+public interface IDataBindingProperty
{
///
- /// Represents a data binding registration
+ /// Gets or sets the display name of the data binding registration
///
- public interface IDataBindingProperty
- {
- ///
- /// Gets or sets the display name of the data binding registration
- ///
- string DisplayName { get; }
+ string DisplayName { get; }
- ///
- /// Gets the type of the value this data binding registration points to
- ///
- Type ValueType { get; }
+ ///
+ /// Gets the type of the value this data binding registration points to
+ ///
+ Type ValueType { get; }
- ///
- /// Gets the value of the property this registration points to
- ///
- /// A value matching the type of
- object? GetValue();
+ ///
+ /// Gets the value of the property this registration points to
+ ///
+ /// A value matching the type of
+ object? GetValue();
- ///
- /// Sets the value of the property this registration points to
- ///
- /// A value matching the type of
- void SetValue(object? value);
- }
+ ///
+ /// Sets the value of the property this registration points to
+ ///
+ /// A value matching the type of
+ void SetValue(object? value);
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/DataModel/DataModelEvent.cs b/src/Artemis.Core/Models/Profile/DataModel/DataModelEvent.cs
index 352c3c09b..a1a98fa83 100644
--- a/src/Artemis.Core/Models/Profile/DataModel/DataModelEvent.cs
+++ b/src/Artemis.Core/Models/Profile/DataModel/DataModelEvent.cs
@@ -3,249 +3,244 @@ using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Modules;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents a data model event with event arguments of type
+///
+public class DataModelEvent : IDataModelEvent where T : DataModelEventArgs
{
+ private bool _trackHistory;
+
///
- /// Represents a data model event with event arguments of type
+ /// Creates a new instance of the class with history tracking disabled
///
- public class DataModelEvent : IDataModelEvent where T : DataModelEventArgs
+ public DataModelEvent()
{
- private bool _trackHistory;
-
- ///
- /// Creates a new instance of the class with history tracking disabled
- ///
- public DataModelEvent()
- {
- }
-
- ///
- /// Creates a new instance of the
- ///
- /// A boolean indicating whether the last 20 events should be tracked
- public DataModelEvent(bool trackHistory)
- {
- _trackHistory = trackHistory;
- }
-
- ///
- [DataModelProperty(Name = "Last trigger", Description = "The time at which the event last triggered")]
- public DateTime LastTrigger { get; private set; }
-
- ///
- [DataModelProperty(Name = "Time since trigger", Description = "The time that has passed since the last trigger")]
- public TimeSpan TimeSinceLastTrigger => DateTime.Now - LastTrigger;
-
- ///
- /// Gets the event arguments of the last time the event was triggered
- ///
- [DataModelProperty(Description = "The arguments of the last time this event triggered")]
- public T? LastEventArguments { get; private set; }
-
- ///
- [DataModelProperty(Description = "The total amount of times this event has triggered since the module was activated")]
- public int TriggerCount { get; private set; }
-
- ///
- /// Gets a queue of the last 20 event arguments
- /// Always empty if is
- ///
- [DataModelProperty(Description = "The arguments of the last time this event triggered")]
- public Queue EventArgumentsHistory { get; } = new(20);
-
- ///
- /// Trigger the event with the given
- ///
- /// The event argument to pass to the event
- public void Trigger(T eventArgs)
- {
- if (eventArgs == null) throw new ArgumentNullException(nameof(eventArgs));
- eventArgs.TriggerTime = DateTime.Now;
-
- LastEventArguments = eventArgs;
- LastTrigger = DateTime.Now;
- TriggerCount++;
-
- if (TrackHistory)
- {
- lock (EventArgumentsHistory)
- {
- if (EventArgumentsHistory.Count == 20)
- EventArgumentsHistory.Dequeue();
- EventArgumentsHistory.Enqueue(eventArgs);
- }
- }
-
- OnEventTriggered();
- }
-
- internal virtual void OnEventTriggered()
- {
- EventTriggered?.Invoke(this, EventArgs.Empty);
- }
-
- ///
- [DataModelIgnore]
- public Type ArgumentsType => typeof(T);
-
- ///
- [DataModelIgnore]
- public string TriggerPastParticiple => "triggered";
-
- ///
- [DataModelIgnore]
- public bool TrackHistory
- {
- get => _trackHistory;
- set
- {
- EventArgumentsHistory.Clear();
- _trackHistory = value;
- }
- }
-
- ///
- [DataModelIgnore]
- public DataModelEventArgs? LastEventArgumentsUntyped => LastEventArguments;
-
- ///
- [DataModelIgnore]
- public List EventArgumentsHistoryUntyped => EventArgumentsHistory.Cast().ToList();
-
- ///
- public event EventHandler? EventTriggered;
-
- ///
- public void Reset()
- {
- TriggerCount = 0;
- EventArgumentsHistory.Clear();
- }
-
- ///
- public void Update()
- {
- }
}
///
- /// Represents a data model event without event arguments
+ /// Creates a new instance of the
///
- public class DataModelEvent : IDataModelEvent
+ /// A boolean indicating whether the last 20 events should be tracked
+ public DataModelEvent(bool trackHistory)
{
- private bool _trackHistory;
+ _trackHistory = trackHistory;
+ }
- ///
- /// Creates a new instance of the class with history tracking disabled
- ///
- public DataModelEvent()
- {
- }
+ ///
+ /// Gets the event arguments of the last time the event was triggered
+ ///
+ [DataModelProperty(Description = "The arguments of the last time this event triggered")]
+ public T? LastEventArguments { get; private set; }
- ///
- /// Creates a new instance of the
- ///
- /// A boolean indicating whether the last 20 events should be tracked
- public DataModelEvent(bool trackHistory)
- {
- _trackHistory = trackHistory;
- }
+ ///
+ /// Gets a queue of the last 20 event arguments
+ /// Always empty if is
+ ///
+ [DataModelProperty(Description = "The arguments of the last time this event triggered")]
+ public Queue EventArgumentsHistory { get; } = new(20);
- ///
- [DataModelProperty(Name = "Last trigger", Description = "The time at which the event last triggered")]
- public DateTime LastTrigger { get; private set; }
+ ///
+ /// Trigger the event with the given
+ ///
+ /// The event argument to pass to the event
+ public void Trigger(T eventArgs)
+ {
+ if (eventArgs == null) throw new ArgumentNullException(nameof(eventArgs));
+ eventArgs.TriggerTime = DateTime.Now;
- ///
- [DataModelProperty(Name = "Time since trigger", Description = "The time that has passed since the last trigger")]
- public TimeSpan TimeSinceLastTrigger => DateTime.Now - LastTrigger;
+ LastEventArguments = eventArgs;
+ LastTrigger = DateTime.Now;
+ TriggerCount++;
- ///
- /// Gets the event arguments of the last time the event was triggered
- ///
- [DataModelProperty(Description = "The arguments of the last time this event triggered")]
- public DataModelEventArgs? LastTriggerArguments { get; private set; }
-
- ///
- [DataModelProperty(Description = "The total amount of times this event has triggered since the module was activated")]
- public int TriggerCount { get; private set; }
-
- ///
- /// Gets a queue of the last 20 event arguments
- /// Always empty if is
- ///
- [DataModelProperty(Description = "The arguments of the last time this event triggered")]
- public Queue EventArgumentsHistory { get; } = new(20);
-
- ///
- /// Trigger the event
- ///
- public void Trigger()
- {
- DataModelEventArgs eventArgs = new() {TriggerTime = DateTime.Now};
-
- LastTriggerArguments = eventArgs;
- LastTrigger = DateTime.Now;
- TriggerCount++;
-
- if (TrackHistory)
+ if (TrackHistory)
+ lock (EventArgumentsHistory)
{
- lock (EventArgumentsHistory)
- {
- if (EventArgumentsHistory.Count == 20)
- EventArgumentsHistory.Dequeue();
- EventArgumentsHistory.Enqueue(eventArgs);
- }
+ if (EventArgumentsHistory.Count == 20)
+ EventArgumentsHistory.Dequeue();
+ EventArgumentsHistory.Enqueue(eventArgs);
}
- OnEventTriggered();
- }
+ OnEventTriggered();
+ }
- internal virtual void OnEventTriggered()
+ internal virtual void OnEventTriggered()
+ {
+ EventTriggered?.Invoke(this, EventArgs.Empty);
+ }
+
+ ///
+ [DataModelProperty(Name = "Last trigger", Description = "The time at which the event last triggered")]
+ public DateTime LastTrigger { get; private set; }
+
+ ///
+ [DataModelProperty(Name = "Time since trigger", Description = "The time that has passed since the last trigger")]
+ public TimeSpan TimeSinceLastTrigger => DateTime.Now - LastTrigger;
+
+ ///
+ [DataModelProperty(Description = "The total amount of times this event has triggered since the module was activated")]
+ public int TriggerCount { get; private set; }
+
+ ///
+ [DataModelIgnore]
+ public Type ArgumentsType => typeof(T);
+
+ ///
+ [DataModelIgnore]
+ public string TriggerPastParticiple => "triggered";
+
+ ///
+ [DataModelIgnore]
+ public bool TrackHistory
+ {
+ get => _trackHistory;
+ set
{
- EventTriggered?.Invoke(this, EventArgs.Empty);
- }
-
- ///
- [DataModelIgnore]
- public Type ArgumentsType => typeof(DataModelEventArgs);
-
- ///
- [DataModelIgnore]
- public string TriggerPastParticiple => "triggered";
-
- ///
- [DataModelIgnore]
- public bool TrackHistory
- {
- get => _trackHistory;
- set
- {
- EventArgumentsHistory.Clear();
- _trackHistory = value;
- }
- }
-
- ///
- [DataModelIgnore]
- public DataModelEventArgs? LastEventArgumentsUntyped => LastTriggerArguments;
-
- ///
- [DataModelIgnore]
- public List EventArgumentsHistoryUntyped => EventArgumentsHistory.ToList();
-
- ///
- public event EventHandler? EventTriggered;
-
- ///
- public void Reset()
- {
- TriggerCount = 0;
EventArgumentsHistory.Clear();
+ _trackHistory = value;
}
+ }
- ///
- public void Update()
+ ///
+ [DataModelIgnore]
+ public DataModelEventArgs? LastEventArgumentsUntyped => LastEventArguments;
+
+ ///
+ [DataModelIgnore]
+ public List EventArgumentsHistoryUntyped => EventArgumentsHistory.Cast().ToList();
+
+ ///
+ public event EventHandler? EventTriggered;
+
+ ///
+ public void Reset()
+ {
+ TriggerCount = 0;
+ EventArgumentsHistory.Clear();
+ }
+
+ ///
+ public void Update()
+ {
+ }
+}
+
+///
+/// Represents a data model event without event arguments
+///
+public class DataModelEvent : IDataModelEvent
+{
+ private bool _trackHistory;
+
+ ///
+ /// Creates a new instance of the class with history tracking disabled
+ ///
+ public DataModelEvent()
+ {
+ }
+
+ ///
+ /// Creates a new instance of the
+ ///
+ /// A boolean indicating whether the last 20 events should be tracked
+ public DataModelEvent(bool trackHistory)
+ {
+ _trackHistory = trackHistory;
+ }
+
+ ///
+ /// Gets the event arguments of the last time the event was triggered
+ ///
+ [DataModelProperty(Description = "The arguments of the last time this event triggered")]
+ public DataModelEventArgs? LastTriggerArguments { get; private set; }
+
+ ///
+ /// Gets a queue of the last 20 event arguments
+ /// Always empty if is
+ ///
+ [DataModelProperty(Description = "The arguments of the last time this event triggered")]
+ public Queue EventArgumentsHistory { get; } = new(20);
+
+ ///
+ /// Trigger the event
+ ///
+ public void Trigger()
+ {
+ DataModelEventArgs eventArgs = new() {TriggerTime = DateTime.Now};
+
+ LastTriggerArguments = eventArgs;
+ LastTrigger = DateTime.Now;
+ TriggerCount++;
+
+ if (TrackHistory)
+ lock (EventArgumentsHistory)
+ {
+ if (EventArgumentsHistory.Count == 20)
+ EventArgumentsHistory.Dequeue();
+ EventArgumentsHistory.Enqueue(eventArgs);
+ }
+
+ OnEventTriggered();
+ }
+
+ internal virtual void OnEventTriggered()
+ {
+ EventTriggered?.Invoke(this, EventArgs.Empty);
+ }
+
+ ///
+ [DataModelProperty(Name = "Last trigger", Description = "The time at which the event last triggered")]
+ public DateTime LastTrigger { get; private set; }
+
+ ///
+ [DataModelProperty(Name = "Time since trigger", Description = "The time that has passed since the last trigger")]
+ public TimeSpan TimeSinceLastTrigger => DateTime.Now - LastTrigger;
+
+ ///
+ [DataModelProperty(Description = "The total amount of times this event has triggered since the module was activated")]
+ public int TriggerCount { get; private set; }
+
+ ///
+ [DataModelIgnore]
+ public Type ArgumentsType => typeof(DataModelEventArgs);
+
+ ///
+ [DataModelIgnore]
+ public string TriggerPastParticiple => "triggered";
+
+ ///
+ [DataModelIgnore]
+ public bool TrackHistory
+ {
+ get => _trackHistory;
+ set
{
+ EventArgumentsHistory.Clear();
+ _trackHistory = value;
}
}
+
+ ///
+ [DataModelIgnore]
+ public DataModelEventArgs? LastEventArgumentsUntyped => LastTriggerArguments;
+
+ ///
+ [DataModelIgnore]
+ public List EventArgumentsHistoryUntyped => EventArgumentsHistory.ToList();
+
+ ///
+ public event EventHandler? EventTriggered;
+
+ ///
+ public void Reset()
+ {
+ TriggerCount = 0;
+ EventArgumentsHistory.Clear();
+ }
+
+ ///
+ public void Update()
+ {
+ }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/DataModel/DataModelEventArgs.cs b/src/Artemis.Core/Models/Profile/DataModel/DataModelEventArgs.cs
index edd41bb6a..c6ae1db7c 100644
--- a/src/Artemis.Core/Models/Profile/DataModel/DataModelEventArgs.cs
+++ b/src/Artemis.Core/Models/Profile/DataModel/DataModelEventArgs.cs
@@ -1,17 +1,16 @@
using System;
using Artemis.Core.Modules;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents the base class for data model events that contain event data
+///
+public class DataModelEventArgs
{
///
- /// Represents the base class for data model events that contain event data
+ /// Gets the time at which the event with these arguments was triggered
///
- public class DataModelEventArgs
- {
- ///
- /// Gets the time at which the event with these arguments was triggered
- ///
- [DataModelIgnore]
- public DateTime TriggerTime { get; internal set; }
- }
+ [DataModelIgnore]
+ public DateTime TriggerTime { get; internal set; }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/DataModel/DataModelPath.cs b/src/Artemis.Core/Models/Profile/DataModel/DataModelPath.cs
index 6aaaf0ee9..ea1a85825 100644
--- a/src/Artemis.Core/Models/Profile/DataModel/DataModelPath.cs
+++ b/src/Artemis.Core/Models/Profile/DataModel/DataModelPath.cs
@@ -6,388 +6,388 @@ using System.Reflection;
using Artemis.Core.Modules;
using Artemis.Storage.Entities.Profile;
-namespace Artemis.Core
+namespace Artemis.Core;
+
+///
+/// Represents a path that points to a property in data model
+///
+public class DataModelPath : IStorageModel, IDisposable
{
+ private readonly LinkedList _segments;
+ private Expression>? _accessorLambda;
+ private bool _disposed;
+
///
- /// Represents a path that points to a property in data model
+ /// Creates a new instance of the class pointing directly to the target
///
- public class DataModelPath : IStorageModel, IDisposable
+ /// The target at which this path starts
+ public DataModelPath(DataModel target)
{
- private readonly LinkedList _segments;
- private Expression>? _accessorLambda;
- private bool _disposed;
+ Target = target ?? throw new ArgumentNullException(nameof(target));
+ Path = "";
+ Entity = new DataModelPathEntity();
- ///
- /// Creates a new instance of the class pointing directly to the target
- ///
- /// The target at which this path starts
- public DataModelPath(DataModel target)
- {
- Target = target ?? throw new ArgumentNullException(nameof(target));
- Path = "";
- Entity = new DataModelPathEntity();
+ _segments = new LinkedList();
- _segments = new LinkedList();
-
- Save();
- Initialize();
- SubscribeToDataModelStore();
- }
-
- ///
- /// Creates a new instance of the class pointing to the provided path
- ///
- /// The target at which this path starts
- /// A point-separated path
- public DataModelPath(DataModel target, string path)
- {
- Target = target ?? throw new ArgumentNullException(nameof(target));
- Path = path ?? throw new ArgumentNullException(nameof(path));
- Entity = new DataModelPathEntity();
-
- _segments = new LinkedList();
-
- Save();
- Initialize();
- SubscribeToDataModelStore();
- }
-
- ///
- /// Creates a new instance of the class based on an existing path
- ///
- /// The path to base the new instance on
- public DataModelPath(DataModelPath dataModelPath)
- {
- if (dataModelPath == null)
- throw new ArgumentNullException(nameof(dataModelPath));
-
- Target = dataModelPath.Target;
- Path = dataModelPath.Path;
- Entity = new DataModelPathEntity();
-
- _segments = new LinkedList();
-
- Save();
- Initialize();
- SubscribeToDataModelStore();
- }
-
- ///
- /// Creates a new instance of the class based on a
- ///
- ///
- public DataModelPath(DataModelPathEntity entity)
- {
- Path = entity.Path;
- Entity = entity;
-
- _segments = new LinkedList();
-
- Load();
- Initialize();
- SubscribeToDataModelStore();
- }
-
- ///
- /// Gets the data model at which this path starts
- ///
- public DataModel? Target { get; private set; }
-
- ///
- /// Gets the data model ID of the if it is a
- ///
- public string? DataModelId => Target?.Module.Id;
-
- ///
- /// Gets the point-separated path associated with this
- ///
- public string Path { get; private set; }
-
- ///
- /// Gets a boolean indicating whether all are valid
- ///
- public bool IsValid => Segments.Any() && Segments.All(p => p.Type != DataModelPathSegmentType.Invalid);
-
- ///
- /// Gets a read-only list of all segments of this path
- ///
- public IReadOnlyCollection Segments => _segments.ToList().AsReadOnly();
-
- ///
- /// Gets the entity used for persistent storage
- ///
- public DataModelPathEntity Entity { get; }
-
- internal Func