mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Code cleanup
This commit is contained in:
1 parent
0c245ba83d
commit
ae330c3769
73 files changed
+372
-364
No files matched your search
@@ -6,7 +6,7 @@ namespace Artemis.Core.Extensions
|
||||
{
|
||||
public static int RoundToInt(this float number)
|
||||
{
|
||||
return (int)Math.Round(number, MidpointRounding.AwayFromZero);
|
||||
return (int) Math.Round(number, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,7 @@ namespace Artemis.Core.JsonConverters
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace Artemis.Core.Models.Profile.KeyframeEngines
|
||||
|
||||
protected override object GetInterpolatedValue()
|
||||
{
|
||||
var currentKeyframe = (Keyframe<SKSize>)CurrentKeyframe;
|
||||
var nextKeyframe = (Keyframe<SKSize>)NextKeyframe;
|
||||
var currentKeyframe = (Keyframe<SKSize>) CurrentKeyframe;
|
||||
var nextKeyframe = (Keyframe<SKSize>) NextKeyframe;
|
||||
|
||||
var widthDiff = nextKeyframe.Value.Width - currentKeyframe.Value.Width;
|
||||
var heightDiff = nextKeyframe.Value.Height - currentKeyframe.Value.Height;
|
||||
|
||||
@@ -328,7 +328,7 @@ namespace Artemis.Core.Models.Profile
|
||||
|
||||
var propertyEntity = LayerEntity.PropertyEntities.FirstOrDefault(p => p.Id == layerProperty.Id && p.ValueType == layerProperty.Type.Name);
|
||||
// TODO: Catch serialization exceptions and log them
|
||||
if (propertyEntity != null)
|
||||
if (propertyEntity != null)
|
||||
layerProperty.ApplyToProperty(propertyEntity);
|
||||
|
||||
_properties.Add(layerProperty.Id, layerProperty);
|
||||
@@ -354,7 +354,8 @@ namespace Artemis.Core.Models.Profile
|
||||
|
||||
private void CreateDefaultProperties()
|
||||
{
|
||||
var transformProperty = new LayerProperty<object>(this, null, "Core.Transform", "Transform", "The default properties collection every layer has, allows you to transform the shape.") {ExpandByDefault = true};
|
||||
var transformProperty = new LayerProperty<object>(this, null, "Core.Transform", "Transform", "The default properties collection every layer has, allows you to transform the shape.")
|
||||
{ExpandByDefault = true};
|
||||
AnchorPointProperty = new LayerProperty<SKPoint>(this, transformProperty, "Core.AnchorPoint", "Anchor Point", "The point at which the shape is attached to its position.");
|
||||
PositionProperty = new LayerProperty<SKPoint>(this, transformProperty, "Core.Position", "Position", "The position of the shape.");
|
||||
SizeProperty = new LayerProperty<SKSize>(this, transformProperty, "Core.Size", "Size", "The size of the shape.") {InputAffix = "%"};
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
||||
public string InputAffix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether this property can use keyframes, True by default.
|
||||
/// Gets or sets whether this property can use keyframes, True by default.
|
||||
/// </summary>
|
||||
public bool CanUseKeyframes { get; set; }
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace Artemis.Core.Models.Profile.LayerProperties
|
||||
@@ -26,8 +25,8 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
||||
{
|
||||
get
|
||||
{
|
||||
var currentValue = base.GetCurrentValue();
|
||||
return currentValue == null ? default : (T)currentValue;
|
||||
var currentValue = GetCurrentValue();
|
||||
return currentValue == null ? default : (T) currentValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,10 @@ namespace Artemis.Core.Models.Profile.LayerShapes
|
||||
/// Updates Position and Size using the provided unscaled rectangle
|
||||
/// </summary>
|
||||
/// <param name="rect">An unscaled rectangle which is relative to the layer (1.0 being full width/height, 0.5 being half).</param>
|
||||
/// <param name="time">An optional timespan to indicate where to set the properties, if null the properties' base values will be used.</param>
|
||||
/// <param name="time">
|
||||
/// An optional timespan to indicate where to set the properties, if null the properties' base values
|
||||
/// will be used.
|
||||
/// </param>
|
||||
public void SetFromUnscaledRectangle(SKRect rect, TimeSpan? time)
|
||||
{
|
||||
if (!Layer.Leds.Any())
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
using System;
|
||||
using System.Xml.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
{
|
||||
public abstract class LayerBrushSettings : PropertyChangedBase
|
||||
{
|
||||
private Action<Action> _propertyChangedDispatcher = Execute.DefaultPropertyChangedDispatcher;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the dispatcher to use to dispatch PropertyChanged events. Defaults to Execute.DefaultPropertyChangedDispatcher
|
||||
/// Gets or sets the dispatcher to use to dispatch PropertyChanged events. Defaults to
|
||||
/// Execute.DefaultPropertyChangedDispatcher
|
||||
/// </summary>
|
||||
[System.Xml.Serialization.XmlIgnore]
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
public override Action<Action> PropertyChangedDispatcher
|
||||
{
|
||||
get { return this._propertyChangedDispatcher; }
|
||||
set { this._propertyChangedDispatcher = value; }
|
||||
}
|
||||
[XmlIgnore]
|
||||
[JsonIgnore]
|
||||
public override Action<Action> PropertyChangedDispatcher { get; set; } = Execute.DefaultPropertyChangedDispatcher;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace Artemis.Core.Plugins.Models
|
||||
}
|
||||
catch (JsonReaderException)
|
||||
{
|
||||
Value = default(T);
|
||||
Value = default;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Artemis.Core.Plugins.Models
|
||||
/// <param name="name">The name of the setting</param>
|
||||
/// <param name="defaultValue">The default value to use if the setting does not exist yet</param>
|
||||
/// <returns></returns>
|
||||
public PluginSetting<T> GetSetting<T>(string name, T defaultValue = default(T))
|
||||
public PluginSetting<T> GetSetting<T>(string name, T defaultValue = default)
|
||||
{
|
||||
lock (_settingEntities)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Artemis.Core.Extensions;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using RGB.NET.Core;
|
||||
|
||||
@@ -42,14 +42,6 @@ namespace Artemis.Core.Services
|
||||
Task.Run(Initialize);
|
||||
}
|
||||
|
||||
private void ConfigureJsonConvert()
|
||||
{
|
||||
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
||||
{
|
||||
Converters = new List<JsonConverter> { new SKColorConverter() }
|
||||
};
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Dispose services
|
||||
@@ -58,6 +50,14 @@ namespace Artemis.Core.Services
|
||||
|
||||
public bool IsInitialized { get; set; }
|
||||
|
||||
private void ConfigureJsonConvert()
|
||||
{
|
||||
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
||||
{
|
||||
Converters = new List<JsonConverter> {new SKColorConverter()}
|
||||
};
|
||||
}
|
||||
|
||||
private async Task Initialize()
|
||||
{
|
||||
if (IsInitialized)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.KeyframeEngines;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
@@ -61,9 +60,7 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
// If no settings found, provide a fresh instance of the settings type
|
||||
else if (settingsType != null)
|
||||
{
|
||||
settingsInstance = Activator.CreateInstance(settingsType);
|
||||
}
|
||||
|
||||
var arguments = new IParameter[]
|
||||
{
|
||||
@@ -72,7 +69,7 @@ namespace Artemis.Core.Services
|
||||
new ConstructorArgument("descriptor", brushDescriptor)
|
||||
};
|
||||
var layerElement = (LayerBrush) _kernel.Get(brushDescriptor.LayerBrushType, arguments);
|
||||
layer.LayerBrush = (layerElement);
|
||||
layer.LayerBrush = layerElement;
|
||||
|
||||
return layerElement;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Artemis.Core.Services
|
||||
_pluginSettings = new PluginSettings(pluginInfo, pluginSettingRepository);
|
||||
}
|
||||
|
||||
public PluginSetting<T> GetSetting<T>(string name, T defaultValue = default(T))
|
||||
public PluginSetting<T> GetSetting<T>(string name, T defaultValue = default)
|
||||
{
|
||||
return _pluginSettings.GetSetting(name, defaultValue);
|
||||
}
|
||||
@@ -28,6 +28,6 @@ namespace Artemis.Core.Services
|
||||
/// </summary>
|
||||
public interface ISettingsService : IProtectedArtemisService
|
||||
{
|
||||
PluginSetting<T> GetSetting<T>(string name, T defaultValue = default(T));
|
||||
PluginSetting<T> GetSetting<T>(string name, T defaultValue = default);
|
||||
}
|
||||
}
|
||||
@@ -160,9 +160,7 @@ namespace Artemis.Core.Services.Storage
|
||||
{
|
||||
// Only instantiate engines for properties without an existing engine instance
|
||||
foreach (var layerProperty in profile.GetAllLayers().SelectMany(l => l.Properties).Where(p => p.KeyframeEngine == null))
|
||||
{
|
||||
_layerService.InstantiateKeyframeEngine(layerProperty);
|
||||
}
|
||||
}
|
||||
|
||||
private void ActiveProfilesPopulateLeds(ArtemisSurface surface)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<packages>
|
||||
<package id="AppDomainToolkit" version="1.0.4.3" targetFramework="net461" />
|
||||
<package id="Ben.Demystifier" version="0.1.4" targetFramework="net472" />
|
||||
|
||||
Reference in new issue
Block a user