mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Profiles - Added enter, main and exit timelines
Display conditions - Fleshed out most of the UI
This commit is contained in:
1 parent
0e873a48cf
commit
7cfe9a46ee
26 files changed
+282
-75
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Storage.Entities.Profile.Abstract;
|
||||
|
||||
@@ -34,9 +35,10 @@ namespace Artemis.Core.Models.Profile.Conditions.Abstract
|
||||
}
|
||||
}
|
||||
|
||||
public abstract DisplayConditionPartEntity GetEntity();
|
||||
public abstract bool Evaluate();
|
||||
|
||||
internal abstract void ApplyToEntity();
|
||||
internal abstract void Initialize(IDataModelService dataModelService);
|
||||
internal abstract void ApplyToEntity();
|
||||
internal abstract DisplayConditionPartEntity GetEntity();
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,23 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
public BooleanOperator BooleanOperator { get; set; }
|
||||
public DisplayConditionGroupEntity DisplayConditionGroupEntity { get; set; }
|
||||
|
||||
public override bool Evaluate()
|
||||
{
|
||||
switch (BooleanOperator)
|
||||
{
|
||||
case BooleanOperator.And:
|
||||
return Children.All(c => c.Evaluate());
|
||||
case BooleanOperator.Or:
|
||||
return Children.Any(c => c.Evaluate());
|
||||
case BooleanOperator.AndNot:
|
||||
return Children.All(c => !c.Evaluate());
|
||||
case BooleanOperator.OrNot:
|
||||
return Children.Any(c => !c.Evaluate());
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
internal override void ApplyToEntity()
|
||||
{
|
||||
DisplayConditionGroupEntity.BooleanOperator = (int) BooleanOperator;
|
||||
@@ -49,7 +66,7 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
child.Initialize(dataModelService);
|
||||
}
|
||||
|
||||
public override DisplayConditionPartEntity GetEntity()
|
||||
internal override DisplayConditionPartEntity GetEntity()
|
||||
{
|
||||
return DisplayConditionGroupEntity;
|
||||
}
|
||||
|
||||
@@ -8,18 +8,24 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
{
|
||||
public ListOperator ListOperator { get; set; }
|
||||
|
||||
public override bool Evaluate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
internal override void ApplyToEntity()
|
||||
{
|
||||
}
|
||||
|
||||
internal override void Initialize(IDataModelService dataModelService)
|
||||
{
|
||||
}
|
||||
|
||||
public override DisplayConditionPartEntity GetEntity()
|
||||
internal override DisplayConditionPartEntity GetEntity()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
internal override void Initialize(IDataModelService dataModelService)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public enum ListOperator
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
|
||||
ValidateOperator();
|
||||
ValidateRightSide();
|
||||
|
||||
CreateExpression();
|
||||
}
|
||||
|
||||
@@ -91,6 +92,7 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
RightPropertyPath = null;
|
||||
|
||||
SetStaticValue(staticValue);
|
||||
|
||||
CreateExpression();
|
||||
}
|
||||
|
||||
@@ -111,14 +113,21 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
var leftType = LeftDataModel.GetTypeAtPath(LeftPropertyPath);
|
||||
if (displayConditionOperator.SupportsType(leftType))
|
||||
Operator = displayConditionOperator;
|
||||
|
||||
CreateExpression();
|
||||
}
|
||||
|
||||
public void CreateExpression()
|
||||
private void CreateExpression()
|
||||
{
|
||||
DynamicConditionLambda = null;
|
||||
CompiledDynamicConditionLambda = null;
|
||||
StaticConditionLambda = null;
|
||||
CompiledStaticConditionLambda = null;
|
||||
|
||||
if (PredicateType == PredicateType.Dynamic)
|
||||
CreateDynamicExpression();
|
||||
else
|
||||
CreateStaticExpression();
|
||||
|
||||
CreateStaticExpression();
|
||||
}
|
||||
|
||||
internal override void ApplyToEntity()
|
||||
@@ -134,6 +143,16 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
DisplayConditionPredicateEntity.OperatorType = Operator?.GetType().Name;
|
||||
}
|
||||
|
||||
public override bool Evaluate()
|
||||
{
|
||||
if (CompiledDynamicConditionLambda != null)
|
||||
return CompiledDynamicConditionLambda(LeftDataModel, RightDataModel);
|
||||
if (CompiledStaticConditionLambda != null)
|
||||
return CompiledStaticConditionLambda(LeftDataModel);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
internal override void Initialize(IDataModelService dataModelService)
|
||||
{
|
||||
// Left side
|
||||
@@ -184,7 +203,7 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
}
|
||||
}
|
||||
|
||||
public override DisplayConditionPartEntity GetEntity()
|
||||
internal override DisplayConditionPartEntity GetEntity()
|
||||
{
|
||||
return DisplayConditionPredicateEntity;
|
||||
}
|
||||
@@ -199,9 +218,6 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
Operator = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the right side, ensuring it is still compatible with the current left side
|
||||
/// </summary>
|
||||
private void ValidateRightSide()
|
||||
{
|
||||
var leftSideType = LeftDataModel.GetTypeAtPath(LeftPropertyPath);
|
||||
@@ -223,10 +239,6 @@ namespace Artemis.Core.Models.Profile.Conditions
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the current static value, ensuring it is a valid type. This assumes the types are compatible if they
|
||||
/// differ.
|
||||
/// </summary>
|
||||
private void SetStaticValue(object staticValue)
|
||||
{
|
||||
// If the left side is empty simply apply the value, any validation will wait
|
||||
|
||||
Reference in new issue
Block a user