From 13df88ca409a88eba66a605e0c424e272f2d9fcc Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Fri, 30 Oct 2020 16:45:02 +0100 Subject: [PATCH] Display conditions - Fixed event argument conditions Display conditions - Fixed event inner-condition selection --- .../Profile/Conditions/DataModelConditionEvent.cs | 3 ++- .../Models/Profile/DataModel/DataModelEvent.cs | 8 ++++++++ .../Models/Profile/DataModel/IDataModelEvent.cs | 5 +++++ .../Input/DataModelDynamicViewModel.cs | 15 ++++++++++++--- .../Shared/DataModelVisualizationViewModel.cs | 9 +++------ 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionEvent.cs b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionEvent.cs index 009f1504f..c629ef276 100644 --- a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionEvent.cs +++ b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionEvent.cs @@ -62,7 +62,8 @@ namespace Artemis.Core // If there is a child (root group), it must evaluate to true whenever the event triggered if (Children.Any()) - return Children[0].Evaluate(); + return Children[0].EvaluateObject(_event.LastEventArgumentsUntyped); + // If there are no children, we always evaluate to true whenever the event triggered return true; } diff --git a/src/Artemis.Core/Models/Profile/DataModel/DataModelEvent.cs b/src/Artemis.Core/Models/Profile/DataModel/DataModelEvent.cs index ac3d39dfe..0b94d541b 100644 --- a/src/Artemis.Core/Models/Profile/DataModel/DataModelEvent.cs +++ b/src/Artemis.Core/Models/Profile/DataModel/DataModelEvent.cs @@ -44,6 +44,10 @@ namespace Artemis.Core [DataModelIgnore] public Type ArgumentsType => typeof(T); + /// + [DataModelIgnore] + public DataModelEventArgs? LastEventArgumentsUntyped => LastEventArguments; + /// public event EventHandler? EventTriggered; } @@ -87,6 +91,10 @@ namespace Artemis.Core [DataModelIgnore] public Type ArgumentsType => typeof(DataModelEventArgs); + /// + [DataModelIgnore] + public DataModelEventArgs? LastEventArgumentsUntyped => LastEventArguments; + /// public event EventHandler? EventTriggered; } diff --git a/src/Artemis.Core/Models/Profile/DataModel/IDataModelEvent.cs b/src/Artemis.Core/Models/Profile/DataModel/IDataModelEvent.cs index e0e26b059..d1643d159 100644 --- a/src/Artemis.Core/Models/Profile/DataModel/IDataModelEvent.cs +++ b/src/Artemis.Core/Models/Profile/DataModel/IDataModelEvent.cs @@ -19,6 +19,11 @@ namespace Artemis.Core /// Type ArgumentsType { get; } + /// + /// Gets the event arguments of the last time the event was triggered by its base type + /// + public DataModelEventArgs? LastEventArgumentsUntyped { get; } + /// /// Fires when the event is triggered /// diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelDynamicViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelDynamicViewModel.cs index a4502e62f..3e656da26 100644 --- a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelDynamicViewModel.cs +++ b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelDynamicViewModel.cs @@ -97,7 +97,11 @@ namespace Artemis.UI.Shared.Input public bool IsDataModelViewModelOpen { get => _isDataModelViewModelOpen; - set => SetAndNotify(ref _isDataModelViewModelOpen, value); + set + { + if (!SetAndNotify(ref _isDataModelViewModelOpen, value)) return; + if (value) UpdateDataModelVisualization(); + } } public DataModelPath DataModelPath @@ -195,9 +199,14 @@ namespace Artemis.UI.Shared.Input private void OnUpdateTimerOnElapsed(object sender, ElapsedEventArgs e) { - if (!IsDataModelViewModelOpen) - return; + // if (!IsDataModelViewModelOpen) + // return; + // + // UpdateDataModelVisualization(); + } + private void UpdateDataModelVisualization() + { DataModelViewModel.Update(_dataModelUIService); foreach (DataModelPropertiesViewModel extraDataModelViewModel in ExtraDataModelViewModels) extraDataModelViewModel.Update(_dataModelUIService); diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelVisualizationViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelVisualizationViewModel.cs index facaac227..ca468a6aa 100644 --- a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelVisualizationViewModel.cs +++ b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelVisualizationViewModel.cs @@ -184,14 +184,11 @@ namespace Artemis.UI.Shared internal void PopulateProperties(IDataModelUIService dataModelUIService) { - // if (IsRootViewModel) - // return; - - if (Parent == null && DataModel == null) + if (IsRootViewModel && DataModel == null) return; - Type modelType = Parent == null || Parent.IsRootViewModel ? DataModel.GetType() : DataModelPath.GetPropertyType(); - + Type modelType = IsRootViewModel ? DataModel.GetType() : DataModelPath?.GetPropertyType() ?? DataModel.GetType(); + // Add missing static children foreach (PropertyInfo propertyInfo in modelType.GetProperties(BindingFlags.Public | BindingFlags.Instance).OrderBy(t => t.MetadataToken)) {