Core - Flattened namespaces

Shared UI - Flattened namespaces
Shared UI - General housekeeping
Project - Code cleanup
This commit is contained in:
SpoinkyNL committed 2020-09-01 00:14:08 +02:00
1 parent 029e39ec1d
commit 8718d01eae
454 files changed
+1678 -1938

No files matched your search

@@ -3,11 +3,11 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using Artemis.Core.Annotations;
using Artemis.Core.Properties;
using SkiaSharp;
using Stylet;
namespace Artemis.Core.Models.Profile.Colors
namespace Artemis.Core
{
/// <summary>
/// A gradient containing a list of <see cref="ColorGradientStop" />s
@@ -136,7 +136,7 @@ namespace Artemis.Core.Models.Profile.Colors
/// <inheritdoc />
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
internal virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
@@ -1,9 +1,9 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Artemis.Core.Annotations;
using Artemis.Core.Properties;
using SkiaSharp;
namespace Artemis.Core.Models.Profile.Colors
namespace Artemis.Core
{
/// <summary>
/// A color with a position, usually contained in a <see cref="ColorGradient" />
@@ -1,8 +1,8 @@
using System.Collections.Generic;
using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services;
using Artemis.Storage.Entities.Profile.Abstract;
namespace Artemis.Core.Models.Profile.Conditions.Abstract
namespace Artemis.Core
{
/// <summary>
/// An abstract class for display condition parts
@@ -10,7 +10,7 @@ namespace Artemis.Core.Models.Profile.Conditions.Abstract
public abstract class DisplayConditionPart
{
private readonly List<DisplayConditionPart> _children = new List<DisplayConditionPart>();
/// <summary>
/// Gets the parent of this part
/// </summary>
@@ -1,12 +1,10 @@
using System;
using System.Linq;
using Artemis.Core.Models.Profile.Conditions.Abstract;
using Artemis.Core.Services.Interfaces;
using Artemis.Storage.Entities.Profile;
using Artemis.Core.Services;
using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.Conditions;
namespace Artemis.Core.Models.Profile.Conditions
namespace Artemis.Core
{
/// <summary>
/// A group containing zero to many <see cref="DisplayConditionPart" />s which it evaluates using a boolean specific
@@ -2,15 +2,12 @@
using System.Collections;
using System.Linq;
using System.Linq.Expressions;
using Artemis.Core.Exceptions;
using Artemis.Core.Models.Profile.Conditions.Abstract;
using Artemis.Core.Plugins.DataModelExpansions;
using Artemis.Core.Services.Interfaces;
using Artemis.Storage.Entities.Profile;
using Artemis.Core.DataModelExpansions;
using Artemis.Core.Services;
using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.Conditions;
namespace Artemis.Core.Models.Profile.Conditions
namespace Artemis.Core
{
public class DisplayConditionList : DisplayConditionPart
{
@@ -33,6 +30,8 @@ namespace Artemis.Core.Models.Profile.Conditions
public DataModel ListDataModel { get; private set; }
public string ListPropertyPath { get; private set; }
public Func<object, IList> CompiledListAccessor { get; set; }
public override bool Evaluate()
{
if (CompiledListAccessor == null)
@@ -59,6 +58,47 @@ namespace Artemis.Core.Models.Profile.Conditions
};
}
public void UpdateList(DataModel dataModel, string path)
{
if (dataModel != null && path == null)
throw new ArtemisCoreException("If a data model is provided, a path is also required");
if (dataModel == null && path != null)
throw new ArtemisCoreException("If path is provided, a data model is also required");
if (dataModel != null)
{
if (!dataModel.ContainsPath(path))
throw new ArtemisCoreException($"Data model of type {dataModel.GetType().Name} does not contain a property at path '{path}'");
if (dataModel.GetListTypeAtPath(path) == null)
throw new ArtemisCoreException($"The path '{path}' does not contain a list");
}
// Remove the old root group that was tied to the old data model
while (Children.Any())
RemoveChild(Children[0]);
ListDataModel = dataModel;
ListPropertyPath = path;
if (dataModel == null)
return;
// Create a new root group
AddChild(new DisplayConditionGroup(this));
CreateExpression();
}
public void CreateExpression()
{
var parameter = Expression.Parameter(typeof(object), "listDataModel");
var accessor = ListPropertyPath.Split('.').Aggregate<string, Expression>(
Expression.Convert(parameter, ListDataModel.GetType()),
(expression, s) => Expression.Convert(Expression.Property(expression, s), typeof(IList)));
var lambda = Expression.Lambda<Func<object, IList>>(accessor, parameter);
CompiledListAccessor = lambda.Compile();
}
internal override void ApplyToEntity()
{
// Target list
@@ -103,51 +143,9 @@ namespace Artemis.Core.Models.Profile.Conditions
Entity.Children.Clear();
AddChild(new DisplayConditionGroup(this));
}
Children[0].Initialize(dataModelService);
}
public void UpdateList(DataModel dataModel, string path)
{
if (dataModel != null && path == null)
throw new ArtemisCoreException("If a data model is provided, a path is also required");
if (dataModel == null && path != null)
throw new ArtemisCoreException("If path is provided, a data model is also required");
if (dataModel != null)
{
if (!dataModel.ContainsPath(path))
throw new ArtemisCoreException($"Data model of type {dataModel.GetType().Name} does not contain a property at path '{path}'");
if (dataModel.GetListTypeAtPath(path) == null)
throw new ArtemisCoreException($"The path '{path}' does not contain a list");
}
// Remove the old root group that was tied to the old data model
while (Children.Any())
RemoveChild(Children[0]);
ListDataModel = dataModel;
ListPropertyPath = path;
if (dataModel == null)
return;
// Create a new root group
AddChild(new DisplayConditionGroup(this));
CreateExpression();
}
public void CreateExpression()
{
var parameter = Expression.Parameter(typeof(object), "listDataModel");
var accessor = ListPropertyPath.Split('.').Aggregate<string, Expression>(
Expression.Convert(parameter, ListDataModel.GetType()),
(expression, s) => Expression.Convert(Expression.Property(expression, s), typeof(IList)));
var lambda = Expression.Lambda<Func<object, IList>>(accessor, parameter);
CompiledListAccessor = lambda.Compile();
}
public Func<object, IList> CompiledListAccessor { get; set; }
}
public enum ListOperator
@@ -1,16 +1,13 @@
using System;
using System.Linq;
using System.Linq.Expressions;
using Artemis.Core.Exceptions;
using Artemis.Core.Extensions;
using Artemis.Core.Models.Profile.Conditions.Abstract;
using Artemis.Core.Plugins.DataModelExpansions;
using Artemis.Core.Services.Interfaces;
using Artemis.Core.DataModelExpansions;
using Artemis.Core.Services;
using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.Conditions;
using Newtonsoft.Json;
namespace Artemis.Core.Models.Profile.Conditions
namespace Artemis.Core
{
public class DisplayConditionListPredicate : DisplayConditionPart
{
@@ -2,11 +2,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Artemis.Core.Extensions;
using Artemis.Core.Plugins;
using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services;
namespace Artemis.Core.Models.Profile.Conditions
namespace Artemis.Core
{
/// <summary>
/// A display condition operator is used by the conditions system to perform a specific boolean check
@@ -1,16 +1,13 @@
using System;
using System.Linq;
using System.Linq.Expressions;
using Artemis.Core.Exceptions;
using Artemis.Core.Extensions;
using Artemis.Core.Models.Profile.Conditions.Abstract;
using Artemis.Core.Plugins.DataModelExpansions;
using Artemis.Core.Services.Interfaces;
using Artemis.Core.DataModelExpansions;
using Artemis.Core.Services;
using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.Conditions;
using Newtonsoft.Json;
namespace Artemis.Core.Models.Profile.Conditions
namespace Artemis.Core
{
/// <summary>
/// A predicate in a display condition using either two data model values or one data model value and a
@@ -198,8 +195,10 @@ namespace Artemis.Core.Models.Profile.Conditions
var leftType = LeftDataModel.GetTypeAtPath(LeftPropertyPath);
if (!displayConditionOperator.SupportsType(leftType))
{
throw new ArtemisCoreException($"Cannot apply operator {displayConditionOperator.GetType().Name} to this predicate because " +
$"it does not support left side type {leftType.Name}");
}
Operator = displayConditionOperator;
CreateExpression();
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq.Expressions;
namespace Artemis.Core.Models.Profile.Conditions.Operators
namespace Artemis.Core
{
internal class EqualsConditionOperator : DisplayConditionOperator
{
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq.Expressions;
namespace Artemis.Core.Models.Profile.Conditions.Operators
namespace Artemis.Core
{
internal class GreaterThanConditionOperator : DisplayConditionOperator
{
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq.Expressions;
namespace Artemis.Core.Models.Profile.Conditions.Operators
namespace Artemis.Core
{
internal class GreaterThanOrEqualConditionOperator : DisplayConditionOperator
{
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq.Expressions;
namespace Artemis.Core.Models.Profile.Conditions.Operators
namespace Artemis.Core
{
internal class LessThanConditionOperator : DisplayConditionOperator
{
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq.Expressions;
namespace Artemis.Core.Models.Profile.Conditions.Operators
namespace Artemis.Core
{
internal class LessThanOrEqualConditionOperator : DisplayConditionOperator
{
@@ -2,11 +2,11 @@
using System.Collections.Generic;
using System.Linq.Expressions;
namespace Artemis.Core.Models.Profile.Conditions.Operators
namespace Artemis.Core
{
internal class NotEqualConditionOperator : DisplayConditionOperator
{
public override IReadOnlyCollection<Type> CompatibleTypes => new List<Type> { typeof(object) };
public override IReadOnlyCollection<Type> CompatibleTypes => new List<Type> {typeof(object)};
public override string Description => "Does not equal";
public override string Icon => "NotEqualVariant";
@@ -3,17 +3,17 @@ using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
namespace Artemis.Core.Models.Profile.Conditions.Operators
namespace Artemis.Core
{
internal class StringContainsConditionOperator : DisplayConditionOperator
{
private readonly MethodInfo _toLower;
private readonly MethodInfo _contains;
private readonly MethodInfo _toLower;
public StringContainsConditionOperator()
{
_toLower = typeof(string).GetMethod("ToLower", new Type[] { });
_contains = typeof(string).GetMethod("Contains", new[] {typeof(string) });
_contains = typeof(string).GetMethod("Contains", new[] {typeof(string)});
}
public override IReadOnlyCollection<Type> CompatibleTypes => new List<Type> {typeof(string)};
@@ -3,20 +3,20 @@ using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
namespace Artemis.Core.Models.Profile.Conditions.Operators
namespace Artemis.Core
{
internal class StringEndsWithConditionOperator : DisplayConditionOperator
{
private readonly MethodInfo _toLower;
private readonly MethodInfo _endsWith;
private readonly MethodInfo _toLower;
public StringEndsWithConditionOperator()
{
_toLower = typeof(string).GetMethod("ToLower", new Type[] { });
_endsWith = typeof(string).GetMethod("EndsWith", new[] { typeof(string) });
_endsWith = typeof(string).GetMethod("EndsWith", new[] {typeof(string)});
}
public override IReadOnlyCollection<Type> CompatibleTypes => new List<Type> { typeof(string) };
public override IReadOnlyCollection<Type> CompatibleTypes => new List<Type> {typeof(string)};
public override string Description => "Ends with";
public override string Icon => "ContainEnd";
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
namespace Artemis.Core.Models.Profile.Conditions.Operators
namespace Artemis.Core
{
internal class StringEqualsConditionOperator : DisplayConditionOperator
{
@@ -3,20 +3,20 @@ using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
namespace Artemis.Core.Models.Profile.Conditions.Operators
namespace Artemis.Core
{
internal class StringNotContainsConditionOperator : DisplayConditionOperator
{
private readonly MethodInfo _toLower;
private readonly MethodInfo _contains;
private readonly MethodInfo _toLower;
public StringNotContainsConditionOperator()
{
_toLower = typeof(string).GetMethod("ToLower", new Type[] { });
_contains = typeof(string).GetMethod("Contains", new[] { typeof(string) });
_contains = typeof(string).GetMethod("Contains", new[] {typeof(string)});
}
public override IReadOnlyCollection<Type> CompatibleTypes => new List<Type> { typeof(string) };
public override IReadOnlyCollection<Type> CompatibleTypes => new List<Type> {typeof(string)};
public override string Description => "Does not contain";
public override string Icon => "FormatStrikethrough";
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
namespace Artemis.Core.Models.Profile.Conditions.Operators
namespace Artemis.Core
{
internal class StringNotEqualConditionOperator : DisplayConditionOperator
{
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq.Expressions;
namespace Artemis.Core.Models.Profile.Conditions.Operators
namespace Artemis.Core
{
internal class StringNullConditionOperator : DisplayConditionOperator
{
@@ -3,20 +3,20 @@ using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
namespace Artemis.Core.Models.Profile.Conditions.Operators
namespace Artemis.Core
{
internal class StringStartsWithConditionOperator : DisplayConditionOperator
{
private readonly MethodInfo _toLower;
private readonly MethodInfo _startsWith;
private readonly MethodInfo _toLower;
public StringStartsWithConditionOperator()
{
_toLower = typeof(string).GetMethod("ToLower", new Type[] { });
_startsWith = typeof(string).GetMethod("StartsWith", new[] { typeof(string) });
_startsWith = typeof(string).GetMethod("StartsWith", new[] {typeof(string)});
}
public override IReadOnlyCollection<Type> CompatibleTypes => new List<Type> { typeof(string) };
public override IReadOnlyCollection<Type> CompatibleTypes => new List<Type> {typeof(string)};
public override string Description => "Starts with";
public override string Icon => "ContainStart";
@@ -1,8 +1,7 @@
using System.Collections.Generic;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Plugins.DataModelExpansions;
using Artemis.Core.DataModelExpansions;
namespace Artemis.Core.Models.Profile.DataBindings
namespace Artemis.Core
{
/// <summary>
/// A data binding that binds a certain <see cref="BaseLayerProperty" /> to a value inside a <see cref="DataModel" />
@@ -1,14 +1,12 @@
using System;
using System.Linq;
using System.Linq.Expressions;
using Artemis.Core.Exceptions;
using Artemis.Core.Models.Profile.DataBindings.Modifiers;
using Artemis.Core.Plugins.DataModelExpansions;
using Artemis.Core.Services.Interfaces;
using Artemis.Core.DataModelExpansions;
using Artemis.Core.Services;
using Artemis.Storage.Entities.Profile.DataBindings;
using Newtonsoft.Json;
namespace Artemis.Core.Models.Profile.DataBindings
namespace Artemis.Core
{
/// <summary>
/// Modifies a data model value in a way defined by the modifier type
@@ -2,20 +2,17 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Artemis.Core.Extensions;
using Artemis.Core.Plugins;
using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces;
namespace Artemis.Core.Models.Profile.DataBindings.Modifiers
namespace Artemis.Core
{
/// <summary>
/// A modifier that changes the source value of a data binding in some way
/// A modifier that changes the source value of a data binding in some way
/// </summary>
public abstract class DataBindingModifierType
{
private bool _registered;
private IDataBindingService _dataBindingService;
private bool _registered;
/// <summary>
/// Gets the plugin info this data binding modifier belongs to
+3 -4
View File
@@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Plugins.LayerEffects;
using Artemis.Core.Utilities;
using Artemis.Core.LayerEffects;
using Artemis.Storage.Entities.Profile;
using Artemis.Storage.Entities.Profile.Abstract;
using SkiaSharp;
namespace Artemis.Core.Models.Profile
namespace Artemis.Core
{
public sealed class Folder : RenderProfileElement
{
@@ -183,7 +182,7 @@ namespace Artemis.Core.Models.Profile
profileElement.Render(deltaTime, folderCanvas, _folderBitmap.Info);
folderCanvas.Restore();
}
// If required, apply the opacity override of the module to the root folder
if (IsRootFolder && Profile.Module.OpacityOverride < 1)
{
+5 -14
View File
@@ -2,21 +2,14 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Artemis.Core.Extensions;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
using Artemis.Core.Models.Profile.LayerShapes;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.LayerBrushes;
using Artemis.Core.Plugins.LayerBrushes.Internal;
using Artemis.Core.Plugins.LayerEffects;
using Artemis.Core.LayerBrushes;
using Artemis.Core.LayerEffects;
using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces;
using Artemis.Storage.Entities.Profile;
using Artemis.Storage.Entities.Profile.Abstract;
using SkiaSharp;
namespace Artemis.Core.Models.Profile
namespace Artemis.Core
{
/// <summary>
/// Represents a layer on a profile. To create new layers use the <see cref="RenderElementService" /> by injecting
@@ -232,10 +225,10 @@ namespace Artemis.Core.Models.Profile
switch (General.ShapeType.CurrentValue)
{
case LayerShapeType.Ellipse:
LayerShape = new Ellipse(this);
LayerShape = new EllipseShape(this);
break;
case LayerShapeType.Rectangle:
LayerShape = new Rectangle(this);
LayerShape = new RectangleShape(this);
break;
default:
throw new ArgumentOutOfRangeException();
@@ -291,9 +284,7 @@ namespace Artemis.Core.Models.Profile
if (stickToMainSegment)
{
if (!DisplayContinuously)
{
TimelinePosition = StartSegmentLength + timeOverride;
}
else
{
var progress = timeOverride.TotalMilliseconds % MainSegmentLength.TotalMilliseconds;
@@ -1,7 +1,7 @@
using System;
using Artemis.Core.Plugins.LayerBrushes;
using Artemis.Core.LayerBrushes;
namespace Artemis.Core.Models.Profile
namespace Artemis.Core
{
/// <summary>
/// A reference to a <see cref="LayerBrushDescriptor" />
@@ -1,8 +1,6 @@
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
using Artemis.Core.Models.Profile.LayerProperties.Types;
using SkiaSharp;
using SkiaSharp;
namespace Artemis.Core.Models.Profile
namespace Artemis.Core
{
public class LayerGeneralProperties : LayerPropertyGroup
{
@@ -1,6 +1,6 @@
using System;
namespace Artemis.Core.Models.Profile.LayerProperties.Attributes
namespace Artemis.Core
{
public class PropertyDescriptionAttribute : Attribute
{
@@ -1,6 +1,6 @@
using System;
namespace Artemis.Core.Models.Profile.LayerProperties.Attributes
namespace Artemis.Core
{
public class PropertyGroupDescriptionAttribute : Attribute
{
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Artemis.Core.Events;
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
using Artemis.Storage.Entities.Profile;
namespace Artemis.Core.Models.Profile.LayerProperties
namespace Artemis.Core
{
/// <summary>
/// For internal use only, to implement your own layer property type, extend <see cref="LayerProperty{T}" /> instead.
@@ -1,8 +1,7 @@
using System;
using Artemis.Core.Utilities;
using Stylet;
namespace Artemis.Core.Models.Profile.LayerProperties
namespace Artemis.Core
{
/// <summary>
/// For internal use only, use <see cref="LayerPropertyKeyframe{T}" /> instead.
@@ -3,12 +3,10 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using Artemis.Core.Exceptions;
using Artemis.Core.Utilities;
using Artemis.Storage.Entities.Profile;
using Newtonsoft.Json;
namespace Artemis.Core.Models.Profile.LayerProperties
namespace Artemis.Core
{
/// <summary>
/// Represents a property on a layer. Properties are saved in storage and can optionally be modified from the UI.
@@ -175,7 +173,10 @@ namespace Artemis.Core.Models.Profile.LayerProperties
}
/// <inheritdoc />
public override Type GetPropertyType() => typeof(T);
public override Type GetPropertyType()
{
return typeof(T);
}
/// <inheritdoc />
public override List<PropertyInfo> GetDataBindingProperties()
@@ -1,13 +1,12 @@
using System;
using Artemis.Core.Utilities;
namespace Artemis.Core.Models.Profile.LayerProperties
namespace Artemis.Core
{
public class LayerPropertyKeyframe<T> : BaseLayerPropertyKeyframe
{
private LayerProperty<T> _layerProperty;
private TimeSpan _position;
private T _value;
private LayerProperty<T> _layerProperty;
public LayerPropertyKeyframe(T value, TimeSpan position, Easings.Functions easingFunction, LayerProperty<T> layerProperty) : base(layerProperty)
{
@@ -1,8 +1,6 @@
using Artemis.Core.Exceptions;
using Artemis.Core.Models.Profile.Colors;
using Artemis.Storage.Entities.Profile;
using Artemis.Storage.Entities.Profile;
namespace Artemis.Core.Models.Profile.LayerProperties.Types
namespace Artemis.Core
{
/// <inheritdoc />
public class ColorGradientLayerProperty : LayerProperty<ColorGradient>
@@ -1,7 +1,6 @@
using System;
using Artemis.Core.Exceptions;
namespace Artemis.Core.Models.Profile.LayerProperties.Types
namespace Artemis.Core
{
/// <inheritdoc />
public class EnumLayerProperty<T> : LayerProperty<T> where T : Enum
@@ -1,4 +1,4 @@
namespace Artemis.Core.Models.Profile.LayerProperties.Types
namespace Artemis.Core
{
/// <inheritdoc />
public class FloatLayerProperty : LayerProperty<float>
@@ -1,6 +1,6 @@
using System;
namespace Artemis.Core.Models.Profile.LayerProperties.Types
namespace Artemis.Core
{
/// <inheritdoc />
public class IntLayerProperty : LayerProperty<int>
@@ -1,6 +1,4 @@
using Artemis.Core.Exceptions;
namespace Artemis.Core.Models.Profile.LayerProperties.Types
namespace Artemis.Core
{
/// <summary>
/// A special layer property used to configure the selected layer brush
@@ -1,8 +1,7 @@
using System;
using Artemis.Core.Extensions;
using SkiaSharp;
namespace Artemis.Core.Models.Profile.LayerProperties.Types
namespace Artemis.Core
{
/// <inheritdoc />
public class SKColorLayerProperty : LayerProperty<SKColor>
@@ -1,6 +1,6 @@
using SkiaSharp;
namespace Artemis.Core.Models.Profile.LayerProperties.Types
namespace Artemis.Core
{
/// <inheritdoc />
public class SKPointLayerProperty : LayerProperty<SKPoint>
@@ -3,7 +3,7 @@ using System.Linq;
using System.Reflection;
using SkiaSharp;
namespace Artemis.Core.Models.Profile.LayerProperties.Types
namespace Artemis.Core
{
/// <inheritdoc />
public class SKSizeLayerProperty : LayerProperty<SKSize>
@@ -17,16 +17,16 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
return p.CurrentValue;
}
public override List<PropertyInfo> GetDataBindingProperties()
{
return typeof(SKSize).GetProperties().Where(p => p.CanWrite).ToList();
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
var widthDiff = NextKeyframe.Value.Width - CurrentKeyframe.Value.Width;
var heightDiff = NextKeyframe.Value.Height - CurrentKeyframe.Value.Height;
CurrentValue = new SKSize(CurrentKeyframe.Value.Width + widthDiff * keyframeProgressEased, CurrentKeyframe.Value.Height + heightDiff * keyframeProgressEased);
}
public override List<PropertyInfo> GetDataBindingProperties()
{
return typeof(SKSize).GetProperties().Where(p => p.CanWrite).ToList();
}
}
}
@@ -2,19 +2,13 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Artemis.Core.Annotations;
using Artemis.Core.Events;
using Artemis.Core.Exceptions;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Plugins.LayerBrushes;
using Artemis.Core.Plugins.LayerBrushes.Internal;
using Artemis.Core.Plugins.LayerEffects;
using Artemis.Core.Services.Interfaces;
using Artemis.Core.LayerBrushes;
using Artemis.Core.LayerEffects;
using Artemis.Core.Properties;
using Artemis.Core.Services;
using Artemis.Storage.Entities.Profile;
namespace Artemis.Core.Models.Profile
namespace Artemis.Core
{
public abstract class LayerPropertyGroup : IDisposable
{
@@ -89,6 +83,13 @@ namespace Artemis.Core.Models.Profile
/// </summary>
public ReadOnlyCollection<LayerPropertyGroup> LayerPropertyGroups => _layerPropertyGroups.AsReadOnly();
public void Dispose()
{
DisableProperties();
foreach (var layerPropertyGroup in _layerPropertyGroups)
layerPropertyGroup.Dispose();
}
/// <summary>
/// Recursively gets all layer properties on this group and any subgroups
/// </summary>
@@ -108,13 +109,6 @@ namespace Artemis.Core.Models.Profile
return _allLayerProperties;
}
public void Dispose()
{
DisableProperties();
foreach (var layerPropertyGroup in _layerPropertyGroups)
layerPropertyGroup.Dispose();
}
/// <summary>
/// Called before property group is activated to allow you to populate <see cref="LayerProperty{T}.DefaultValue" /> on
/// the properties you want
@@ -1,13 +1,17 @@
using SkiaSharp;
namespace Artemis.Core.Models.Profile.LayerShapes
namespace Artemis.Core
{
public class Ellipse : LayerShape
/// <summary>
/// Represents an ellipse layer shape
/// </summary>
public class EllipseShape : LayerShape
{
public Ellipse(Layer layer) : base(layer)
internal EllipseShape(Layer layer) : base(layer)
{
}
/// <inheritdoc />
public override void CalculateRenderProperties()
{
var path = new SKPath();
@@ -1,10 +1,13 @@
using SkiaSharp;
namespace Artemis.Core.Models.Profile.LayerShapes
namespace Artemis.Core
{
/// <summary>
/// Represents the shape of a layer
/// </summary>
public abstract class LayerShape
{
protected LayerShape(Layer layer)
internal LayerShape(Layer layer)
{
Layer = layer;
}
@@ -19,6 +22,9 @@ namespace Artemis.Core.Models.Profile.LayerShapes
/// </summary>
public SKPath Path { get; protected set; }
/// <summary>
/// Calculates the <see cref="Path" />
/// </summary>
public abstract void CalculateRenderProperties();
}
}
@@ -1,13 +1,17 @@
using SkiaSharp;
namespace Artemis.Core.Models.Profile.LayerShapes
namespace Artemis.Core
{
public class Rectangle : LayerShape
/// <summary>
/// Represents a rectangular layer shape
/// </summary>
public class RectangleShape : LayerShape
{
public Rectangle(Layer layer) : base(layer)
internal RectangleShape(Layer layer) : base(layer)
{
}
/// <inheritdoc />
public override void CalculateRenderProperties()
{
var path = new SKPath();
@@ -1,8 +1,6 @@
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
using Artemis.Core.Models.Profile.LayerProperties.Types;
using SkiaSharp;
using SkiaSharp;
namespace Artemis.Core.Models.Profile
namespace Artemis.Core
{
public class LayerTransformProperties : LayerPropertyGroup
{
+2 -4
View File
@@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Exceptions;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Modules;
using Artemis.Core.Modules;
using Artemis.Storage.Entities.Profile;
using SkiaSharp;
namespace Artemis.Core.Models.Profile
namespace Artemis.Core
{
public sealed class Profile : ProfileElement
{
@@ -1,8 +1,8 @@
using System;
using Artemis.Core.Plugins.Modules;
using Artemis.Core.Modules;
using Artemis.Storage.Entities.Profile;
namespace Artemis.Core.Models.Profile
namespace Artemis.Core
{
public class ProfileDescriptor
{
@@ -5,23 +5,10 @@ using System.Linq;
using SkiaSharp;
using Stylet;
namespace Artemis.Core.Models.Profile
namespace Artemis.Core
{
public abstract class ProfileElement : PropertyChangedBase, IDisposable
{
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected bool _disposed;
private bool _enabled;
private Guid _entityId;
@@ -86,6 +73,12 @@ namespace Artemis.Core.Models.Profile
set => SetAndNotify(ref _enabled, value);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Updates the element
/// </summary>
@@ -201,6 +194,13 @@ namespace Artemis.Core.Models.Profile
return $"{nameof(EntityId)}: {EntityId}, {nameof(Order)}: {Order}, {nameof(Name)}: {Name}";
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
}
}
/// <summary>
/// Applies the profile element's properties to the underlying storage entity
/// </summary>
@@ -1,4 +1,4 @@
namespace Artemis.Core.Models.Profile
namespace Artemis.Core
{
/// <summary>
/// An enum defining the right side type of a profile entity
@@ -1,11 +1,6 @@
using System.Collections.Generic;
using Artemis.Storage.Entities.Profile;
using SkiaSharp;
namespace Artemis.Core.Models.Profile
namespace Artemis.Core
{
public abstract class PropertiesProfileElement : ProfileElement
{
}
}
@@ -2,18 +2,31 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Artemis.Core.Annotations;
using Artemis.Core.Models.Profile.Conditions;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Plugins.LayerEffects;
using Artemis.Core.LayerEffects;
using Artemis.Core.Properties;
using Artemis.Storage.Entities.Profile;
using Artemis.Storage.Entities.Profile.Abstract;
using SkiaSharp;
namespace Artemis.Core.Models.Profile
namespace Artemis.Core
{
public abstract class RenderProfileElement : ProfileElement
{
/// <summary>
/// Returns a list of all keyframes on all properties and effects of this layer
/// </summary>
public virtual List<BaseLayerPropertyKeyframe> GetAllKeyframes()
{
var keyframes = new List<BaseLayerPropertyKeyframe>();
foreach (var layerEffect in LayerEffects)
{
foreach (var baseLayerProperty in layerEffect.BaseProperties.GetAllLayerProperties())
keyframes.AddRange(baseLayerProperty.BaseKeyframes);
}
return keyframes;
}
protected void ApplyRenderElementDefaults()
{
MainSegmentLength = TimeSpan.FromSeconds(5);
@@ -54,21 +67,6 @@ namespace Artemis.Core.Models.Profile
}
}
/// <summary>
/// Returns a list of all keyframes on all properties and effects of this layer
/// </summary>
public virtual List<BaseLayerPropertyKeyframe> GetAllKeyframes()
{
var keyframes = new List<BaseLayerPropertyKeyframe>();
foreach (var layerEffect in LayerEffects)
{
foreach (var baseLayerProperty in layerEffect.BaseProperties.GetAllLayerProperties())
keyframes.AddRange(baseLayerProperty.BaseKeyframes);
}
return keyframes;
}
#region Properties
private SKPath _path;
@@ -215,7 +213,7 @@ namespace Artemis.Core.Models.Profile
/// <summary>
/// Overrides the progress of the element
/// Overrides the progress of the element
/// </summary>
/// <param name="timeOverride"></param>
/// <param name="stickToMainSegment"></param>