diff --git a/docfx/docfx_project/index.md b/docfx/docfx_project/index.md index 0cad893cf..0d7007d2d 100644 --- a/docfx/docfx_project/index.md +++ b/docfx/docfx_project/index.md @@ -6,16 +6,12 @@ A large part of this documentation is being generated based on code but over tim ## Plugins Artemis 2.0 has been developed from the ground up with plugins in mind. This means almost all functionality can be expanded. The following plugin types are currently available and fully implemented: - - [DataModelExpansion\](api/Artemis.Core.DataModelExpansions.DataModelExpansion-1.html) - [DeviceProvider](api/Artemis.Core.DeviceProviders.DeviceProvider.html) - [LayerBrush\](api/Artemis.Core.LayerBrushes.LayerBrush-1.html) - [PerLedLayerBrush\](api/Artemis.Core.LayerBrushes.PerLedLayerBrush-1.html) - - [RgbNetLayerBrush\](api/Artemis.Core.LayerBrushes.RgbNetLayerBrush-1.html) - [LayerEffect](api/Artemis.Core.LayerEffects.LayerEffect-1.html) - [Module](api/Artemis.Core.Modules.Module.html) - [Module\](api/Artemis.Core.Modules.Module-1.html) - - [ProfileModule](api/Artemis.Core.Modules.ProfileModule.html), - - [ProfileModule\](api/Artemis.Core.Modules.ProfileModule-1.html) These allow you to expand on Artemis's functionality. For quick and interactive plugin creation, use the [Visual Studio template extension](https://marketplace.visualstudio.com/items?itemName=SpoinkyNL.ArtemisTemplates). @@ -25,6 +21,6 @@ Example implementations of these plugins can be found on [GitHub](https://github Artemis provides plugins with an API through a range of services. All the services are available to plugins by using dependency injection in your plugin's constructor. Dependency injection is also available for the different view models plugins may provide. -- [Core Services](api/Artemis.Core.Services.Interfaces.html) -- [UI Services](api/Artemis.UI.Shared.Services.Interfaces.html) +- [Core Services](api/Artemis.Core.Services.html#interfaces) +- [UI Services](api/Artemis.UI.Shared.Services.html#interfaces) diff --git a/src/Artemis.ConsoleUI/packages.lock.json b/src/Artemis.ConsoleUI/packages.lock.json index 45239c58c..bb43b0af9 100644 --- a/src/Artemis.ConsoleUI/packages.lock.json +++ b/src/Artemis.ConsoleUI/packages.lock.json @@ -154,6 +154,27 @@ "Ninject": "3.3.3" } }, + "RGB.NET.Core": { + "type": "Transitive", + "resolved": "1.0.0-prerelease.32", + "contentHash": "HlhhikrkV7OQIRszn6RT6+6N4QGGHaN6NDHK1YssZEJTtE2MIdeRajeQFFziPc4OVOvMgxY13unw/v25r/YALw==" + }, + "RGB.NET.Layout": { + "type": "Transitive", + "resolved": "1.0.0-prerelease.32", + "contentHash": "O7I8zR5Hy+joSLCJW10lkIPNMDS1gXe8hQuwm+T5DEDDpykVyc4tnO55WlO5GDmDCS/cXhcwq+qNpLez5Th4Xw==", + "dependencies": { + "RGB.NET.Core": "1.0.0-prerelease.32" + } + }, + "RGB.NET.Presets": { + "type": "Transitive", + "resolved": "1.0.0-prerelease.32", + "contentHash": "tqPUA/KUG1hw5pT4D7OLXI6buXxpUIUYNET90gHnVXbadYi0C0OJZ703XDsaPpj4Db8/B2k8f1T4tM4s2KCJhw==", + "dependencies": { + "RGB.NET.Core": "1.0.0-prerelease.32" + } + }, "runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl": { "type": "Transitive", "resolved": "4.3.0", @@ -1091,7 +1112,39 @@ } }, "artemis.core": { - "type": "Project" + "type": "Project", + "dependencies": { + "Artemis.Storage": "1.0.0", + "EmbedIO": "3.4.3", + "HidSharp": "2.1.0", + "Humanizer.Core": "2.11.10", + "LiteDB": "5.0.10", + "McMaster.NETCore.Plugins": "1.4.0", + "Newtonsoft.Json": "13.0.1", + "Ninject": "3.3.4", + "Ninject.Extensions.ChildKernel": "3.3.0", + "Ninject.Extensions.Conventions": "3.3.0", + "RGB.NET.Core": "1.0.0-prerelease.32", + "RGB.NET.Layout": "1.0.0-prerelease.32", + "RGB.NET.Presets": "1.0.0-prerelease.32", + "Serilog": "2.10.0", + "Serilog.Sinks.Console": "4.0.0", + "Serilog.Sinks.Debug": "2.0.0", + "Serilog.Sinks.File": "5.0.0", + "SkiaSharp": "2.80.3", + "System.Buffers": "4.5.1", + "System.IO.FileSystem.AccessControl": "5.0.0", + "System.Numerics.Vectors": "4.5.0", + "System.Reflection.Metadata": "5.0.0", + "System.ValueTuple": "4.5.0" + } + }, + "artemis.storage": { + "type": "Project", + "dependencies": { + "LiteDB": "5.0.10", + "Serilog": "2.10.0" + } } } } diff --git a/src/Artemis.Core/Extensions/TypeExtensions.cs b/src/Artemis.Core/Extensions/TypeExtensions.cs index 748e4dc51..ed5c5e36e 100644 --- a/src/Artemis.Core/Extensions/TypeExtensions.cs +++ b/src/Artemis.Core/Extensions/TypeExtensions.cs @@ -50,7 +50,7 @@ namespace Artemis.Core /// 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) + public static bool IsGenericType(this Type? type, Type genericType) { if (type == null) return false; @@ -95,17 +95,7 @@ namespace Artemis.Core /// if the value is of a numeric type, otherwise public static bool IsNumber([NotNullWhenAttribute(true)] this object? value) { - return value is sbyte - || value is byte - || value is short - || value is ushort - || value is int - || value is uint - || value is long - || value is ulong - || value is float - || value is double - || value is decimal; + 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 @@ -199,10 +189,10 @@ namespace Artemis.Core /// The generic type it should be or implement public static bool IsOfGenericType(this Type typeToCheck, Type genericType) { - return typeToCheck.IsOfGenericType(genericType, out Type _); + return typeToCheck.IsOfGenericType(genericType, out Type? _); } - private static bool IsOfGenericType(this Type typeToCheck, Type genericType, out Type concreteGenericType) + private static bool IsOfGenericType(this Type? typeToCheck, Type genericType, out Type? concreteGenericType) { while (true) { diff --git a/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs b/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs index 81854dda5..35fbb444b 100644 --- a/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs +++ b/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs @@ -73,9 +73,8 @@ public class ColorGradient : IList, IList, INotifyCollectionC } else { - List colors = this.Select(c => c.Color).ToList(); for (int i = 0; i <= timesToRepeat; i++) - result.AddRange(colors); + result.AddRange(this.Select(c => c.Color)); } if (seamless && !IsSeamless()) @@ -87,9 +86,7 @@ public class ColorGradient : IList, IList, INotifyCollectionC /// /// Gets all the positions in the color gradient /// - /// - /// The amount of times to repeat the positions - /// + /// The amount of times to repeat the positions /// /// A boolean indicating whether to make the gradient seamless by adding the first color behind the /// last color @@ -120,7 +117,7 @@ public class ColorGradient : IList, IList, INotifyCollectionC // Compress current points evenly float compression = 1f - 1f / result.Count; for (int index = 0; index < result.Count; index++) - result[index] = result[index] * compression; + result[index] *= compression; // Add one extra point at the end result.Add(1f); } @@ -132,19 +129,30 @@ public class ColorGradient : IList, IList, INotifyCollectionC /// Gets a color at any position between 0.0 and 1.0 using interpolation /// /// A position between 0.0 and 1.0 - public SKColor GetColor(float position) + /// The amount of times to repeat the positions + /// + /// A boolean indicating whether to make the gradient seamless by adding the first color behind the + /// last color + /// + public SKColor GetColor(float position, int timesToRepeat = 0, bool seamless = false) { if (!this.Any()) return new SKColor(255, 255, 255); - ColorGradientStop[] stops = this.ToArray(); - if (position <= 0) return stops[0].Color; - if (position >= 1) return stops[^1].Color; - ColorGradientStop left = stops[0]; - ColorGradientStop? right = null; - foreach (ColorGradientStop stop in stops) + SKColor[] colors = GetColorsArray(timesToRepeat, seamless); + float[] stops = GetPositionsArray(timesToRepeat, seamless); + + // If at or over the edges, return the corresponding edge + if (position <= 0) return colors[0]; + if (position >= 1) return colors[^1]; + + // Walk through the stops until we find the one at or after the requested position, that becomes the right stop + // The left stop is the previous stop before the right one was found. + float left = stops[0]; + float? right = null; + foreach (float stop in stops) { - if (stop.Position >= position) + if (stop >= position) { right = stop; break; @@ -153,14 +161,22 @@ public class ColorGradient : IList, IList, INotifyCollectionC left = stop; } - if (right == null || left == right) - return left.Color; + // Get the left stop's color + SKColor leftColor = colors[Array.IndexOf(stops, left)]; - position = (float) Math.Round((position - left.Position) / (right.Position - left.Position), 2); - byte a = (byte) ((right.Color.Alpha - left.Color.Alpha) * position + left.Color.Alpha); - byte r = (byte) ((right.Color.Red - left.Color.Red) * position + left.Color.Red); - byte g = (byte) ((right.Color.Green - left.Color.Green) * position + left.Color.Green); - byte b = (byte) ((right.Color.Blue - left.Color.Blue) * position + left.Color.Blue); + // If no right stop was found or the left and right stops are on the same spot, return the left stop's color + if (right == null || left == right) + return leftColor; + + // Get the right stop's color + SKColor rightColor = colors[Array.IndexOf(stops, right)]; + + // Interpolate the position between the left and right color + position = MathF.Round((position - left) / (right.Value - left), 2); + byte a = (byte) ((rightColor.Alpha - leftColor.Alpha) * position + leftColor.Alpha); + byte r = (byte) ((rightColor.Red - leftColor.Red) * position + leftColor.Red); + byte g = (byte) ((rightColor.Green - leftColor.Green) * position + leftColor.Green); + byte b = (byte) ((rightColor.Blue - leftColor.Blue) * position + leftColor.Blue); return new SKColor(r, g, b, a); } @@ -561,7 +577,8 @@ public class ColorGradient : IList, IList, INotifyCollectionC OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, index)); } - public bool IsFixedSize { get; } + /// + public bool IsFixedSize => false; /// public ColorGradientStop this[int index] diff --git a/src/Artemis.Core/Models/Profile/Conditions/AlwaysOnCondition.cs b/src/Artemis.Core/Models/Profile/Conditions/AlwaysOnCondition.cs index 90c0a790a..a5463dfd3 100644 --- a/src/Artemis.Core/Models/Profile/Conditions/AlwaysOnCondition.cs +++ b/src/Artemis.Core/Models/Profile/Conditions/AlwaysOnCondition.cs @@ -4,14 +4,26 @@ using Artemis.Storage.Entities.Profile.Conditions; namespace Artemis.Core { + /// + /// Represents a condition that is always true. + /// public class AlwaysOnCondition : ICondition { + /// + /// 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; diff --git a/src/Artemis.Core/Models/Profile/Conditions/ICondition.cs b/src/Artemis.Core/Models/Profile/Conditions/ICondition.cs index a56394c49..bddd6867b 100644 --- a/src/Artemis.Core/Models/Profile/Conditions/ICondition.cs +++ b/src/Artemis.Core/Models/Profile/Conditions/ICondition.cs @@ -34,6 +34,9 @@ public interface ICondition : IDisposable, IStorageModel /// void UpdateTimeline(double deltaTime); + /// + /// 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 cd33f2d91..459e24e19 100644 --- a/src/Artemis.Core/Models/Profile/Conditions/PlayOnceCondition.cs +++ b/src/Artemis.Core/Models/Profile/Conditions/PlayOnceCondition.cs @@ -4,14 +4,26 @@ using Artemis.Storage.Entities.Profile.Conditions; namespace Artemis.Core { + /// + /// Represents a condition that plays once when its script evaluates to . + /// public class PlayOnceCondition : ICondition { + /// + /// 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; diff --git a/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs b/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs index fc4159ef8..637a1ea6e 100644 --- a/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs +++ b/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs @@ -30,6 +30,7 @@ namespace Artemis.Core protected LayerPropertyGroup() { // These are set right after construction to keep the constructor (and inherited constructs) clean + ProfileElement = null!; GroupDescription = null!; Path = ""; diff --git a/src/Artemis.Core/Plugins/LayerEffects/Internal/BaseLayerEffect.cs b/src/Artemis.Core/Plugins/LayerEffects/Internal/BaseLayerEffect.cs index 9692ac27c..bbd355e2c 100644 --- a/src/Artemis.Core/Plugins/LayerEffects/Internal/BaseLayerEffect.cs +++ b/src/Artemis.Core/Plugins/LayerEffects/Internal/BaseLayerEffect.cs @@ -11,7 +11,6 @@ namespace Artemis.Core.LayerEffects { private ILayerEffectConfigurationDialog? _configurationDialog; private LayerEffectDescriptor _descriptor; - private bool _suspended; private bool _hasBeenRenamed; private string _name; private int _order; diff --git a/src/Artemis.Core/Services/Interfaces/IGraphicsContextProvider.cs b/src/Artemis.Core/Services/Interfaces/IGraphicsContextProvider.cs index 26361fbe2..88a7dd917 100644 --- a/src/Artemis.Core/Services/Interfaces/IGraphicsContextProvider.cs +++ b/src/Artemis.Core/Services/Interfaces/IGraphicsContextProvider.cs @@ -3,8 +3,20 @@ using Artemis.Core.SkiaSharp; namespace Artemis.Core.Services; +/// +/// Represents a class that can provide one or more graphics instances by name. +/// public interface IGraphicsContextProvider { + /// + /// Gets a read only collection containing the names of all the graphics contexts supported by this provider. + /// IReadOnlyCollection GraphicsContextNames { get; } + + /// + /// Gets a managed graphics context by name. + /// + /// The name of the graphics context. + /// If found, an instance of the managed graphics context with the given ; otherwise . IManagedGraphicsContext? GetGraphicsContext(string name); } \ No newline at end of file diff --git a/src/Artemis.Core/Services/ModuleService.cs b/src/Artemis.Core/Services/ModuleService.cs index 956e69281..5c2640139 100644 --- a/src/Artemis.Core/Services/ModuleService.cs +++ b/src/Artemis.Core/Services/ModuleService.cs @@ -85,7 +85,7 @@ namespace Artemis.Core.Services } } - private void ActivationUpdateTimerOnElapsed(object sender, ElapsedEventArgs e) + private void ActivationUpdateTimerOnElapsed(object? sender, ElapsedEventArgs e) { UpdateModuleActivation(); } diff --git a/src/Artemis.Core/Services/Registration/Interfaces/ILayerBrushService.cs b/src/Artemis.Core/Services/Registration/Interfaces/ILayerBrushService.cs index 648495a55..6af01399e 100644 --- a/src/Artemis.Core/Services/Registration/Interfaces/ILayerBrushService.cs +++ b/src/Artemis.Core/Services/Registration/Interfaces/ILayerBrushService.cs @@ -24,10 +24,14 @@ namespace Artemis.Core.Services List GetLayerBrushes(); /// - /// Returns the descriptor of the default layer brush + /// Returns the descriptor of the default layer brush /// LayerBrushDescriptor? GetDefaultLayerBrush(); + /// + /// Applies the configured default brush to the provided . + /// + /// The layer to apply the default brush to. void ApplyDefaultBrush(Layer layer); } } \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj index 649015b88..2b4947080 100644 --- a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj +++ b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj @@ -1,4 +1,4 @@ - + Library net6.0 @@ -13,9 +13,6 @@ bin\Artemis.UI.Avalonia.Shared.xml - - - diff --git a/src/Artemis.UI.Shared/Behaviors/LostFocusNumberBoxBindingBehavior.cs b/src/Artemis.UI.Shared/Behaviors/LostFocusNumberBoxBindingBehavior.cs index cf004cf16..2b8c736cc 100644 --- a/src/Artemis.UI.Shared/Behaviors/LostFocusNumberBoxBindingBehavior.cs +++ b/src/Artemis.UI.Shared/Behaviors/LostFocusNumberBoxBindingBehavior.cs @@ -12,6 +12,9 @@ namespace Artemis.UI.Shared.Behaviors; /// public class LostFocusNumberBoxBindingBehavior : Behavior { + /// + /// Gets or sets the value of the binding. + /// public static readonly StyledProperty ValueProperty = AvaloniaProperty.Register( nameof(Value), defaultBindingMode: BindingMode.TwoWay); @@ -20,6 +23,9 @@ public class LostFocusNumberBoxBindingBehavior : Behavior ValueProperty.Changed.Subscribe(e => ((LostFocusNumberBoxBindingBehavior) e.Sender).OnBindingValueChanged()); } + /// + /// Gets or sets the value of the binding. + /// public double Value { get => GetValue(ValueProperty); diff --git a/src/Artemis.UI.Shared/Behaviors/LostFocusTextBoxBindingBehavior.cs b/src/Artemis.UI.Shared/Behaviors/LostFocusTextBoxBindingBehavior.cs index 961ea308f..c3b806fae 100644 --- a/src/Artemis.UI.Shared/Behaviors/LostFocusTextBoxBindingBehavior.cs +++ b/src/Artemis.UI.Shared/Behaviors/LostFocusTextBoxBindingBehavior.cs @@ -12,6 +12,9 @@ namespace Artemis.UI.Shared.Behaviors; /// public class LostFocusTextBoxBindingBehavior : Behavior { + /// + /// Gets or sets the value of the binding. + /// public static readonly StyledProperty TextProperty = AvaloniaProperty.Register( "Text", defaultBindingMode: BindingMode.TwoWay); @@ -20,6 +23,9 @@ public class LostFocusTextBoxBindingBehavior : Behavior TextProperty.Changed.Subscribe(e => ((LostFocusTextBoxBindingBehavior) e.Sender).OnBindingValueChanged()); } + /// + /// Gets or sets the value of the binding. + /// public string Text { get => GetValue(TextProperty); diff --git a/src/Artemis.UI.Shared/Behaviors/SliderPointerReleasedBindingBehavior.cs b/src/Artemis.UI.Shared/Behaviors/SliderPointerReleasedBindingBehavior.cs index 0fb302cea..9e193f92a 100644 --- a/src/Artemis.UI.Shared/Behaviors/SliderPointerReleasedBindingBehavior.cs +++ b/src/Artemis.UI.Shared/Behaviors/SliderPointerReleasedBindingBehavior.cs @@ -13,6 +13,9 @@ namespace Artemis.UI.Shared.Behaviors; /// public class SliderPointerReleasedBindingBehavior : Behavior { + /// + /// Gets or sets the value of the binding. + /// public static readonly StyledProperty ValueProperty = AvaloniaProperty.Register( nameof(Value), defaultBindingMode: BindingMode.TwoWay); @@ -21,6 +24,9 @@ public class SliderPointerReleasedBindingBehavior : Behavior ValueProperty.Changed.Subscribe(e => ((SliderPointerReleasedBindingBehavior) e.Sender).OnBindingValueChanged()); } + /// + /// Gets or sets the value of the binding. + /// public double Value { get => GetValue(ValueProperty); diff --git a/src/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs b/src/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs index 4f0c33187..b6cba7e35 100644 --- a/src/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs @@ -24,7 +24,7 @@ namespace Artemis.UI.Shared private readonly ObservableCollection<(Enum, string)> _currentValues = new(); private ComboBox? _enumComboBox; - private Type _currentType; + private Type? _currentType; /// /// Creates a new instance of the class. diff --git a/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPicker.cs b/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPicker.cs index 6eef1fb88..a50b90110 100644 --- a/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPicker.cs +++ b/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPicker.cs @@ -70,6 +70,9 @@ public class GradientPicker : TemplatedControl private ColorGradient? _lastColorGradient; private ColorPicker? _colorPicker; + /// + /// Creates a new instance of the class. + /// public GradientPicker() { _deleteStop = ReactiveCommand.Create(s => diff --git a/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPickerColorStop.cs b/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPickerColorStop.cs index a13e67bfa..832398f7e 100644 --- a/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPickerColorStop.cs +++ b/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPickerColorStop.cs @@ -127,14 +127,14 @@ public class GradientPickerColorStop : TemplatedControl { if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed || !ReferenceEquals(e.Pointer.Captured, this) || PositionReference == null) { - if (_draggingStop != ColorStop) + if (!Equals(_draggingStop, ColorStop)) return; _dragOffset = e.GetCurrentPoint(PositionReference).Position.X - GetPixelPosition(); } double position = e.GetCurrentPoint(PositionReference).Position.X - _dragOffset; - ColorStop.Position = MathF.Round((float) Math.Clamp(position / PositionReference.Bounds.Width, 0, 1), 3, MidpointRounding.AwayFromZero); + ColorStop.Position = MathF.Round((float) Math.Clamp(position / PositionReference?.Bounds.Width ?? 0, 0, 1), 3, MidpointRounding.AwayFromZero); e.Handled = true; } diff --git a/src/Artemis.UI.Shared/NullCommand.cs b/src/Artemis.UI.Shared/NullCommand.cs deleted file mode 100644 index 06e23ebbf..000000000 --- a/src/Artemis.UI.Shared/NullCommand.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Windows.Input; - -namespace Artemis.UI.Shared; - -/// -/// Represents a placeholder command that does nothing and can't be executed. -/// -public class NullCommand : ICommand -{ - private static readonly Lazy _instance = new(() => new NullCommand()); - - private NullCommand() - { - } - - /// - /// Gets the static instance of this command. - /// - public static ICommand Instance => _instance.Value; - - /// - public event EventHandler? CanExecuteChanged; - - /// - public void Execute(object? parameter) - { - throw new InvalidOperationException("NullCommand cannot be executed"); - } - - /// - public bool CanExecute(object? parameter) - { - return false; - } -} \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Services/ProfileEditor/Commands/ChangeConditionType.cs b/src/Artemis.UI.Shared/Services/ProfileEditor/Commands/ChangeConditionType.cs index e69a29f12..92fd2fcf8 100644 --- a/src/Artemis.UI.Shared/Services/ProfileEditor/Commands/ChangeConditionType.cs +++ b/src/Artemis.UI.Shared/Services/ProfileEditor/Commands/ChangeConditionType.cs @@ -9,8 +9,8 @@ namespace Artemis.UI.Shared.Services.ProfileEditor.Commands; public class ChangeConditionType : IProfileEditorCommand, IDisposable { private readonly RenderProfileElement _profileElement; - private readonly ICondition? _condition; - private readonly ICondition? _oldCondition; + private readonly ICondition _condition; + private readonly ICondition _oldCondition; private bool _executed; /// @@ -18,7 +18,7 @@ public class ChangeConditionType : IProfileEditorCommand, IDisposable /// /// The profile element whose condition type to change. /// The new condition type. - public ChangeConditionType(RenderProfileElement profileElement, ICondition? condition) + public ChangeConditionType(RenderProfileElement profileElement, ICondition condition) { _profileElement = profileElement; _condition = condition; diff --git a/src/Artemis.UI.Shared/Services/ProfileEditor/Commands/ChangeElementDisplayCondition.cs b/src/Artemis.UI.Shared/Services/ProfileEditor/Commands/ChangeElementDisplayCondition.cs index 6241db06a..bf2f0ce06 100644 --- a/src/Artemis.UI.Shared/Services/ProfileEditor/Commands/ChangeElementDisplayCondition.cs +++ b/src/Artemis.UI.Shared/Services/ProfileEditor/Commands/ChangeElementDisplayCondition.cs @@ -8,8 +8,8 @@ namespace Artemis.UI.Shared.Services.ProfileEditor.Commands; /// public class ChangeElementDisplayCondition : IProfileEditorCommand, IDisposable { - private readonly ICondition? _condition; - private readonly ICondition? _oldCondition; + private readonly ICondition _condition; + private readonly ICondition _oldCondition; private readonly RenderProfileElement _profileElement; private bool _executed; @@ -18,7 +18,7 @@ public class ChangeElementDisplayCondition : IProfileEditorCommand, IDisposable /// /// The render profile element whose display condition to change. /// The new display condition. - public ChangeElementDisplayCondition(RenderProfileElement profileElement, ICondition? condition) + public ChangeElementDisplayCondition(RenderProfileElement profileElement, ICondition condition) { _profileElement = profileElement; _condition = condition;