1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 21:38:38 +00:00

Code style - Omit the type in a new expressions

This commit is contained in:
SpoinkyNL 2020-12-18 17:54:01 +01:00
parent 099f56f4fe
commit 10e6cdc54b
117 changed files with 251 additions and 252 deletions

View File

@ -35,7 +35,7 @@ namespace Artemis.Core
/// <summary>
/// The plugin info used by core components of Artemis
/// </summary>
public static readonly PluginInfo CorePluginInfo = new PluginInfo
public static readonly PluginInfo CorePluginInfo = new()
{
Guid = Guid.Parse("ffffffff-ffff-ffff-ffff-ffffffffffff"), Name = "Artemis Core", Version = new Version(2, 0)
};
@ -43,16 +43,16 @@ namespace Artemis.Core
/// <summary>
/// The plugin used by core components of Artemis
/// </summary>
public static readonly Plugin CorePlugin = new Plugin(CorePluginInfo, new DirectoryInfo(ApplicationFolder), null);
public static readonly Plugin CorePlugin = new(CorePluginInfo, new DirectoryInfo(ApplicationFolder), null);
internal static readonly CorePluginFeature CorePluginFeature = new CorePluginFeature {Plugin = CorePlugin};
internal static readonly EffectPlaceholderPlugin EffectPlaceholderPlugin = new EffectPlaceholderPlugin {Plugin = CorePlugin};
internal static readonly CorePluginFeature CorePluginFeature = new() {Plugin = CorePlugin};
internal static readonly EffectPlaceholderPlugin EffectPlaceholderPlugin = new() {Plugin = CorePlugin};
internal static JsonSerializerSettings JsonConvertSettings = new JsonSerializerSettings
internal static JsonSerializerSettings JsonConvertSettings = new()
{
Converters = new List<JsonConverter> {new SKColorConverter(), new ForgivingIntConverter()}
};
internal static JsonSerializerSettings JsonConvertTypedSettings = new JsonSerializerSettings
internal static JsonSerializerSettings JsonConvertTypedSettings = new()
{
TypeNameHandling = TypeNameHandling.All,
Converters = new List<JsonConverter> { new SKColorConverter(), new ForgivingIntConverter() }

View File

@ -84,7 +84,7 @@ namespace Artemis.Core
IEnumerable<TSource> _()
{
HashSet<TKey> knownKeys = new HashSet<TKey>(comparer);
HashSet<TKey> knownKeys = new(comparer);
foreach (TSource element in source)
{
if (knownKeys.Add(keySelector(element)))

View File

@ -19,7 +19,7 @@ namespace Artemis.Core
public static string GetProcessFilename(this Process p)
{
int capacity = 2000;
StringBuilder builder = new StringBuilder(capacity);
StringBuilder builder = new(capacity);
IntPtr ptr = OpenProcess(ProcessAccessFlags.QueryLimitedInformation, false, p.Id);
if (!QueryFullProcessImageName(ptr, 0, builder, ref capacity)) return string.Empty;

View File

@ -8,7 +8,7 @@ namespace Artemis.Core
{
public static string GetDeviceIdentifier(this IRGBDevice rgbDevice)
{
StringBuilder builder = new StringBuilder();
StringBuilder builder = new();
builder.Append(rgbDevice.DeviceInfo.DeviceName);
builder.Append('-');
builder.Append(rgbDevice.DeviceInfo.Manufacturer);

View File

@ -16,7 +16,7 @@ namespace Artemis.Core
/// <returns>The RGB.NET color</returns>
public static Color ToRgbColor(this SKColor color)
{
return new Color(color.Alpha, color.Red, color.Green, color.Blue);
return new(color.Alpha, color.Red, color.Green, color.Blue);
}
/// <summary>
@ -49,7 +49,7 @@ namespace Artemis.Core
/// <returns>The sum of the two colors</returns>
public static SKColor Sum(this SKColor a, SKColor b)
{
return new SKColor(
return new(
ClampToByte(a.Red + b.Red),
ClampToByte(a.Green + b.Green),
ClampToByte(a.Blue + b.Blue),

View File

@ -11,7 +11,7 @@ namespace Artemis.Core
/// </summary>
public static class TypeExtensions
{
private static readonly Dictionary<Type, List<Type>> PrimitiveTypeConversions = new Dictionary<Type, List<Type>>
private static readonly Dictionary<Type, List<Type>> PrimitiveTypeConversions = new()
{
{typeof(decimal), new List<Type> {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(char)}},
{typeof(double), new List<Type> {typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(char), typeof(float)}},
@ -24,7 +24,7 @@ namespace Artemis.Core
{typeof(short), new List<Type> {typeof(byte)}}
};
private static readonly Dictionary<Type, string> TypeKeywords = new Dictionary<Type, string>
private static readonly Dictionary<Type, string> TypeKeywords = new()
{
{typeof(bool), "bool"},
{typeof(byte), "byte"},

View File

@ -34,7 +34,7 @@ namespace Artemis.Core
return Stops.OrderBy(c => c.Position).Select(c => c.Color).ToArray();
List<SKColor> colors = Stops.OrderBy(c => c.Position).Select(c => c.Color).ToList();
List<SKColor> result = new List<SKColor>();
List<SKColor> result = new();
for (int i = 0; i <= timesToRepeat; i++)
result.AddRange(colors);
@ -57,7 +57,7 @@ namespace Artemis.Core
// Create stops and a list of divided stops
List<float> stops = Stops.OrderBy(c => c.Position).Select(c => c.Position / (timesToRepeat + 1)).ToList();
List<float> result = new List<float>();
List<float> result = new();
// For each repeat cycle, add the base stops to the end result
for (int i = 0; i <= timesToRepeat; i++)
@ -120,7 +120,7 @@ namespace Artemis.Core
public static ColorGradient GetUnicornBarf()
{
const int amount = 8;
ColorGradient gradient = new ColorGradient();
ColorGradient gradient = new();
for (int i = 0; i <= amount; i++)
{

View File

@ -11,7 +11,7 @@ namespace Artemis.Core
/// </summary>
public abstract class DataModelConditionPart : IDisposable
{
private readonly List<DataModelConditionPart> _children = new List<DataModelConditionPart>();
private readonly List<DataModelConditionPart> _children = new();
/// <summary>
/// Gets the parent of this part

View File

@ -153,7 +153,7 @@ namespace Artemis.Core
return;
// Ensure the list path is valid and points to a list
DataModelPath eventPath = new DataModelPath(null, Entity.EventPath);
DataModelPath eventPath = new(null, Entity.EventPath);
// Can't check this on an invalid list, if it becomes valid later lets hope for the best
if (eventPath.IsValid && !PointsToEvent(eventPath))
return;

View File

@ -177,7 +177,7 @@ namespace Artemis.Core
return;
// Ensure the list path is valid and points to a list
DataModelPath listPath = new DataModelPath(null, Entity.ListPath);
DataModelPath listPath = new(null, Entity.ListPath);
Type listType = listPath.GetPropertyType()!;
// Can't check this on an invalid list, if it becomes valid later lets hope for the best
if (listPath.IsValid && !PointsToList(listPath))

View File

@ -11,7 +11,7 @@ namespace Artemis.Core
/// </summary>
public class ConditionalDataBinding<TLayerProperty, TProperty> : IDataBindingMode<TLayerProperty, TProperty>
{
private readonly List<DataBindingCondition<TLayerProperty, TProperty>> _conditions = new List<DataBindingCondition<TLayerProperty, TProperty>>();
private readonly List<DataBindingCondition<TLayerProperty, TProperty>> _conditions = new();
private bool _disposed;
internal ConditionalDataBinding(DataBinding<TLayerProperty, TProperty> dataBinding, ConditionalDataBindingEntity entity)
@ -81,7 +81,7 @@ namespace Artemis.Core
if (_disposed)
throw new ObjectDisposedException("ConditionalDataBinding");
DataBindingCondition<TLayerProperty, TProperty> condition = new DataBindingCondition<TLayerProperty, TProperty>(this);
DataBindingCondition<TLayerProperty, TProperty> condition = new(this);
_conditions.Add(condition);
ApplyOrder();

View File

@ -10,7 +10,7 @@ namespace Artemis.Core
/// </summary>
public class DirectDataBinding<TLayerProperty, TProperty> : IDataBindingMode<TLayerProperty, TProperty>
{
private readonly List<DataBindingModifier<TLayerProperty, TProperty>> _modifiers = new List<DataBindingModifier<TLayerProperty, TProperty>>();
private readonly List<DataBindingModifier<TLayerProperty, TProperty>> _modifiers = new();
private bool _disposed;
internal DirectDataBinding(DataBinding<TLayerProperty, TProperty> dataBinding, DirectDataBindingEntity entity)
@ -156,7 +156,7 @@ namespace Artemis.Core
if (_disposed)
throw new ObjectDisposedException("DirectDataBinding");
DataBindingModifier<TLayerProperty, TProperty> modifier = new DataBindingModifier<TLayerProperty, TProperty>(this, type);
DataBindingModifier<TLayerProperty, TProperty> modifier = new(this, type);
_modifiers.Add(modifier);
ApplyOrder();

View File

@ -47,7 +47,7 @@ namespace Artemis.Core
/// <para>Always empty if <see cref="TrackHistory" /> is <see langword="false" /></para>
/// </summary>
[DataModelProperty(Description = "The arguments of the last time this event triggered")]
public Queue<T> EventArgumentsHistory { get; } = new Queue<T>(20);
public Queue<T> EventArgumentsHistory { get; } = new(20);
/// <summary>
/// Trigger the event with the given <paramref name="eventArgs" />
@ -157,14 +157,14 @@ namespace Artemis.Core
/// <para>Always empty if <see cref="TrackHistory" /> is <see langword="false" /></para>
/// </summary>
[DataModelProperty(Description = "The arguments of the last time this event triggered")]
public Queue<DataModelEventArgs> EventArgumentsHistory { get; } = new Queue<DataModelEventArgs>(20);
public Queue<DataModelEventArgs> EventArgumentsHistory { get; } = new(20);
/// <summary>
/// Trigger the event
/// </summary>
public void Trigger()
{
DataModelEventArgs eventArgs = new DataModelEventArgs {TriggerTime = DateTime.Now};
DataModelEventArgs eventArgs = new() {TriggerTime = DateTime.Now};
LastEventArguments = eventArgs;
LastTrigger = DateTime.Now;

View File

@ -192,7 +192,7 @@ namespace Artemis.Core
if (Target == null)
return;
DataModelPathSegment startSegment = new DataModelPathSegment(this, "target", "target");
DataModelPathSegment startSegment = new(this, "target", "target");
startSegment.Node = _segments.AddFirst(startSegment);
// On an empty path don't bother processing segments

View File

@ -68,7 +68,7 @@ namespace Artemis.Core
/// <inheritdoc />
public override List<ILayerProperty> GetAllLayerProperties()
{
List<ILayerProperty> result = new List<ILayerProperty>();
List<ILayerProperty> result = new();
foreach (BaseLayerEffect layerEffect in LayerEffects)
if (layerEffect.BaseProperties != null)
result.AddRange(layerEffect.BaseProperties.GetAllLayerProperties());
@ -151,7 +151,7 @@ namespace Artemis.Core
if (Disposed)
throw new ObjectDisposedException("Folder");
SKPath path = new SKPath {FillType = SKPathFillType.Winding};
SKPath path = new() {FillType = SKPathFillType.Winding};
foreach (ProfileElement child in Children)
if (child is RenderProfileElement effectChild && effectChild.Path != null)
path.AddPath(effectChild.Path);

View File

@ -125,7 +125,7 @@ namespace Artemis.Core
/// <inheritdoc />
public override List<ILayerProperty> GetAllLayerProperties()
{
List<ILayerProperty> result = new List<ILayerProperty>();
List<ILayerProperty> result = new();
result.AddRange(General.GetAllLayerProperties());
result.AddRange(Transform.GetAllLayerProperties());
if (LayerBrush?.BaseProperties != null)
@ -221,7 +221,7 @@ namespace Artemis.Core
LayerEntity.Leds.Clear();
foreach (ArtemisLed artemisLed in Leds)
{
LedEntity ledEntity = new LedEntity
LedEntity ledEntity = new()
{
DeviceIdentifier = artemisLed.Device.RgbDevice.GetDeviceIdentifier(),
LedName = artemisLed.RgbLed.Id.ToString()
@ -336,7 +336,7 @@ namespace Artemis.Core
Renderer.Paint.BlendMode = General.BlendMode.CurrentValue;
Renderer.Paint.Color = new SKColor(0, 0, 0, (byte) (Transform.Opacity.CurrentValue * 2.55f));
using SKPath renderPath = new SKPath();
using SKPath renderPath = new();
if (General.ShapeType.CurrentValue == LayerShapeType.Rectangle)
renderPath.AddRect(Renderer.Path.Bounds);
else
@ -415,7 +415,7 @@ namespace Artemis.Core
}
else
{
SKPath path = new SKPath {FillType = SKPathFillType.Winding};
SKPath path = new() {FillType = SKPathFillType.Winding};
foreach (ArtemisLed artemisLed in Leds)
path.AddRect(artemisLed.AbsoluteRectangle);
@ -569,7 +569,7 @@ namespace Artemis.Core
if (Disposed)
throw new ObjectDisposedException("Layer");
List<ArtemisLed> leds = new List<ArtemisLed>();
List<ArtemisLed> leds = new();
// Get the surface LEDs for this layer
List<ArtemisLed> availableLeds = surface.Devices.SelectMany(d => d.Leds).ToList();

View File

@ -292,7 +292,7 @@ namespace Artemis.Core
if (value == null)
return null;
LayerPropertyKeyframe<T> keyframe = new LayerPropertyKeyframe<T>(
LayerPropertyKeyframe<T> keyframe = new(
CoreJson.DeserializeObject<T>(keyframeEntity.Value)!, keyframeEntity.Position, (Easings.Functions) keyframeEntity.EasingFunction, this
);
AddKeyframe(keyframe);
@ -366,9 +366,9 @@ namespace Artemis.Core
#region Data bindings
// ReSharper disable InconsistentNaming
internal readonly List<IDataBindingRegistration> _dataBindingRegistrations = new List<IDataBindingRegistration>();
internal readonly List<IDataBindingRegistration> _dataBindingRegistrations = new();
internal readonly List<IDataBinding> _dataBindings = new List<IDataBinding>();
internal readonly List<IDataBinding> _dataBindings = new();
// ReSharper restore InconsistentNaming
/// <summary>
@ -444,7 +444,7 @@ namespace Artemis.Core
if (dataBindingRegistration.DataBinding != null)
throw new ArtemisCoreException("Provided data binding registration already has an enabled data binding");
DataBinding<T, TProperty> dataBinding = new DataBinding<T, TProperty>(dataBindingRegistration);
DataBinding<T, TProperty> dataBinding = new(dataBindingRegistration);
_dataBindings.Add(dataBinding);
OnDataBindingEnabled(new LayerPropertyEventArgs<T>(dataBinding.LayerProperty));

View File

@ -66,7 +66,7 @@ namespace Artemis.Core
/// <inheritdoc />
public KeyframeEntity GetKeyframeEntity()
{
return new KeyframeEntity
return new()
{
Value = CoreJson.SerializeObject(Value),
Position = Position,

View File

@ -113,7 +113,7 @@ namespace Artemis.Core
if (!PropertiesInitialized)
return new List<ILayerProperty>();
List<ILayerProperty> result = new List<ILayerProperty>(LayerProperties);
List<ILayerProperty> result = new(LayerProperties);
foreach (LayerPropertyGroup layerPropertyGroup in LayerPropertyGroups)
result.AddRange(layerPropertyGroup.GetAllLayerProperties());

View File

@ -14,7 +14,7 @@ namespace Artemis.Core
/// <inheritdoc />
public override void CalculateRenderProperties()
{
SKPath path = new SKPath();
SKPath path = new();
path.AddOval(SKRect.Create(Layer.Bounds.Width, Layer.Bounds.Height));
Path = path;
}

View File

@ -14,7 +14,7 @@ namespace Artemis.Core
/// <inheritdoc />
public override void CalculateRenderProperties()
{
SKPath path = new SKPath();
SKPath path = new();
path.AddRect(SKRect.Create(Layer.Bounds.Width, Layer.Bounds.Height));
Path = path;
}

View File

@ -12,7 +12,7 @@ namespace Artemis.Core
/// </summary>
public sealed class Profile : ProfileElement
{
private readonly object _lock = new object();
private readonly object _lock = new();
private bool _isActivated;
internal Profile(ProfileModule module, string name) : base(null!)
@ -26,7 +26,7 @@ namespace Artemis.Core
UndoStack = new Stack<string>();
RedoStack = new Stack<string>();
Folder _ = new Folder(this, "Root folder");
Folder _ = new(this, "Root folder");
Save();
}
@ -168,7 +168,7 @@ namespace Artemis.Core
FolderEntity? rootFolder = ProfileEntity.Folders.FirstOrDefault(f => f.ParentId == EntityId);
if (rootFolder == null)
{
Folder _ = new Folder(this, "Root folder");
Folder _ = new(this, "Root folder");
}
else
{

View File

@ -189,7 +189,7 @@ namespace Artemis.Core
if (Disposed)
throw new ObjectDisposedException(GetType().Name);
List<Folder> folders = new List<Folder>();
List<Folder> folders = new();
foreach (Folder childFolder in Children.Where(c => c is Folder).Cast<Folder>())
{
// Add all folders in this element
@ -210,7 +210,7 @@ namespace Artemis.Core
if (Disposed)
throw new ObjectDisposedException(GetType().Name);
List<Layer> layers = new List<Layer>();
List<Layer> layers = new();
// Add all layers in this element
layers.AddRange(Children.Where(c => c is Layer).Cast<Layer>());

View File

@ -67,7 +67,7 @@ namespace Artemis.Core
RenderElementEntity.LayerEffects.Clear();
foreach (BaseLayerEffect layerEffect in LayerEffects)
{
LayerEffectEntity layerEffectEntity = new LayerEffectEntity
LayerEffectEntity layerEffectEntity = new()
{
Id = layerEffect.EntityId,
ProviderId = layerEffect.Descriptor?.PlaceholderFor ?? layerEffect.ProviderId,
@ -208,7 +208,7 @@ namespace Artemis.Core
if (descriptor == null)
throw new ArgumentNullException(nameof(descriptor));
LayerEffectEntity entity = new LayerEffectEntity
LayerEffectEntity entity = new()
{
Id = Guid.NewGuid(),
Enabled = true,

View File

@ -12,7 +12,7 @@ namespace Artemis.Core
public class Timeline : CorePropertyChanged, IStorageModel
{
private const int MaxExtraTimelines = 15;
private readonly object _lock = new object();
private readonly object _lock = new();
/// <summary>
/// Creates a new instance of the <see cref="Timeline" /> class

View File

@ -288,7 +288,7 @@ namespace Artemis.Core
foreach (ArtemisLed led in Leds)
led.CalculateRectangles();
SKPath path = new SKPath {FillType = SKPathFillType.Winding};
SKPath path = new() {FillType = SKPathFillType.Winding};
foreach (ArtemisLed artemisLed in Leds)
path.AddRect(artemisLed.AbsoluteRectangle);

View File

@ -12,8 +12,8 @@ namespace Artemis.Core
/// </summary>
public class ArtemisSurface : CorePropertyChanged
{
private List<ArtemisDevice> _devices = new List<ArtemisDevice>();
private ReadOnlyDictionary<Led, ArtemisLed> _ledMap = new ReadOnlyDictionary<Led, ArtemisLed>(new Dictionary<Led, ArtemisLed>());
private List<ArtemisDevice> _devices = new();
private ReadOnlyDictionary<Led, ArtemisLed> _ledMap = new(new Dictionary<Led, ArtemisLed>());
private bool _isActive;
private string _name;

View File

@ -8,7 +8,7 @@ namespace Artemis.Core.Ninject
{
internal class LoggerProvider : Provider<ILogger>
{
internal static readonly LoggingLevelSwitch LoggingLevelSwitch = new LoggingLevelSwitch(LogEventLevel.Verbose);
internal static readonly LoggingLevelSwitch LoggingLevelSwitch = new(LogEventLevel.Verbose);
private static readonly ILogger Logger = new LoggerConfiguration()
.Enrich.FromLogContext()

View File

@ -9,7 +9,7 @@ namespace Artemis.Core.Ninject
// TODO: Investigate if this can't just be set as a constant on the plugin child kernel
internal class PluginSettingsProvider : Provider<PluginSettings>
{
private static readonly List<PluginSettings> PluginSettings = new List<PluginSettings>();
private static readonly List<PluginSettings> PluginSettings = new();
private readonly IPluginRepository _pluginRepository;
private readonly IPluginManagementService _pluginManagementService;
@ -41,7 +41,7 @@ namespace Artemis.Core.Ninject
if (existingSettings != null)
return existingSettings;
PluginSettings? settings = new PluginSettings(plugin, _pluginRepository);
PluginSettings? settings = new(plugin, _pluginRepository);
PluginSettings.Add(settings);
return settings;
}

View File

@ -13,7 +13,7 @@ namespace Artemis.Core.DataModelExpansions
/// </summary>
public abstract class DataModel
{
private readonly Dictionary<string, DataModel> _dynamicDataModels = new Dictionary<string, DataModel>();
private readonly Dictionary<string, DataModel> _dynamicDataModels = new();
/// <summary>
/// Creates a new instance of the <see cref="DataModel" /> class
@ -47,7 +47,7 @@ namespace Artemis.Core.DataModelExpansions
/// Gets an read-only dictionary of all dynamic data models
/// </summary>
[DataModelIgnore]
public ReadOnlyDictionary<string, DataModel> DynamicDataModels => new ReadOnlyDictionary<string, DataModel>(_dynamicDataModels);
public ReadOnlyDictionary<string, DataModel> DynamicDataModels => new(_dynamicDataModels);
/// <summary>
/// Returns a read-only collection of all properties in this datamodel that are to be ignored

View File

@ -13,7 +13,7 @@ namespace Artemis.Core.DataModelExpansions
/// <summary>
/// Gets a list of all properties ignored at runtime using <c>IgnoreProperty(x => x.y)</c>
/// </summary>
protected internal readonly List<PropertyInfo> HiddenPropertiesList = new List<PropertyInfo>();
protected internal readonly List<PropertyInfo> HiddenPropertiesList = new();
/// <summary>
/// Gets a list of all properties ignored at runtime using <c>IgnoreProperty(x => x.y)</c>
@ -41,7 +41,7 @@ namespace Artemis.Core.DataModelExpansions
/// <returns></returns>
public virtual DataModelPropertyAttribute GetDataModelDescription()
{
return new DataModelPropertyAttribute {Name = Plugin.Info.Name, Description = Plugin.Info.Description};
return new() {Name = Plugin.Info.Name, Description = Plugin.Info.Description};
}
}
}

View File

@ -34,7 +34,7 @@ namespace Artemis.Core.DeviceProviders
[Inject]
public ILogger? Logger { get; set; }
internal Dictionary<IRGBDevice, string> DeviceLayoutPaths { get; set; } = new Dictionary<IRGBDevice, string>();
internal Dictionary<IRGBDevice, string> DeviceLayoutPaths { get; set; } = new();
/// <inheritdoc />
public override void Disable()

View File

@ -41,7 +41,7 @@ namespace Artemis.Core.LayerBrushes
if (!IsEnabled)
throw new ArtemisPluginException(Plugin, "Can only add a layer brush descriptor when the plugin is enabled");
LayerBrushDescriptor descriptor = new LayerBrushDescriptor(displayName, description, icon, typeof(T), this);
LayerBrushDescriptor descriptor = new(displayName, description, icon, typeof(T), this);
_layerBrushDescriptors.Add(descriptor);
LayerBrushStore.Add(descriptor);
}

View File

@ -34,8 +34,8 @@ namespace Artemis.Core.LayerBrushes
if (Layer.General.TransformMode.CurrentValue == LayerTransformMode.Normal && SupportsTransformation)
canvas.SetMatrix(canvas.TotalMatrix.PreConcat(Layer.GetTransformMatrix(true, false, false, true).Invert()));
using SKPath pointsPath = new SKPath();
using SKPaint ledPaint = new SKPaint();
using SKPath pointsPath = new();
using SKPaint ledPaint = new();
foreach (ArtemisLed artemisLed in Layer.Leds)
{
pointsPath.AddPoly(new[]

View File

@ -87,7 +87,7 @@ namespace Artemis.Core.LayerEffects
{
if (PlaceholderFor == null)
throw new ArtemisCoreException("Cannot create a placeholder instance using a layer effect descriptor that is not a placeholder for anything");
PlaceholderLayerEffect effect = new PlaceholderLayerEffect(entity, PlaceholderFor)
PlaceholderLayerEffect effect = new(entity, PlaceholderFor)
{
ProfileElement = renderElement,
Descriptor = this

View File

@ -41,7 +41,7 @@ namespace Artemis.Core.LayerEffects
if (!IsEnabled)
throw new ArtemisPluginFeatureException(this, "Can only add a layer effect descriptor when the plugin is enabled");
LayerEffectDescriptor descriptor = new LayerEffectDescriptor(displayName, description, icon, typeof(T), this);
LayerEffectDescriptor descriptor = new(displayName, description, icon, typeof(T), this);
_layerEffectDescriptors.Add(descriptor);
LayerEffectStore.Add(descriptor);
}

View File

@ -4,7 +4,7 @@
{
public static LayerEffectDescriptor Create(string missingProviderId)
{
LayerEffectDescriptor descriptor = new LayerEffectDescriptor("Missing effect", "This effect could not be loaded", "FileQuestion", null, Constants.EffectPlaceholderPlugin)
LayerEffectDescriptor descriptor = new("Missing effect", "This effect could not be loaded", "FileQuestion", null, Constants.EffectPlaceholderPlugin)
{
PlaceholderFor = missingProviderId
};

View File

@ -42,7 +42,7 @@ namespace Artemis.Core.Modules
/// <returns></returns>
public virtual DataModelPropertyAttribute GetDataModelDescription()
{
return new DataModelPropertyAttribute {Name = Plugin.Info.Name, Description = Plugin.Info.Description};
return new() {Name = Plugin.Info.Name, Description = Plugin.Info.Description};
}
internal override void InternalEnable()
@ -98,7 +98,7 @@ namespace Artemis.Core.Modules
/// A list of activation requirements
/// <para>Note: if empty the module is always activated</para>
/// </summary>
public List<IModuleActivationRequirement> ActivationRequirements { get; } = new List<IModuleActivationRequirement>();
public List<IModuleActivationRequirement> ActivationRequirements { get; } = new();
/// <summary>
/// Gets or sets the activation requirement mode, defaults to <see cref="ActivationRequirementType.Any" />

View File

@ -46,7 +46,7 @@ namespace Artemis.Core.Modules
/// <returns></returns>
public virtual DataModelPropertyAttribute GetDataModelDescription()
{
return new DataModelPropertyAttribute {Name = Plugin.Info.Name, Description = Plugin.Info.Description};
return new() {Name = Plugin.Info.Name, Description = Plugin.Info.Description};
}
/// <summary>
@ -94,8 +94,8 @@ namespace Artemis.Core.Modules
/// <summary>
/// Gets a list of all properties ignored at runtime using <c>IgnoreProperty(x => x.y)</c>
/// </summary>
protected internal readonly List<PropertyInfo> HiddenPropertiesList = new List<PropertyInfo>();
private readonly object _lock = new object();
protected internal readonly List<PropertyInfo> HiddenPropertiesList = new();
private readonly object _lock = new();
/// <summary>
/// Creates a new instance of the <see cref="ProfileModule" /> class

View File

@ -54,7 +54,7 @@ namespace Artemis.Core
_pluginRepository.AddSetting(settingEntity);
}
PluginSetting<T> pluginSetting = new PluginSetting<T>(Plugin, _pluginRepository, settingEntity);
PluginSetting<T> pluginSetting = new(Plugin, _pluginRepository, settingEntity);
// This overrides null with the default value, I'm not sure if that's desirable because you
// might expect something to go null and you might not

View File

@ -13,7 +13,7 @@ namespace Artemis.Core
private DateTime _lastEvent;
private Timer? _timer;
private bool _disposed;
private readonly object _lock = new object();
private readonly object _lock = new();
internal TimedUpdateRegistration(PluginFeature feature, TimeSpan interval, Action<double> action)
{

View File

@ -45,7 +45,7 @@ namespace Artemis.Core
public Rectangle RenderedRectangle { get; private set; }
/// <inheritdoc />
public Dictionary<BrushRenderTarget, Color> RenderedTargets { get; } = new Dictionary<BrushRenderTarget, Color>();
public Dictionary<BrushRenderTarget, Color> RenderedTargets { get; } = new();
/// <summary>
/// Gets or sets the desired scale of the bitmap brush
@ -155,7 +155,7 @@ namespace Artemis.Core
}
}
Color pixel = new Color(a / sampleSize, r / sampleSize, g / sampleSize, b / sampleSize);
Color pixel = new(a / sampleSize, r / sampleSize, g / sampleSize, b / sampleSize);
ArtemisDevice? artemisDevice = Surface?.GetArtemisLed(renderTarget.Led)?.Device;
if (artemisDevice is not null)

View File

@ -29,7 +29,7 @@ namespace Artemis.Core.Services
if ((amount & (amount - 1)) != 0)
throw new ArgumentException("Must be power of two", nameof(amount));
Queue<ColorCube> cubes = new Queue<ColorCube>(amount);
Queue<ColorCube> cubes = new(amount);
cubes.Enqueue(new ColorCube(colors));
while (cubes.Count < amount)

View File

@ -32,10 +32,10 @@ namespace Artemis.Core.Services
private readonly PluginSetting<double> _renderScale;
private readonly IRgbService _rgbService;
private readonly ISurfaceService _surfaceService;
private readonly List<Exception> _updateExceptions = new List<Exception>();
private List<BaseDataModelExpansion> _dataModelExpansions = new List<BaseDataModelExpansion>();
private readonly List<Exception> _updateExceptions = new();
private List<BaseDataModelExpansion> _dataModelExpansions = new();
private DateTime _lastExceptionLog;
private List<Module> _modules = new List<Module>();
private List<Module> _modules = new();
// ReSharper disable UnusedParameter.Local - Storage migration and module service are injected early to ensure it runs before anything else
public CoreService(IKernel kernel, ILogger logger, StorageMigrationService _, ISettingsService settingsService, IPluginManagementService pluginManagementService,
@ -112,7 +112,7 @@ namespace Artemis.Core.Services
public void PlayIntroAnimation()
{
IntroAnimation intro = new IntroAnimation(_logger, _profileService, _surfaceService);
IntroAnimation intro = new(_logger, _profileService, _surfaceService);
// Draw a white overlay over the device
void DrawOverlay(object? sender, FrameRenderingEventArgs args)
@ -183,7 +183,7 @@ namespace Artemis.Core.Services
return;
// Render all active modules
using SKCanvas canvas = new SKCanvas(_rgbService.BitmapBrush.Bitmap);
using SKCanvas canvas = new(_rgbService.BitmapBrush.Bitmap);
canvas.Scale((float) _renderScale.Value);
canvas.Clear(new SKColor(0, 0, 0));
if (!ModuleRenderingDisabled)

View File

@ -16,7 +16,7 @@ namespace Artemis.Core.Services
private void BlinkDevice(ArtemisDevice device, int blinkCount)
{
// Create a LED group way at the top
ListLedGroup ledGroup = new ListLedGroup(device.Leds.Select(l => l.RgbLed))
ListLedGroup ledGroup = new(device.Leds.Select(l => l.RgbLed))
{
Brush = new SolidColorBrush(new Color(255, 255, 255)),
ZIndex = 999

View File

@ -5,7 +5,7 @@ namespace Artemis.Core.Services
{
internal static class InputKeyUtilities
{
internal static readonly Dictionary<KeyboardKey, LedId> KeyboardKeyLedIdMap = new Dictionary<KeyboardKey, LedId>
internal static readonly Dictionary<KeyboardKey, LedId> KeyboardKeyLedIdMap = new()
{
{KeyboardKey.None, LedId.Keyboard_Custom1},
{KeyboardKey.Cancel, LedId.Keyboard_Custom2},
@ -182,7 +182,7 @@ namespace Artemis.Core.Services
{KeyboardKey.NumPadEnter, LedId.Keyboard_NumEnter}
};
internal static readonly Dictionary<MouseButton, LedId> MouseButtonLedIdMap = new Dictionary<MouseButton, LedId>
internal static readonly Dictionary<MouseButton, LedId> MouseButtonLedIdMap = new()
{
{MouseButton.Left, LedId.Mouse1},
{MouseButton.Middle, LedId.Mouse2},

View File

@ -34,7 +34,7 @@ namespace Artemis.Core.Services
#region Providers
private readonly List<InputProvider> _inputProviders = new List<InputProvider>();
private readonly List<InputProvider> _inputProviders = new();
public void AddInputProvider(InputProvider inputProvider)
{
@ -63,8 +63,8 @@ namespace Artemis.Core.Services
#region Identification
private readonly Dictionary<Tuple<InputProvider, object>, ArtemisDevice> _deviceCache = new Dictionary<Tuple<InputProvider, object>, ArtemisDevice>();
private List<ArtemisDevice> _devices = new List<ArtemisDevice>();
private readonly Dictionary<Tuple<InputProvider, object>, ArtemisDevice> _deviceCache = new();
private List<ArtemisDevice> _devices = new();
private ArtemisDevice? _cachedFallbackKeyboard;
private ArtemisDevice? _cachedFallbackMouse;
private ArtemisDevice? _identifyingDevice;
@ -180,8 +180,8 @@ namespace Artemis.Core.Services
#region Keyboard
private readonly Dictionary<ArtemisDevice, HashSet<KeyboardKey>> _pressedKeys = new Dictionary<ArtemisDevice, HashSet<KeyboardKey>>();
private readonly Dictionary<ArtemisDevice, KeyboardModifierKey> _keyboardModifier = new Dictionary<ArtemisDevice, KeyboardModifierKey>();
private readonly Dictionary<ArtemisDevice, HashSet<KeyboardKey>> _pressedKeys = new();
private readonly Dictionary<ArtemisDevice, KeyboardModifierKey> _keyboardModifier = new();
private KeyboardModifierKey _globalModifiers;
private void InputProviderOnKeyboardDataReceived(object? sender, InputProviderKeyboardEventArgs e)
@ -199,7 +199,7 @@ namespace Artemis.Core.Services
led = e.Device.GetLed(ledId);
// Create the UpDown event args because it can be used for every event
ArtemisKeyboardKeyUpDownEventArgs eventArgs = new ArtemisKeyboardKeyUpDownEventArgs(e.Device, led, e.Key, keyboardModifierKey, e.IsDown);
ArtemisKeyboardKeyUpDownEventArgs eventArgs = new(e.Device, led, e.Key, keyboardModifierKey, e.IsDown);
OnKeyboardKeyUpDown(eventArgs);
if (e.IsDown)
OnKeyboardKeyDown(eventArgs);
@ -289,7 +289,7 @@ namespace Artemis.Core.Services
led = e.Device.Leds.FirstOrDefault(l => l.RgbLed.Id == ledId);
// Create the UpDown event args because it can be used for every event
ArtemisMouseButtonUpDownEventArgs eventArgs = new ArtemisMouseButtonUpDownEventArgs(e.Device, led, e.Button, e.IsDown);
ArtemisMouseButtonUpDownEventArgs eventArgs = new(e.Device, led, e.Button, e.IsDown);
OnMouseButtonUpDown(eventArgs);
if (e.IsDown)
OnMouseButtonDown(eventArgs);

View File

@ -14,7 +14,7 @@ namespace Artemis.Core.Services
{
internal class ModuleService : IModuleService
{
private static readonly SemaphoreSlim ActiveModuleSemaphore = new SemaphoreSlim(1, 1);
private static readonly SemaphoreSlim ActiveModuleSemaphore = new(1, 1);
private readonly ILogger _logger;
private readonly IModuleRepository _moduleRepository;
private readonly IPluginManagementService _pluginManagementService;
@ -28,7 +28,7 @@ namespace Artemis.Core.Services
_profileService = profileService;
_pluginManagementService.PluginFeatureEnabled += OnPluginFeatureEnabled;
Timer activationUpdateTimer = new Timer(2000);
Timer activationUpdateTimer = new(2000);
activationUpdateTimer.Start();
activationUpdateTimer.Elapsed += ActivationUpdateTimerOnElapsed;
@ -204,11 +204,11 @@ namespace Artemis.Core.Services
return;
}
Stopwatch stopwatch = new Stopwatch();
Stopwatch stopwatch = new();
stopwatch.Start();
List<Module> modules = _pluginManagementService.GetFeaturesOfType<Module>().ToList();
List<Task> tasks = new List<Task>();
List<Task> tasks = new();
foreach (Module module in modules)
lock (module)
{

View File

@ -38,7 +38,7 @@ namespace Artemis.Core.Services
private void CopyBuiltInPlugin(FileInfo zipFileInfo, ZipArchive zipArchive)
{
DirectoryInfo pluginDirectory = new DirectoryInfo(Path.Combine(Constants.DataFolder, "plugins", Path.GetFileNameWithoutExtension(zipFileInfo.Name)));
DirectoryInfo pluginDirectory = new(Path.Combine(Constants.DataFolder, "plugins", Path.GetFileNameWithoutExtension(zipFileInfo.Name)));
bool createLockFile = File.Exists(Path.Combine(pluginDirectory.FullName, "artemis.lock"));
// Remove the old directory if it exists
@ -58,10 +58,10 @@ namespace Artemis.Core.Services
public void CopyBuiltInPlugins()
{
OnCopyingBuildInPlugins();
DirectoryInfo pluginDirectory = new DirectoryInfo(Path.Combine(Constants.DataFolder, "plugins"));
DirectoryInfo pluginDirectory = new(Path.Combine(Constants.DataFolder, "plugins"));
// Iterate built-in plugins
DirectoryInfo builtInPluginDirectory = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "Plugins"));
DirectoryInfo builtInPluginDirectory = new(Path.Combine(Directory.GetCurrentDirectory(), "Plugins"));
if (!builtInPluginDirectory.Exists)
{
_logger.Warning("No built-in plugins found at {pluginDir}, skipping CopyBuiltInPlugins", builtInPluginDirectory.FullName);
@ -76,7 +76,7 @@ namespace Artemis.Core.Services
if (metaDataFileEntry == null)
throw new ArtemisPluginException("Couldn't find a plugin.json in " + zipFile.FullName);
using StreamReader reader = new StreamReader(metaDataFileEntry.Open());
using StreamReader reader = new(metaDataFileEntry.Open());
PluginInfo builtInPluginInfo = CoreJson.DeserializeObject<PluginInfo>(reader.ReadToEnd())!;
// Find the matching plugin in the plugin folder
@ -151,7 +151,7 @@ namespace Artemis.Core.Services
public Plugin? GetCallingPlugin()
{
StackTrace stackTrace = new StackTrace(); // get call stack
StackTrace stackTrace = new(); // get call stack
StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames)
foreach (StackFrame stackFrame in stackFrames)
@ -183,7 +183,7 @@ namespace Artemis.Core.Services
UnloadPlugins();
// Load the plugin assemblies into the plugin context
DirectoryInfo pluginDirectory = new DirectoryInfo(Path.Combine(Constants.DataFolder, "plugins"));
DirectoryInfo pluginDirectory = new(Path.Combine(Constants.DataFolder, "plugins"));
foreach (DirectoryInfo subDirectory in pluginDirectory.EnumerateDirectories())
{
try
@ -238,7 +238,7 @@ namespace Artemis.Core.Services
}
// Load the entity and fall back on creating a new one
Plugin plugin = new Plugin(pluginInfo, directory, _pluginRepository.GetPluginByGuid(pluginInfo.Guid));
Plugin plugin = new(pluginInfo, directory, _pluginRepository.GetPluginByGuid(pluginInfo.Guid));
OnPluginLoading(new PluginEventArgs(plugin));
// Locate the main assembly entry

View File

@ -17,7 +17,7 @@ namespace Artemis.Core.Services.Models
internal static SurfaceArrangement GetDefaultArrangement()
{
SurfaceArrangement arrangement = new SurfaceArrangement();
SurfaceArrangement arrangement = new();
SurfaceArrangementType keypad = arrangement.AddType(RGBDeviceType.Keypad, 1);
keypad.AddConfiguration(new SurfaceArrangementConfiguration(null, HorizontalArrangementPosition.Equal, VerticalArrangementPosition.Equal, 20));
@ -71,7 +71,7 @@ namespace Artemis.Core.Services.Models
private SurfaceArrangementType AddType(RGBDeviceType type, int zIndex)
{
SurfaceArrangementType surfaceArrangementType = new SurfaceArrangementType(this, type, zIndex);
SurfaceArrangementType surfaceArrangementType = new(this, type, zIndex);
Types.Add(surfaceArrangementType);
return surfaceArrangementType;
}

View File

@ -46,7 +46,7 @@ namespace Artemis.Core.Services.Models
}
// If nothing applied fall back to just basing on whatever is the furthers to the right
SurfaceArrangementConfiguration fallback = new SurfaceArrangementConfiguration(
SurfaceArrangementConfiguration fallback = new(
null,
HorizontalArrangementPosition.Right,
VerticalArrangementPosition.Equal,

View File

@ -33,8 +33,8 @@ namespace Artemis.Core.Services
_surfaceService.SurfaceConfigurationUpdated += OnSurfaceConfigurationUpdated;
}
public JsonSerializerSettings MementoSettings { get; set; } = new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.All};
public JsonSerializerSettings ExportSettings { get; set; } = new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.All, Formatting = Formatting.Indented};
public JsonSerializerSettings MementoSettings { get; set; } = new() {TypeNameHandling = TypeNameHandling.All};
public JsonSerializerSettings ExportSettings { get; set; } = new() {TypeNameHandling = TypeNameHandling.All, Formatting = Formatting.Indented};
public ProfileDescriptor? GetLastActiveProfile(ProfileModule module)
{
@ -78,7 +78,7 @@ namespace Artemis.Core.Services
public ProfileDescriptor CreateProfileDescriptor(ProfileModule module, string name)
{
ProfileEntity profileEntity = new ProfileEntity {Id = Guid.NewGuid(), Name = name, ModuleId = module.Id};
ProfileEntity profileEntity = new() {Id = Guid.NewGuid(), Name = name, ModuleId = module.Id};
_profileRepository.Add(profileEntity);
return new ProfileDescriptor(module, profileEntity);
@ -107,7 +107,7 @@ namespace Artemis.Core.Services
if (profileEntity == null)
throw new ArtemisCoreException($"Cannot find profile named: {profileDescriptor.Name} ID: {profileDescriptor.Id}");
Profile profile = new Profile(profileDescriptor.ProfileModule, profileEntity);
Profile profile = new(profileDescriptor.ProfileModule, profileEntity);
InstantiateProfile(profile);
profileDescriptor.ProfileModule.ChangeActiveProfile(profile, _surfaceService.ActiveSurface);
@ -122,7 +122,7 @@ namespace Artemis.Core.Services
return;
ProfileEntity entity = _profileRepository.Get(module.ActiveProfile.EntityId);
Profile profile = new Profile(module, entity);
Profile profile = new(module, entity);
InstantiateProfile(profile);
module.ChangeActiveProfile(null, _surfaceService.ActiveSurface);
@ -138,7 +138,7 @@ namespace Artemis.Core.Services
if (profileEntity == null)
throw new ArtemisCoreException($"Cannot find profile named: {profileDescriptor.Name} ID: {profileDescriptor.Id}");
Profile profile = new Profile(profileDescriptor.ProfileModule, profileEntity);
Profile profile = new(profileDescriptor.ProfileModule, profileEntity);
InstantiateProfile(profile);
void ActivatingProfileSurfaceUpdate(object? sender, SurfaceConfigurationEventArgs e)

View File

@ -40,7 +40,7 @@ namespace Artemis.Core.Services
public ArtemisSurface CreateSurfaceConfiguration(string name)
{
// Create a blank config
ArtemisSurface configuration = new ArtemisSurface(_rgbService.Surface, name);
ArtemisSurface configuration = new(_rgbService.Surface, name);
// Add all current devices
foreach (IRGBDevice rgbDevice in _rgbService.LoadedDevices)
@ -134,7 +134,7 @@ namespace Artemis.Core.Services
foreach (SurfaceEntity surfaceEntity in configs)
{
// Create the surface entity
ArtemisSurface surfaceConfiguration = new ArtemisSurface(_rgbService.Surface, surfaceEntity);
ArtemisSurface surfaceConfiguration = new(_rgbService.Surface, surfaceEntity);
foreach (DeviceEntity position in surfaceEntity.DeviceEntities)
{
IRGBDevice? device = _rgbService.Surface.Devices.FirstOrDefault(d => d.GetDeviceIdentifier() == position.DeviceIdentifier);

View File

@ -6,7 +6,7 @@ namespace Artemis.Core
{
internal class ConditionOperatorStore
{
private static readonly List<ConditionOperatorRegistration> Registrations = new List<ConditionOperatorRegistration>();
private static readonly List<ConditionOperatorRegistration> Registrations = new();
public static ConditionOperatorRegistration Add(BaseConditionOperator conditionOperator)
{

View File

@ -6,7 +6,7 @@ namespace Artemis.Core
{
internal class DataBindingModifierTypeStore
{
private static readonly List<DataBindingModifierTypeRegistration> Registrations = new List<DataBindingModifierTypeRegistration>();
private static readonly List<DataBindingModifierTypeRegistration> Registrations = new();
public static DataBindingModifierTypeRegistration Add(BaseDataBindingModifierType modifierType)
{

View File

@ -7,7 +7,7 @@ namespace Artemis.Core
{
internal class DataModelStore
{
private static readonly List<DataModelRegistration> Registrations = new List<DataModelRegistration>();
private static readonly List<DataModelRegistration> Registrations = new();
public static DataModelRegistration Add(DataModel dataModel)
{

View File

@ -7,7 +7,7 @@ namespace Artemis.Core
{
internal class LayerBrushStore
{
private static readonly List<LayerBrushRegistration> Registrations = new List<LayerBrushRegistration>();
private static readonly List<LayerBrushRegistration> Registrations = new();
public static LayerBrushRegistration Add(LayerBrushDescriptor descriptor)
{

View File

@ -7,7 +7,7 @@ namespace Artemis.Core
{
internal class LayerEffectStore
{
private static readonly List<LayerEffectRegistration> Registrations = new List<LayerEffectRegistration>();
private static readonly List<LayerEffectRegistration> Registrations = new();
public static LayerEffectRegistration Add(LayerEffectDescriptor descriptor)
{

View File

@ -37,7 +37,7 @@ namespace Artemis.Core
if (restart)
arguments = "-Command \"& {Start-Sleep -s " + delay + "; (Get-Process 'Artemis.UI').kill(); Start-Process -FilePath '" + Process.GetCurrentProcess().MainModule!.FileName + "'}\"";
ProcessStartInfo info = new ProcessStartInfo
ProcessStartInfo info = new()
{
Arguments = arguments,
WindowStyle = ProcessWindowStyle.Hidden,
@ -59,7 +59,7 @@ namespace Artemis.Core
/// <returns>The process created to open the URL</returns>
public static Process? OpenUrl(string url)
{
ProcessStartInfo processInfo = new ProcessStartInfo
ProcessStartInfo processInfo = new()
{
FileName = url,
UseShellExecute = true
@ -87,7 +87,7 @@ namespace Artemis.Core
// On Windows, ensure everyone has permission (important when running as admin)
DirectorySecurity security = dataDirectory.GetAccessControl();
SecurityIdentifier everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
SecurityIdentifier everyone = new(WellKnownSidType.WorldSid, null);
security.AddAccessRule(new FileSystemAccessRule(
everyone,
FileSystemRights.Modify | FileSystemRights.Synchronize,

View File

@ -47,7 +47,7 @@ namespace Artemis.Core
LedName = l.RgbLed.Id.ToString()
}));
Profile profile = new Profile(new DummyModule(), profileEntity);
Profile profile = new(new DummyModule(), profileEntity);
profile.Activate(_surfaceService.ActiveSurface);
_profileService.InstantiateProfile(profile);

View File

@ -50,7 +50,7 @@ namespace Artemis.Storage.Migrations
public void Apply(LiteRepository repository)
{
Dictionary<string, string> pluginMap = new Dictionary<string, string>
Dictionary<string, string> pluginMap = new()
{
{"ffffffff-ffff-ffff-ffff-ffffffffffff", "Artemis.Core.CorePluginFeature-ffffffff"},
{"ab41d601-35e0-4a73-bf0b-94509b006ab0", "Artemis.Plugins.DataModelExpansions.TestData.PluginDataModelExpansion-ab41d601"},

View File

@ -35,7 +35,7 @@ namespace Artemis.UI.Shared
if (scrollPos == scrollViewer.ScrollableHeight && e.Delta < 0 || scrollPos == 0 && e.Delta > 0)
{
e.Handled = true;
MouseWheelEventArgs e2 = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
MouseWheelEventArgs e2 = new(e.MouseDevice, e.Timestamp, e.Delta);
e2.RoutedEvent = UIElement.MouseWheelEvent;
AssociatedObject.RaiseEvent(e2);
}

View File

@ -106,7 +106,7 @@ namespace Artemis.UI.Shared
// Determine the scale required to fit the desired size of the control
Size measureSize = MeasureDevice();
double scale = Math.Min(DesiredSize.Width / measureSize.Width, DesiredSize.Height / measureSize.Height);
Rect scaledRect = new Rect(0, 0, measureSize.Width * scale, measureSize.Height * scale);
Rect scaledRect = new(0, 0, measureSize.Width * scale, measureSize.Height * scale);
// Center and scale the visualization in the desired bounding box
if (DesiredSize.Width > 0 && DesiredSize.Height > 0)
@ -116,7 +116,7 @@ namespace Artemis.UI.Shared
}
// Determine the offset required to rotate within bounds
Rect rotationRect = new Rect(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height);
Rect rotationRect = new(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height);
rotationRect.Transform(new RotateTransform(Device.Rotation).Value);
// Apply device rotation
@ -169,7 +169,7 @@ namespace Artemis.UI.Shared
if (Device == null)
return Size.Empty;
Rect rotationRect = new Rect(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height);
Rect rotationRect = new(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height);
rotationRect.Transform(new RotateTransform(Device.Rotation).Value);
return rotationRect.Size;
@ -249,16 +249,16 @@ namespace Artemis.UI.Shared
}
// Create the opacity drawing group
DrawingGroup opacityDrawingGroup = new DrawingGroup();
DrawingGroup opacityDrawingGroup = new();
DrawingContext drawingContext = opacityDrawingGroup.Open();
foreach (DeviceVisualizerLed deviceVisualizerLed in _deviceVisualizerLeds)
deviceVisualizerLed.RenderOpacityMask(drawingContext);
drawingContext.Close();
// Render the store as a bitmap
DrawingImage drawingImage = new DrawingImage(opacityDrawingGroup);
Image image = new Image {Source = drawingImage};
RenderTargetBitmap bitmap = new RenderTargetBitmap(
DrawingImage drawingImage = new(opacityDrawingGroup);
Image image = new() {Source = drawingImage};
RenderTargetBitmap bitmap = new(
Math.Max(1, (int) (opacityDrawingGroup.Bounds.Width * 2.5)),
Math.Max(1, (int) (opacityDrawingGroup.Bounds.Height * 2.5)),
96,
@ -270,7 +270,7 @@ namespace Artemis.UI.Shared
bitmap.Freeze();
// Set the bitmap as the opacity mask for the colors backing store
ImageBrush bitmapBrush = new ImageBrush(bitmap);
ImageBrush bitmapBrush = new(bitmap);
bitmapBrush.Freeze();
_backingStore.OpacityMask = bitmapBrush;

View File

@ -61,9 +61,9 @@ namespace Artemis.UI.Shared
if (DisplayGeometry == null)
return;
SolidColorBrush fillBrush = new SolidColorBrush(Color.FromArgb(100, 255, 255, 255));
SolidColorBrush fillBrush = new(Color.FromArgb(100, 255, 255, 255));
fillBrush.Freeze();
SolidColorBrush penBrush = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
SolidColorBrush penBrush = new(Color.FromArgb(255, 255, 255, 255));
penBrush.Freeze();
// Create transparent pixels covering the entire LedRect so the image size matched the LedRect size

View File

@ -44,7 +44,7 @@ namespace Artemis.UI.Shared
typeof(RoutedPropertyChangedEventHandler<float>),
typeof(DraggableFloat));
private readonly Regex _inputRegex = new Regex("^[.][-|0-9]+$|^-?[0-9]*[.]{0,1}[0-9]*$");
private readonly Regex _inputRegex = new("^[.][-|0-9]+$|^-?[0-9]*[.]{0,1}[0-9]*$");
private bool _calledDragStarted;
@ -196,10 +196,10 @@ namespace Artemis.UI.Shared
}
// Use decimals for everything to avoid floating point errors
decimal startValue = new decimal(_startValue);
decimal startX = new decimal(_mouseDragStartPoint.X);
decimal x = new decimal(e.GetPosition((IInputElement) sender).X);
decimal stepSize = new decimal(StepSize);
decimal startValue = new(_startValue);
decimal startX = new(_mouseDragStartPoint.X);
decimal x = new(e.GetPosition((IInputElement) sender).X);
decimal stepSize = new(StepSize);
if (stepSize == 0)
stepSize = 0.1m;

View File

@ -21,7 +21,7 @@ namespace Artemis.UI.Shared
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
List<ColorGradientStop> colorGradients = (List<ColorGradientStop>) value;
GradientStopCollection collection = new GradientStopCollection();
GradientStopCollection collection = new();
if (colorGradients == null)
return collection;
@ -34,7 +34,7 @@ namespace Artemis.UI.Shared
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
GradientStopCollection collection = (GradientStopCollection) value;
List<ColorGradientStop> colorGradients = new List<ColorGradientStop>();
List<ColorGradientStop> colorGradients = new();
if (collection == null)
return colorGradients;

View File

@ -27,7 +27,7 @@ namespace Artemis.UI.Shared
}
}
internal override object InternalGuard => new object();
internal override object InternalGuard => new();
/// <inheritdoc />
public override void UpdateValue(object? model)

View File

@ -45,7 +45,7 @@ namespace Artemis.UI.Shared
/// </summary>
public DataModelPropertyAttribute TargetDescription { get; }
internal override object InternalGuard { get; } = new object();
internal override object InternalGuard { get; } = new();
/// <inheritdoc />
public sealed override void Submit()

View File

@ -21,7 +21,7 @@ namespace Artemis.UI.Shared.Input
private readonly IDataModelUIService _dataModelUIService;
private readonly Module _module;
private readonly Timer _updateTimer;
private SolidColorBrush _buttonBrush = new SolidColorBrush(Color.FromRgb(171, 71, 188));
private SolidColorBrush _buttonBrush = new(Color.FromRgb(171, 71, 188));
private DataModelPath? _dataModelPath;
private DataModelPropertiesViewModel? _dataModelViewModel;
private bool _displaySwitchButton;
@ -59,7 +59,7 @@ namespace Artemis.UI.Shared.Input
/// <summary>
/// Gets the brush to use for the switch button
/// </summary>
public SolidColorBrush SwitchButtonBrush => new SolidColorBrush(ButtonBrush.Color.Darken());
public SolidColorBrush SwitchButtonBrush => new(ButtonBrush.Color.Darken());
/// <summary>
/// Gets or sets the placeholder text when no value is entered

View File

@ -19,7 +19,7 @@ namespace Artemis.UI.Shared.Input
{
private readonly IDataModelUIService _dataModelUIService;
private readonly Window? _rootView;
private SolidColorBrush _buttonBrush = new SolidColorBrush(Color.FromRgb(171, 71, 188));
private SolidColorBrush _buttonBrush = new(Color.FromRgb(171, 71, 188));
private bool _displaySwitchButton;
private DataModelDisplayViewModel? _displayViewModel;
private DataModelInputViewModel? _inputViewModel;
@ -62,7 +62,7 @@ namespace Artemis.UI.Shared.Input
/// <summary>
/// Gets the brush to use for the switch button
/// </summary>
public SolidColorBrush SwitchButtonBrush => new SolidColorBrush(ButtonBrush.Color.Darken());
public SolidColorBrush SwitchButtonBrush => new(ButtonBrush.Color.Darken());
/// <summary>
/// Gets the view model used to display the value

View File

@ -263,7 +263,7 @@ namespace Artemis.UI.Shared
if (depth > MaxDepth)
return null;
DataModelPath dataModelPath = new DataModelPath(DataModel, path);
DataModelPath dataModelPath = new(DataModel, path);
if (!dataModelPath.IsValid)
return null;

View File

@ -18,7 +18,7 @@ namespace Artemis.UI.Shared
/// <returns>The created view model</returns>
public static DataModelPropertiesViewModel CreateViewModel(this EventPredicateWrapperDataModel wrapper, IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
{
DataModelPropertiesViewModel viewModel = new DataModelPropertiesViewModel(wrapper, null, new DataModelPath(wrapper));
DataModelPropertiesViewModel viewModel = new(wrapper, null, new DataModelPath(wrapper));
viewModel.Update(dataModelUIService, configuration);
viewModel.UpdateRequested += (sender, args) => viewModel.Update(dataModelUIService, configuration);
viewModel.Children.First().IsVisualizationExpanded = true;
@ -35,7 +35,7 @@ namespace Artemis.UI.Shared
/// <returns>The created view model</returns>
public static DataModelPropertiesViewModel CreateViewModel(this ListPredicateWrapperDataModel wrapper, IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
{
DataModelPropertiesViewModel viewModel = new DataModelPropertiesViewModel(wrapper, null, new DataModelPath(wrapper));
DataModelPropertiesViewModel viewModel = new(wrapper, null, new DataModelPath(wrapper));
viewModel.Update(dataModelUIService, configuration);
viewModel.UpdateRequested += (sender, args) => viewModel.Update(dataModelUIService, configuration);
viewModel.Children.First().IsVisualizationExpanded = true;

View File

@ -85,7 +85,7 @@ namespace Artemis.UI.Shared
}
}
internal override object InternalGuard { get; } = new object();
internal override object InternalGuard { get; } = new();
#region IDisposable

View File

@ -52,12 +52,12 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
{
Canvas? child = VisualTreeUtilities.FindChild<Canvas>((DependencyObject) sender, null);
float position = (float) (e.GetPosition(child).X / PreviewWidth);
ColorGradientStop stop = new ColorGradientStop(ColorGradient.GetColor(position), position);
ColorGradientStop stop = new(ColorGradient.GetColor(position), position);
ColorGradient.Stops.Add(stop);
ColorGradient.OnColorValuesUpdated();
int index = ColorGradient.Stops.OrderBy(s => s.Position).ToList().IndexOf(stop);
ColorStopViewModel viewModel = new ColorStopViewModel(this, stop);
ColorStopViewModel viewModel = new(this, stop);
ColorStopViewModels.Insert(index, viewModel);
SelectColorStop(viewModel);

View File

@ -72,7 +72,7 @@ namespace Artemis.UI.Shared.Services
if (_overlayOpacity > 1f)
_overlayOpacity = 1f;
using SKPaint overlayPaint = new SKPaint {Color = new SKColor(0, 0, 0, (byte) (255 * _overlayOpacity))};
using SKPaint overlayPaint = new() {Color = new SKColor(0, 0, 0, (byte) (255 * _overlayOpacity))};
overlayPaint.Color = _overlayColor.WithAlpha((byte) (_overlayColor.Alpha * _overlayOpacity));
e.Canvas.DrawRect(0, 0, e.Canvas.LocalClipBounds.Width, e.Canvas.LocalClipBounds.Height, overlayPaint);
}

View File

@ -34,7 +34,7 @@ namespace Artemis.UI.Shared.Services
public DataModelPropertiesViewModel GetMainDataModelVisualization()
{
DataModelPropertiesViewModel viewModel = new DataModelPropertiesViewModel(null, null, null);
DataModelPropertiesViewModel viewModel = new(null, null, null);
foreach (DataModel dataModelExpansion in _dataModelService.GetDataModels().OrderBy(d => d.DataModelDescription.Name))
viewModel.Children.Add(new DataModelPropertiesViewModel(dataModelExpansion, viewModel, new DataModelPath(dataModelExpansion)));
@ -86,7 +86,7 @@ namespace Artemis.UI.Shared.Services
if (dataModel == null)
return null;
DataModelPropertiesViewModel viewModel = new DataModelPropertiesViewModel(null, null, null);
DataModelPropertiesViewModel viewModel = new(null, null, null);
viewModel.Children.Add(new DataModelPropertiesViewModel(dataModel, viewModel, new DataModelPath(dataModel)));
// Update to populate children
@ -114,7 +114,7 @@ namespace Artemis.UI.Shared.Services
_kernel.Bind(viewModelType).ToSelf();
// Create the registration
DataModelVisualizationRegistration registration = new DataModelVisualizationRegistration(this, RegistrationType.Input, plugin, supportedType, viewModelType)
DataModelVisualizationRegistration registration = new(this, RegistrationType.Input, plugin, supportedType, viewModelType)
{
// Apply the compatible conversion types to the registration
CompatibleConversionTypes = compatibleConversionTypes
@ -141,7 +141,7 @@ namespace Artemis.UI.Shared.Services
}
_kernel.Bind(viewModelType).ToSelf();
DataModelVisualizationRegistration registration = new DataModelVisualizationRegistration(this, RegistrationType.Display, plugin, supportedType, viewModelType);
DataModelVisualizationRegistration registration = new(this, RegistrationType.Display, plugin, supportedType, viewModelType);
_registeredDataModelDisplays.Add(registration);
return registration;
}

View File

@ -54,7 +54,7 @@ namespace Artemis.UI.Shared.Services.Models
// Let the folder initialize and load as usual
FolderEntity.Name += " - copy";
Folder folder = new Folder(profile, parent, FolderEntity);
Folder folder = new(profile, parent, FolderEntity);
return folder;
}

View File

@ -23,8 +23,8 @@ namespace Artemis.UI.Shared.Services
private readonly ILogger _logger;
private readonly IProfileService _profileService;
private readonly List<PropertyInputRegistration> _registeredPropertyEditors;
private readonly object _selectedProfileElementLock = new object();
private readonly object _selectedProfileLock = new object();
private readonly object _selectedProfileElementLock = new();
private readonly object _selectedProfileLock = new();
private TimeSpan _currentTime;
private int _pixelsPerSecond;
@ -113,7 +113,7 @@ namespace Artemis.UI.Shared.Services
_logger.Verbose("ChangeSelectedProfile {profile}", profile);
ChangeSelectedProfileElement(null);
ProfileEventArgs profileElementEvent = new ProfileEventArgs(profile, SelectedProfile);
ProfileEventArgs profileElementEvent = new(profile, SelectedProfile);
// Ensure there is never a deactivated profile as the selected profile
if (SelectedProfile != null)
@ -149,7 +149,7 @@ namespace Artemis.UI.Shared.Services
return;
_logger.Verbose("ChangeSelectedProfileElement {profile}", profileElement);
RenderProfileElementEventArgs profileElementEvent = new RenderProfileElementEventArgs(profileElement, SelectedProfileElement);
RenderProfileElementEventArgs profileElementEvent = new(profileElement, SelectedProfileElement);
SelectedProfileElement = profileElement;
OnSelectedProfileElementChanged(profileElementEvent);
@ -249,7 +249,7 @@ namespace Artemis.UI.Shared.Services
}
_kernel.Bind(viewModelType).ToSelf();
PropertyInputRegistration registration = new PropertyInputRegistration(this, plugin, supportedType, viewModelType);
PropertyInputRegistration registration = new(this, plugin, supportedType, viewModelType);
_registeredPropertyEditors.Add(registration);
return registration;
}
@ -327,7 +327,7 @@ namespace Artemis.UI.Shared.Services
if (viewModelType == null)
return null;
ConstructorArgument parameter = new ConstructorArgument("layerProperty", layerProperty);
ConstructorArgument parameter = new("layerProperty", layerProperty);
// ReSharper disable once InconsistentlySynchronizedField
// When you've just spent the last 2 hours trying to figure out a deadlock and reach this line, I'm so, so sorry. I thought this would be fine.
IKernel kernel = registration?.Plugin.Kernel ?? _kernel;
@ -368,7 +368,7 @@ namespace Artemis.UI.Shared.Services
{
case Folder folder:
{
FolderClipboardModel clipboardModel = new FolderClipboardModel(folder);
FolderClipboardModel clipboardModel = new(folder);
JsonClipboard.SetObject(clipboardModel);
break;
}

View File

@ -19,8 +19,8 @@ namespace Artemis.UI.Shared
/// <returns></returns>
public static List<T> GetHitViewModels<T>(Visual container, RectangleGeometry rectangleGeometry)
{
List<T> result = new List<T>();
GeometryHitTestParameters hitTestParams = new GeometryHitTestParameters(rectangleGeometry);
List<T> result = new();
GeometryHitTestParameters hitTestParams = new(rectangleGeometry);
HitTestResultBehavior ResultCallback(HitTestResult r) => HitTestResultBehavior.Continue;
HitTestFilterBehavior FilterCallback(DependencyObject e)

View File

@ -9,7 +9,7 @@ namespace Artemis.UI.Shared
/// </summary>
public static class JsonClipboard
{
private static readonly JsonSerializerSettings JsonSettings = new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.All};
private static readonly JsonSerializerSettings JsonSettings = new() {TypeNameHandling = TypeNameHandling.All};
/// <summary>
/// Sets the provided object on the clipboard

View File

@ -174,7 +174,7 @@ namespace Artemis.UI.Shared
{
// insert dummy story-boards which can later be traced using WPF animation tracing
TriggerTraceStoryboard storyboard = new TriggerTraceStoryboard(triggerBase, TriggerTraceStoryboardType.Enter);
TriggerTraceStoryboard storyboard = new(triggerBase, TriggerTraceStoryboardType.Enter);
triggerBase.EnterActions.Insert(0, new BeginStoryboard {Storyboard = storyboard});
storyboard = new TriggerTraceStoryboard(triggerBase, TriggerTraceStoryboardType.Exit);

View File

@ -8,7 +8,7 @@ namespace Artemis.UI.Behaviors
{
public class InputBindingBehavior
{
private static List<Tuple<FrameworkElement, Window, InputBinding>> _movedInputBindings = new List<Tuple<FrameworkElement, Window, InputBinding>>();
private static List<Tuple<FrameworkElement, Window, InputBinding>> _movedInputBindings = new();
public static readonly DependencyProperty PropagateInputBindingsToWindowProperty =
DependencyProperty.RegisterAttached("PropagateInputBindingsToWindow", typeof(bool), typeof(InputBindingBehavior),

View File

@ -15,7 +15,7 @@ namespace Artemis.UI.DefaultTypes.DataModel.Input
public void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
{
string seperator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
Regex regex = new Regex("^[" + seperator + "][0-9]+$|^[0-9]*[" + seperator + "]{0,1}[0-9]*$");
Regex regex = new("^[" + seperator + "][0-9]+$|^[0-9]*[" + seperator + "]{0,1}[0-9]*$");
e.Handled = !regex.IsMatch(e.Text);
}
}

View File

@ -13,7 +13,7 @@ namespace Artemis.UI.DefaultTypes.DataModel.Input
public void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
{
Regex regex = new Regex("[^0-9]+");
Regex regex = new("[^0-9]+");
e.Handled = regex.IsMatch(e.Text);
}
}

View File

@ -7,7 +7,7 @@ namespace Artemis.UI.Extensions
{
public static Rect ToWindowsRect(this Rectangle rectangle, double scale)
{
return new Rect(
return new(
(int) (rectangle.Location.X * scale),
(int) (rectangle.Location.Y * scale),
(int) (rectangle.Size.Width * scale),

View File

@ -231,7 +231,7 @@ namespace Artemis.UI.InputProviders
private static Win32Point GetCursorPosition()
{
Win32Point w32Mouse = new Win32Point();
Win32Point w32Mouse = new();
GetCursorPos(ref w32Mouse);
return w32Mouse;

View File

@ -40,11 +40,11 @@ namespace Artemis.UI.Screens.Modules
if (Module.ModuleTabs != null)
{
List<ModuleTab> moduleTabs = new List<ModuleTab>(Module.ModuleTabs);
List<ModuleTab> moduleTabs = new(Module.ModuleTabs);
foreach (ModuleTab moduleTab in moduleTabs.Where(m => m != null))
{
ConstructorArgument module = new ConstructorArgument("module", Module);
ConstructorArgument displayName = new ConstructorArgument("displayName", DisplayName);
ConstructorArgument module = new("module", Module);
ConstructorArgument displayName = new("displayName", DisplayName);
ModuleViewModel viewModel = (ModuleViewModel) Module.Plugin.Kernel.Get(moduleTab.Type, module, displayName);
Items.Add(viewModel);

View File

@ -35,7 +35,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
LeftSideSelectionViewModel.LoadEventChildren = false;
IReadOnlyCollection<DataModelVisualizationRegistration> editors = _dataModelUIService.RegisteredDataModelEditors;
List<Type> supportedInputTypes = new List<Type> {typeof(DataModelEvent), typeof(DataModelEvent<>)};
List<Type> supportedInputTypes = new() {typeof(DataModelEvent), typeof(DataModelEvent<>)};
LeftSideSelectionViewModel.FilterTypes = supportedInputTypes.ToArray();
LeftSideSelectionViewModel.ButtonBrush = new SolidColorBrush(Color.FromRgb(185, 164, 10));
@ -54,7 +54,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
if (DataModelConditionEvent.EventPath == null || !DataModelConditionEvent.EventPath.IsValid)
return;
List<DataModelConditionViewModel> viewModels = new List<DataModelConditionViewModel>();
List<DataModelConditionViewModel> viewModels = new();
foreach (DataModelConditionPart childModel in Model.Children)
{
if (Items.Any(c => c.Model == childModel))

View File

@ -181,7 +181,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
DataModelConditionGroup.RemoveChild(predicateViewModel.Model);
// Insert a list in the same position
DataModelConditionList list = new DataModelConditionList(DataModelConditionGroup);
DataModelConditionList list = new(DataModelConditionGroup);
list.UpdateList(predicateViewModel.LeftSideSelectionViewModel.DataModelPath);
DataModelConditionGroup.AddChild(list, index);
@ -196,7 +196,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
DataModelConditionGroup.RemoveChild(listViewModel.Model);
// Insert a list in the same position
DataModelConditionGeneralPredicate predicate = new DataModelConditionGeneralPredicate(DataModelConditionGroup, ProfileRightSideType.Dynamic);
DataModelConditionGeneralPredicate predicate = new(DataModelConditionGroup, ProfileRightSideType.Dynamic);
predicate.UpdateLeftSide(listViewModel.LeftSideSelectionViewModel.DataModelPath);
DataModelConditionGroup.AddChild(predicate, index);

View File

@ -104,7 +104,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
if (DataModelConditionList.ListPath == null || !DataModelConditionList.ListPath.IsValid)
return;
List<DataModelConditionViewModel> viewModels = new List<DataModelConditionViewModel>();
List<DataModelConditionViewModel> viewModels = new();
foreach (DataModelConditionPart childModel in Model.Children)
{
if (Items.Any(c => c.Model == childModel))

View File

@ -84,8 +84,8 @@
<materialDesign:Card Grid.Row="3" Grid.ColumnSpan="2" Margin="0 5 0 0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@ -95,7 +95,12 @@
<TextBlock Grid.Row="0" Margin="10 10 0 0">
Data binding result
</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" Margin="0 10 10 0" TextAlignment="Right" ToolTip="Click Play to ensure all other data bindings update as well." Cursor="Help">
<TextBlock Grid.Row="0"
Grid.Column="1"
Margin="0 10 10 0"
Visibility="{Binding AlwaysApplyDataBindings.Value, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}}"
ToolTip="Click Play to ensure all other data bindings update as well or enable 'Constantly apply data bindings in editor'"
Cursor="Help">
Other data bindings not updating?
</TextBlock>
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignLightSeparator}" Margin="0" />

View File

@ -122,7 +122,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
}
// Modifier type
ModifierTypeCategoryViewModel root = new ModifierTypeCategoryViewModel(null, null);
ModifierTypeCategoryViewModel root = new(null, null);
IEnumerable<IGrouping<string, BaseDataBindingModifierType>> modifierTypes = _dataBindingService.GetCompatibleModifierTypes(sourceType, ModifierTypePart.Value).GroupBy(t => t.Category);
foreach (IGrouping<string, BaseDataBindingModifierType> dataBindingModifierTypes in modifierTypes)
{

View File

@ -75,7 +75,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
public List<ITimelineKeyframeViewModel> GetAllKeyframeViewModels(bool expandedOnly)
{
List<ITimelineKeyframeViewModel> result = new List<ITimelineKeyframeViewModel>();
List<ITimelineKeyframeViewModel> result = new();
if (expandedOnly && !IsExpanded)
return result;

View File

@ -71,7 +71,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Controls
base.OnRender(drawingContext);
UpdateTimeScale();
Pen linePen = new Pen(Fill, 1);
Pen linePen = new(Fill, 1);
double width = HorizontalOffset + VisibleWidth;
int frameStart = 0;
@ -126,8 +126,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Controls
private void RenderLabel(DrawingContext drawingContext, string text, double x)
{
Typeface typeFace = new Typeface(FontFamily, new FontStyle(), new FontWeight(), new FontStretch());
FormattedText formattedText = new FormattedText(text, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, typeFace, 9, Fill, null, VisualTreeHelper.GetDpi(this).PixelsPerDip);
Typeface typeFace = new(FontFamily, new FontStyle(), new FontWeight(), new FontStretch());
FormattedText formattedText = new(text, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, typeFace, 9, Fill, null, VisualTreeHelper.GetDpi(this).PixelsPerDip);
if (x == 0 && OffsetFirstValue)
drawingContext.DrawText(formattedText, new Point(2, 5));
else

View File

@ -42,7 +42,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Dialogs
public class TimelineSegmentDialogViewModelValidator : AbstractValidator<TimelineSegmentDialogViewModel>
{
private readonly Regex _inputRegex = new Regex("^[.][-|0-9]+$|^-?[0-9]*[.]{0,1}[0-9]*$");
private readonly Regex _inputRegex = new("^[.][-|0-9]+$|^-?[0-9]*[.]{0,1}[0-9]*$");
public TimelineSegmentDialogViewModelValidator()
{

View File

@ -31,7 +31,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Models
if (HasBeenPasted)
throw new ArtemisUIException("Clipboard model can only be pasted once");
List<ILayerPropertyKeyframe> results = new List<ILayerPropertyKeyframe>();
List<ILayerPropertyKeyframe> results = new();
if (!ClipboardModels.Any())
return results;

View File

@ -249,7 +249,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
private void CopyKeyframes(List<ILayerPropertyKeyframe> keyframes)
{
KeyframesClipboardModel clipboardModel = new KeyframesClipboardModel(keyframes);
KeyframesClipboardModel clipboardModel = new(keyframes);
JsonClipboard.SetObject(clipboardModel);
}
@ -261,7 +261,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
private List<ILayerPropertyKeyframe> PasteClipboardData(KeyframesClipboardModel clipboardModel, TimeSpan pastePosition)
{
List<ILayerPropertyKeyframe> pasted = new List<ILayerPropertyKeyframe>();
List<ILayerPropertyKeyframe> pasted = new();
if (clipboardModel == null)
return pasted;
RenderProfileElement target = _profileEditorService.SelectedProfileElement;
@ -368,7 +368,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
return;
Point position = e.GetPosition((IInputElement) sender);
Rect selectedRect = new Rect(_mouseDragStartPoint, position);
Rect selectedRect = new(_mouseDragStartPoint, position);
SelectionRectangle.Rect = selectedRect;
List<ITimelineKeyframeViewModel> keyframeViewModels = GetAllKeyframeViewModels();
@ -386,7 +386,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
if (_mouseDragging && e.LeftButton == MouseButtonState.Pressed)
{
Point position = e.GetPosition((IInputElement) sender);
Rect selectedRect = new Rect(_mouseDragStartPoint, position);
Rect selectedRect = new(_mouseDragStartPoint, position);
SelectionRectangle.Rect = selectedRect;
e.Handled = true;
}
@ -432,7 +432,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
private List<ITimelineKeyframeViewModel> GetAllKeyframeViewModels()
{
List<ITimelineKeyframeViewModel> viewModels = new List<ITimelineKeyframeViewModel>();
List<ITimelineKeyframeViewModel> viewModels = new();
foreach (LayerPropertyGroupViewModel layerPropertyGroupViewModel in LayerPropertyGroups)
viewModels.AddRange(layerPropertyGroupViewModel.GetAllKeyframeViewModels(false));

View File

@ -79,7 +79,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
// Find the BaseLayerBrush parameter, it is required by the base constructor so its there for sure
ParameterInfo brushParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerBrush).IsAssignableFrom(p.ParameterType));
ConstructorArgument argument = new ConstructorArgument(brushParameter.Name, layerBrush);
ConstructorArgument argument = new(brushParameter.Name, layerBrush);
BrushConfigurationViewModel viewModel = (BrushConfigurationViewModel) layerBrush.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
_windowManager.ShowDialog(new LayerBrushSettingsWindowViewModel(viewModel));
@ -105,7 +105,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
throw new ArtemisUIException("Effect configuration dialogs must have exactly one constructor");
ParameterInfo effectParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerEffect).IsAssignableFrom(p.ParameterType));
ConstructorArgument argument = new ConstructorArgument(effectParameter.Name, layerEffect);
ConstructorArgument argument = new(effectParameter.Name, layerEffect);
EffectConfigurationViewModel viewModel = (EffectConfigurationViewModel) layerEffect.Descriptor.Provider.Plugin.Kernel.Get(configurationViewModel.Type, argument);
_windowManager.ShowDialog(new LayerEffectSettingsWindowViewModel(viewModel));
}

View File

@ -24,7 +24,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
return;
e.Handled = true;
MouseWheelEventArgs eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
MouseWheelEventArgs eventArg = new(e.MouseDevice, e.Timestamp, e.Delta)
{
RoutedEvent = UIElement.MouseWheelEvent,
Source = sender

View File

@ -54,7 +54,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem
public List<TreeItemViewModel> GetAllChildren()
{
List<TreeItemViewModel> children = new List<TreeItemViewModel>();
List<TreeItemViewModel> children = new();
foreach (TreeItemViewModel childFolder in Items)
{
// Add all children in this element
@ -128,7 +128,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem
if (!SupportsChildren)
throw new ArtemisUIException("Cannot add a folder to a profile element of type " + ProfileElement.GetType().Name);
Folder _ = new Folder(ProfileElement, "New folder");
Folder _ = new(ProfileElement, "New folder");
_profileEditorService.UpdateSelectedProfile();
}
@ -137,7 +137,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem
if (!SupportsChildren)
throw new ArtemisUIException("Cannot add a layer to a profile element of type " + ProfileElement.GetType().Name);
Layer layer = new Layer(ProfileElement, "New layer");
Layer layer = new(ProfileElement, "New layer");
// Could be null if the default brush got disabled
LayerBrushDescriptor brush = _layerBrushService.GetDefaultLayerBrush();
@ -217,7 +217,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem
Items.Remove(treeItemViewModel);
// Add missing children
List<TreeItemViewModel> newChildren = new List<TreeItemViewModel>();
List<TreeItemViewModel> newChildren = new();
foreach (ProfileElement profileElement in ProfileElement.Children.OrderBy(c => c.Order))
if (profileElement is Folder folder)
{

Some files were not shown because too many files have changed in this diff Show More