diff --git a/src/Artemis.Core/Models/Profile/Conditions/Abstract/DataModelConditionPart.cs b/src/Artemis.Core/Models/Profile/Conditions/Abstract/DataModelConditionPart.cs
index f16df9e7d..bca0ebc4d 100644
--- a/src/Artemis.Core/Models/Profile/Conditions/Abstract/DataModelConditionPart.cs
+++ b/src/Artemis.Core/Models/Profile/Conditions/Abstract/DataModelConditionPart.cs
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
-using Artemis.Core.Services;
+using System.Collections.ObjectModel;
using Artemis.Storage.Entities.Profile.Abstract;
namespace Artemis.Core
@@ -20,18 +20,22 @@ namespace Artemis.Core
///
/// Gets the children of this part
///
- public IReadOnlyList Children => _children.AsReadOnly();
+ public ReadOnlyCollection Children => _children.AsReadOnly();
///
/// Adds a child to the display condition part's collection
///
///
- public void AddChild(DataModelConditionPart dataModelConditionPart)
+ /// An optional index at which to insert the condition
+ public void AddChild(DataModelConditionPart dataModelConditionPart, int? index = null)
{
if (!_children.Contains(dataModelConditionPart))
{
dataModelConditionPart.Parent = this;
- _children.Add(dataModelConditionPart);
+ if (index != null)
+ _children.Insert(index.Value, dataModelConditionPart);
+ else
+ _children.Add(dataModelConditionPart);
}
}
diff --git a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionListPredicate.cs b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionListPredicate.cs
index baabcf6be..cf35171cf 100644
--- a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionListPredicate.cs
+++ b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionListPredicate.cs
@@ -17,7 +17,7 @@ namespace Artemis.Core
///
///
///
- public DataModelConditionListPredicate(DataModelConditionPart parent, ListRightSideType predicateType)
+ public DataModelConditionListPredicate(DataModelConditionPart parent, ProfileRightSideType predicateType)
{
Parent = parent;
PredicateType = predicateType;
@@ -32,7 +32,7 @@ namespace Artemis.Core
{
Parent = parent;
Entity = entity;
- PredicateType = (ListRightSideType) entity.PredicateType;
+ PredicateType = (ProfileRightSideType) entity.PredicateType;
DataModelConditionList = null!;
ApplyParentList();
@@ -42,7 +42,7 @@ namespace Artemis.Core
///
/// Gets or sets the predicate type
///
- public ListRightSideType PredicateType { get; set; }
+ public ProfileRightSideType PredicateType { get; set; }
///
/// Gets the operator
@@ -66,7 +66,7 @@ namespace Artemis.Core
///
/// Gets the right static value, only used it is
- ///
+ ///
///
public object? RightStaticValue { get; private set; }
@@ -92,11 +92,10 @@ namespace Artemis.Core
}
///
- /// Updates the right side of the predicate using a path to a value inside the list item, makes the predicate dynamic
- /// and re-compiles the expression
+ /// Updates the right side of the predicate using a path and makes the predicate dynamic
///
- /// The path pointing to the right side value inside the list
- public void UpdateRightSideDynamicList(DataModelPath? path)
+ /// The path pointing to the right side value
+ public void UpdateRightSideDynamic(DataModelPath? path)
{
if (path != null && !path.IsValid)
throw new ArtemisCoreException("Cannot update right side of predicate to an invalid path");
@@ -104,20 +103,7 @@ namespace Artemis.Core
RightPath?.Dispose();
RightPath = path != null ? new DataModelPath(path) : null;
- PredicateType = ListRightSideType.DynamicList;
- }
-
- ///
- /// Updates the right side of the predicate using path to a value in a data model, makes the predicate dynamic and
- /// re-compiles the expression
- ///
- /// The path pointing to the right side value inside the list
- public void UpdateRightSideDynamic(DataModelPath? path)
- {
- RightPath?.Dispose();
- RightPath = path;
-
- PredicateType = ListRightSideType.Dynamic;
+ PredicateType = ProfileRightSideType.Dynamic;
}
///
@@ -126,7 +112,7 @@ namespace Artemis.Core
/// The right side value to use
public void UpdateRightSideStatic(object? staticValue)
{
- PredicateType = ListRightSideType.Static;
+ PredicateType = ProfileRightSideType.Static;
RightPath?.Dispose();
RightPath = null;
@@ -214,7 +200,7 @@ namespace Artemis.Core
return false;
// Compare with a static value
- if (PredicateType == ListRightSideType.Static)
+ if (PredicateType == ProfileRightSideType.Static)
{
object? leftSideValue = GetListPathValue(LeftPath, target);
if (leftSideValue != null && leftSideValue.GetType().IsValueType && RightStaticValue == null)
@@ -227,10 +213,13 @@ namespace Artemis.Core
return false;
// Compare with dynamic values
- if (PredicateType == ListRightSideType.Dynamic)
+ if (PredicateType == ProfileRightSideType.Dynamic)
+ {
+ // If the path targets a property inside the list, evaluate on the list path value instead of the right path value
+ if (RightPath.Target is ListPredicateWrapperDataModel)
+ return Operator.Evaluate(GetListPathValue(LeftPath, target), GetListPathValue(RightPath, target));
return Operator.Evaluate(GetListPathValue(LeftPath, target), RightPath.GetValue());
- if (PredicateType == ListRightSideType.DynamicList)
- return Operator.Evaluate(GetListPathValue(LeftPath, target), GetListPathValue(RightPath, target));
+ }
return false;
}
@@ -317,17 +306,22 @@ namespace Artemis.Core
}
// Right side dynamic
- if (PredicateType == ListRightSideType.Dynamic && Entity.RightPath != null)
- RightPath = new DataModelPath(null, Entity.RightPath);
- // Right side dynamic inside the list
- else if (PredicateType == ListRightSideType.DynamicList && Entity.RightPath != null)
+ if (PredicateType == ProfileRightSideType.Dynamic && Entity.RightPath != null)
{
- RightPath = DataModelConditionList.ListType != null
- ? new DataModelPath(ListPredicateWrapperDataModel.Create(DataModelConditionList.ListType), Entity.RightPath)
- : null;
+ // Right side dynamic inside the list
+ // TODO: Come up with a general wrapper solution because this will clash with events
+ if (Entity.RightPath.DataModelGuid == Constants.CorePluginInfo.Guid)
+ {
+ RightPath = DataModelConditionList.ListType != null
+ ? new DataModelPath(ListPredicateWrapperDataModel.Create(DataModelConditionList.ListType), Entity.RightPath)
+ : null;
+ }
+ // Right side dynamic
+ else
+ RightPath = new DataModelPath(null, Entity.RightPath);
}
// Right side static
- else if (PredicateType == ListRightSideType.Static && Entity.RightStaticValue != null)
+ else if (PredicateType == ProfileRightSideType.Static && Entity.RightStaticValue != null)
try
{
if (LeftPath != null && LeftPath.IsValid)
@@ -374,7 +368,7 @@ namespace Artemis.Core
private void ValidateRightSide()
{
Type? leftType = LeftPath?.GetPropertyType();
- if (PredicateType == ListRightSideType.Dynamic)
+ if (PredicateType == ProfileRightSideType.Dynamic)
{
if (RightPath == null || !RightPath.IsValid)
return;
@@ -383,15 +377,6 @@ namespace Artemis.Core
if (leftType != null && !leftType.IsCastableFrom(rightSideType))
UpdateRightSideDynamic(null);
}
- else if (PredicateType == ListRightSideType.DynamicList)
- {
- if (RightPath == null || !RightPath.IsValid)
- return;
-
- Type rightSideType = RightPath.GetPropertyType()!;
- if (leftType != null && !leftType.IsCastableFrom(rightSideType))
- UpdateRightSideDynamicList(null);
- }
else
{
if (RightStaticValue != null && (leftType == null || leftType.IsCastableFrom(RightStaticValue.GetType())))
@@ -455,25 +440,4 @@ namespace Artemis.Core
#endregion
}
-
- ///
- /// An enum defining the right side type of a profile entity
- ///
- public enum ListRightSideType
- {
- ///
- /// A static right side value
- ///
- Static,
-
- ///
- /// A dynamic right side value based on a path in a data model
- ///
- Dynamic,
-
- ///
- /// A dynamic right side value based on a path in the list
- ///
- DynamicList
- }
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Profile/DataBindings/Modes/ConditionalDataBinding.cs b/src/Artemis.Core/Models/Profile/DataBindings/Modes/ConditionalDataBinding.cs
index d4b4e046b..7b4e26a5b 100644
--- a/src/Artemis.Core/Models/Profile/DataBindings/Modes/ConditionalDataBinding.cs
+++ b/src/Artemis.Core/Models/Profile/DataBindings/Modes/ConditionalDataBinding.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using Artemis.Storage.Entities.Profile.DataBindings;
@@ -25,7 +26,7 @@ namespace Artemis.Core
///
/// Gets a list of conditions applied to this data binding
///
- public IReadOnlyList> Conditions => _conditions.AsReadOnly();
+ public ReadOnlyCollection> Conditions => _conditions.AsReadOnly();
///
public DataBinding DataBinding { get; }
diff --git a/src/Artemis.Core/Models/Profile/DataBindings/Modes/DirectDataBinding.cs b/src/Artemis.Core/Models/Profile/DataBindings/Modes/DirectDataBinding.cs
index f22ee61d5..9907f1175 100644
--- a/src/Artemis.Core/Models/Profile/DataBindings/Modes/DirectDataBinding.cs
+++ b/src/Artemis.Core/Models/Profile/DataBindings/Modes/DirectDataBinding.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using Artemis.Storage.Entities.Profile.DataBindings;
namespace Artemis.Core
@@ -28,7 +29,7 @@ namespace Artemis.Core
///
/// Gets a list of modifiers applied to this data binding
///
- public IReadOnlyList> Modifiers => _modifiers.AsReadOnly();
+ public ReadOnlyCollection> Modifiers => _modifiers.AsReadOnly();
internal DirectDataBindingEntity Entity { get; }
diff --git a/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs b/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs
index 9338d25ac..910ca1324 100644
--- a/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs
+++ b/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
using Artemis.Storage.Entities.Profile;
@@ -215,7 +216,7 @@ namespace Artemis.Core
///
/// Gets a read-only list of all the keyframes on this layer property
///
- public IReadOnlyList> Keyframes => _keyframes.AsReadOnly();
+ public ReadOnlyCollection> Keyframes => _keyframes.AsReadOnly();
///
/// Gets the current keyframe in the timeline according to the current progress
diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelDynamicView.xaml b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelDynamicView.xaml
index d2b351696..829f89485 100644
--- a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelDynamicView.xaml
+++ b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelDynamicView.xaml
@@ -6,6 +6,7 @@
xmlns:shared="clr-namespace:Artemis.UI.Shared"
xmlns:input="clr-namespace:Artemis.UI.Shared.Input"
xmlns:s="https://github.com/canton7/Stylet"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance input:DataModelDynamicViewModel}">
@@ -24,45 +25,71 @@
+
-
+
+
+
\ No newline at end of file
diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelDynamicViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelDynamicViewModel.cs
index 79f00613b..8e8b9dadc 100644
--- a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelDynamicViewModel.cs
+++ b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelDynamicViewModel.cs
@@ -25,6 +25,7 @@ namespace Artemis.UI.Shared.Input
private bool _isDataModelViewModelOpen;
private bool _isEnabled = true;
private string _placeholder = "Select a property";
+ private bool _displaySwitchButton;
internal DataModelDynamicViewModel(Module module, ISettingsService settingsService, IDataModelUIService dataModelUIService)
{
@@ -56,6 +57,12 @@ namespace Artemis.UI.Shared.Input
set => SetAndNotify(ref _isEnabled, value);
}
+ public bool DisplaySwitchButton
+ {
+ get => _displaySwitchButton;
+ set => SetAndNotify(ref _displaySwitchButton, value);
+ }
+
public Type[] FilterTypes
{
get => _filterTypes;
@@ -125,6 +132,13 @@ namespace Artemis.UI.Shared.Input
DataModelPath = dataModelPath != null ? new DataModelPath(dataModelPath) : null;
}
+ public void SwitchToStatic()
+ {
+ ChangeDataModelPath(null);
+ OnPropertySelected(new DataModelInputDynamicEventArgs(null));
+ OnSwitchToStaticRequested();
+ }
+
private void Initialize()
{
// Get the data models
@@ -167,12 +181,18 @@ namespace Artemis.UI.Shared.Input
#region Events
public event EventHandler PropertySelected;
+ public event EventHandler SwitchToStaticRequested;
protected virtual void OnPropertySelected(DataModelInputDynamicEventArgs e)
{
PropertySelected?.Invoke(this, e);
}
+ protected virtual void OnSwitchToStaticRequested()
+ {
+ SwitchToStaticRequested?.Invoke(this, EventArgs.Empty);
+ }
+
#endregion
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticView.xaml b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticView.xaml
index 6bc1c6987..1e78b80e0 100644
--- a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticView.xaml
+++ b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticView.xaml
@@ -22,24 +22,39 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
_buttonBrush;
set => SetAndNotify(ref _buttonBrush, value);
}
-
+
public DataModelDisplayViewModel DisplayViewModel
{
get => _displayViewModel;
@@ -92,19 +92,6 @@ namespace Artemis.UI.Shared.Input
private set => SetAndNotify(ref _isEnabled, value);
}
- #region IDisposable
-
- public void Dispose()
- {
- if (_rootView != null)
- {
- _rootView.MouseUp -= RootViewOnMouseUp;
- _rootView.KeyUp -= RootViewOnKeyUp;
- }
- }
-
- #endregion
-
public void ActivateInputViewModel()
{
InputViewModel = _dataModelUIService.GetDataModelInputViewModel(
@@ -127,16 +114,21 @@ namespace Artemis.UI.Shared.Input
ApplyFreeInput(null, true);
return;
}
-
- // If the type changed, reset to the default type
- if (Value == null || !target.IsCastableFrom(Value.GetType()))
- {
- // Force the VM to close if it was open and apply the new value
- ApplyFreeInput(target.GetDefault(), true);
- }
+ // If the type changed, reset to the default type
+ if (Value == null || !TargetType.IsCastableFrom(Value.GetType()))
+ // Force the VM to close if it was open and apply the new value
+ ApplyFreeInput(TargetType.GetDefault(), true);
}
-
+
+ public void SwitchToDynamic()
+ {
+ InputViewModel?.Cancel();
+ ApplyFreeInput(TargetType.GetDefault(), true);
+
+ OnSwitchToDynamicRequested();
+ }
+
private void ApplyFreeInput(object value, bool submitted)
{
if (submitted)
@@ -146,6 +138,19 @@ namespace Artemis.UI.Shared.Input
Value = value;
}
+ #region IDisposable
+
+ public void Dispose()
+ {
+ if (_rootView != null)
+ {
+ _rootView.MouseUp -= RootViewOnMouseUp;
+ _rootView.KeyUp -= RootViewOnKeyUp;
+ }
+ }
+
+ #endregion
+
#region Event handlers
private void RootViewOnKeyUp(object sender, KeyEventArgs e)
@@ -173,12 +178,18 @@ namespace Artemis.UI.Shared.Input
#region Events
public event EventHandler ValueUpdated;
+ public event EventHandler SwitchToDynamicRequested;
protected virtual void OnValueUpdated(DataModelInputStaticEventArgs e)
{
ValueUpdated?.Invoke(this, e);
}
+ protected virtual void OnSwitchToDynamicRequested()
+ {
+ SwitchToDynamicRequested?.Invoke(this, EventArgs.Empty);
+ }
+
#endregion
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI.Shared/Services/Interfaces/IProfileEditorService.cs b/src/Artemis.UI.Shared/Services/Interfaces/IProfileEditorService.cs
index 85cf152e0..8cb46338d 100644
--- a/src/Artemis.UI.Shared/Services/Interfaces/IProfileEditorService.cs
+++ b/src/Artemis.UI.Shared/Services/Interfaces/IProfileEditorService.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using Artemis.Core;
using Artemis.Core.Modules;
using Ninject;
@@ -13,7 +14,7 @@ namespace Artemis.UI.Shared.Services
ILayerProperty SelectedDataBinding { get; }
TimeSpan CurrentTime { get; set; }
int PixelsPerSecond { get; set; }
- IReadOnlyList RegisteredPropertyEditors { get; }
+ ReadOnlyCollection RegisteredPropertyEditors { get; }
IKernel Kernel { get; }
void ChangeSelectedProfile(Profile profile);
void UpdateSelectedProfile();
diff --git a/src/Artemis.UI.Shared/Services/ProfileEditorService.cs b/src/Artemis.UI.Shared/Services/ProfileEditorService.cs
index a637b7049..f1dedc4c3 100644
--- a/src/Artemis.UI.Shared/Services/ProfileEditorService.cs
+++ b/src/Artemis.UI.Shared/Services/ProfileEditorService.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using Artemis.Core;
using Artemis.Core.Modules;
@@ -32,7 +33,7 @@ namespace Artemis.UI.Shared.Services
}
public IKernel Kernel { get; }
- public IReadOnlyList RegisteredPropertyEditors => _registeredPropertyEditors.AsReadOnly();
+ public ReadOnlyCollection RegisteredPropertyEditors => _registeredPropertyEditors.AsReadOnly();
public Profile SelectedProfile { get; private set; }
public RenderProfileElement SelectedProfileElement { get; private set; }
public ILayerProperty SelectedDataBinding { get; private set; }
diff --git a/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionGroupView.xaml b/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionGroupView.xaml
index 56350154b..51db5e501 100644
--- a/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionGroupView.xaml
+++ b/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionGroupView.xaml
@@ -98,42 +98,9 @@
-
-
-
-