mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Data model conditions - Moved events into a separate 'mode'
This commit is contained in:
parent
e1eb03667e
commit
997ab005d8
31
src/Artemis.Core/JsonConverters/ForgivingIntConverter.cs
Normal file
31
src/Artemis.Core/JsonConverters/ForgivingIntConverter.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace Artemis.Core.JsonConverters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An int converter that, if required, will round float values
|
||||||
|
/// </summary>
|
||||||
|
internal class ForgivingIntConverter : JsonConverter<int>
|
||||||
|
{
|
||||||
|
public override bool CanWrite => false;
|
||||||
|
|
||||||
|
public override void WriteJson(JsonWriter writer, int value, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int ReadJson(JsonReader reader, Type objectType, int existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
JValue jsonValue = serializer.Deserialize<JValue>(reader);
|
||||||
|
|
||||||
|
if (jsonValue.Type == JTokenType.Float)
|
||||||
|
return (int) Math.Round(jsonValue.Value<double>());
|
||||||
|
if (jsonValue.Type == JTokenType.Integer)
|
||||||
|
return jsonValue.Value<int>();
|
||||||
|
|
||||||
|
throw new FormatException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -75,7 +75,7 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
return condition;
|
return condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes a condition from the conditional data binding's <see cref="Conditions" /> collection and disposes it
|
/// Removes a condition from the conditional data binding's <see cref="Conditions" /> collection and disposes it
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Artemis.Core.DataModelExpansions;
|
using Artemis.Core.DataModelExpansions;
|
||||||
|
|
||||||
namespace Artemis.Core
|
namespace Artemis.Core
|
||||||
@ -8,6 +10,45 @@ namespace Artemis.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class DataModelEvent<T> : IDataModelEvent where T : DataModelEventArgs
|
public class DataModelEvent<T> : IDataModelEvent where T : DataModelEventArgs
|
||||||
{
|
{
|
||||||
|
private bool _trackHistory;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the <see cref="DataModelEvent{T}" /> class with history tracking disabled
|
||||||
|
/// </summary>
|
||||||
|
public DataModelEvent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the <see cref="DataModelEvent{T}" />
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="trackHistory">A boolean indicating whether the last 20 events should be tracked</param>
|
||||||
|
public DataModelEvent(bool trackHistory)
|
||||||
|
{
|
||||||
|
_trackHistory = trackHistory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
[DataModelProperty(Name = "Last event trigger", Description = "The time at which the event last triggered")]
|
||||||
|
public DateTime LastTrigger { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the event arguments of the last time the event was triggered
|
||||||
|
/// </summary>
|
||||||
|
[DataModelProperty(Description = "The arguments of the last time this event triggered")]
|
||||||
|
public T? LastEventArguments { get; private set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
[DataModelProperty(Description = "The total amount of times this event has triggered since the module was activated")]
|
||||||
|
public int TriggerCount { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a queue of the last 20 event arguments
|
||||||
|
/// <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);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Trigger the event with the given <paramref name="eventArgs" />
|
/// Trigger the event with the given <paramref name="eventArgs" />
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -21,6 +62,16 @@ namespace Artemis.Core
|
|||||||
LastTrigger = DateTime.Now;
|
LastTrigger = DateTime.Now;
|
||||||
TriggerCount++;
|
TriggerCount++;
|
||||||
|
|
||||||
|
if (TrackHistory)
|
||||||
|
{
|
||||||
|
lock (EventArgumentsHistory)
|
||||||
|
{
|
||||||
|
if (EventArgumentsHistory.Count == 20)
|
||||||
|
EventArgumentsHistory.Dequeue();
|
||||||
|
EventArgumentsHistory.Enqueue(eventArgs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
OnEventTriggered();
|
OnEventTriggered();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,26 +81,38 @@ namespace Artemis.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public DateTime LastTrigger { get; private set; }
|
[DataModelIgnore]
|
||||||
|
public Type ArgumentsType => typeof(T);
|
||||||
/// <inheritdoc />
|
|
||||||
public int TriggerCount { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the event arguments of the last time the event was triggered
|
|
||||||
/// </summary>
|
|
||||||
public T? LastEventArguments { get; private set; }
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[DataModelIgnore]
|
[DataModelIgnore]
|
||||||
public Type ArgumentsType => typeof(T);
|
public bool TrackHistory
|
||||||
|
{
|
||||||
|
get => _trackHistory;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
EventArgumentsHistory.Clear();
|
||||||
|
_trackHistory = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[DataModelIgnore]
|
[DataModelIgnore]
|
||||||
public DataModelEventArgs? LastEventArgumentsUntyped => LastEventArguments;
|
public DataModelEventArgs? LastEventArgumentsUntyped => LastEventArguments;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
[DataModelIgnore]
|
||||||
|
public List<DataModelEventArgs> EventArgumentsHistoryUntyped => EventArgumentsHistory.Cast<DataModelEventArgs>().ToList();
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public event EventHandler? EventTriggered;
|
public event EventHandler? EventTriggered;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
TriggerCount = 0;
|
||||||
|
EventArgumentsHistory.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -57,6 +120,45 @@ namespace Artemis.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class DataModelEvent : IDataModelEvent
|
public class DataModelEvent : IDataModelEvent
|
||||||
{
|
{
|
||||||
|
private bool _trackHistory;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the <see cref="DataModelEvent" /> class with history tracking disabled
|
||||||
|
/// </summary>
|
||||||
|
public DataModelEvent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the <see cref="DataModelEvent" />
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="trackHistory">A boolean indicating whether the last 20 events should be tracked</param>
|
||||||
|
public DataModelEvent(bool trackHistory)
|
||||||
|
{
|
||||||
|
_trackHistory = trackHistory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
[DataModelProperty(Name = "Last event trigger", Description = "The time at which the event last triggered")]
|
||||||
|
public DateTime LastTrigger { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the event arguments of the last time the event was triggered
|
||||||
|
/// </summary>
|
||||||
|
[DataModelProperty(Description = "The arguments of the last time this event triggered")]
|
||||||
|
public DataModelEventArgs? LastEventArguments { get; private set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
[DataModelProperty(Description = "The total amount of times this event has triggered since the module was activated")]
|
||||||
|
public int TriggerCount { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a queue of the last 20 event arguments
|
||||||
|
/// <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);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Trigger the event
|
/// Trigger the event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -68,6 +170,16 @@ namespace Artemis.Core
|
|||||||
LastTrigger = DateTime.Now;
|
LastTrigger = DateTime.Now;
|
||||||
TriggerCount++;
|
TriggerCount++;
|
||||||
|
|
||||||
|
if (TrackHistory)
|
||||||
|
{
|
||||||
|
lock (EventArgumentsHistory)
|
||||||
|
{
|
||||||
|
if (EventArgumentsHistory.Count == 20)
|
||||||
|
EventArgumentsHistory.Dequeue();
|
||||||
|
EventArgumentsHistory.Enqueue(eventArgs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
OnEventTriggered();
|
OnEventTriggered();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,27 +187,39 @@ namespace Artemis.Core
|
|||||||
{
|
{
|
||||||
EventTriggered?.Invoke(this, EventArgs.Empty);
|
EventTriggered?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public DateTime LastTrigger { get; private set; }
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public int TriggerCount { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the event arguments of the last time the event was triggered
|
|
||||||
/// </summary>
|
|
||||||
public DataModelEventArgs? LastEventArguments { get; private set; }
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[DataModelIgnore]
|
[DataModelIgnore]
|
||||||
public Type ArgumentsType => typeof(DataModelEventArgs);
|
public Type ArgumentsType => typeof(DataModelEventArgs);
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
[DataModelIgnore]
|
||||||
|
public bool TrackHistory
|
||||||
|
{
|
||||||
|
get => _trackHistory;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
EventArgumentsHistory.Clear();
|
||||||
|
_trackHistory = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[DataModelIgnore]
|
[DataModelIgnore]
|
||||||
public DataModelEventArgs? LastEventArgumentsUntyped => LastEventArguments;
|
public DataModelEventArgs? LastEventArgumentsUntyped => LastEventArguments;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
[DataModelIgnore]
|
||||||
|
public List<DataModelEventArgs> EventArgumentsHistoryUntyped => EventArgumentsHistory.ToList();
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public event EventHandler? EventTriggered;
|
public event EventHandler? EventTriggered;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
TriggerCount = 0;
|
||||||
|
EventArgumentsHistory.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
@ -281,7 +280,7 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
Entity.Path = Path;
|
Entity.Path = Path;
|
||||||
Entity.DataModelGuid = DataModelGuid;
|
Entity.DataModelGuid = DataModelGuid;
|
||||||
|
|
||||||
Entity.WrapperType = Target switch
|
Entity.WrapperType = Target switch
|
||||||
{
|
{
|
||||||
ListPredicateWrapperDataModel _ => PathWrapperType.List,
|
ListPredicateWrapperDataModel _ => PathWrapperType.List,
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Artemis.Core
|
namespace Artemis.Core
|
||||||
{
|
{
|
||||||
@ -19,14 +20,31 @@ namespace Artemis.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Type ArgumentsType { get; }
|
Type ArgumentsType { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a boolean indicating whether the last 20 events should be tracked
|
||||||
|
/// <para>Note: setting this to <see langword="false" /> will clear the current history</para>
|
||||||
|
/// </summary>
|
||||||
|
bool TrackHistory { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the event arguments of the last time the event was triggered by its base type
|
/// Gets the event arguments of the last time the event was triggered by its base type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DataModelEventArgs? LastEventArgumentsUntyped { get; }
|
public DataModelEventArgs? LastEventArgumentsUntyped { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a list of the last 20 event arguments by their base type.
|
||||||
|
/// <para>Always empty if <see cref="TrackHistory" /> is <see langword="false" /></para>
|
||||||
|
/// </summary>
|
||||||
|
public List<DataModelEventArgs> EventArgumentsHistoryUntyped { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fires when the event is triggered
|
/// Fires when the event is triggered
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event EventHandler EventTriggered;
|
event EventHandler EventTriggered;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the trigger count and history of this data model event
|
||||||
|
/// </summary>
|
||||||
|
void Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ namespace Artemis.Core.Services
|
|||||||
{
|
{
|
||||||
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
||||||
{
|
{
|
||||||
Converters = new List<JsonConverter> {new SKColorConverter()}
|
Converters = new List<JsonConverter> {new SKColorConverter(), new ForgivingIntConverter()}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -131,6 +131,8 @@ namespace Artemis.UI.Shared.Input
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool LoadEventChildren { get; set; } = true;
|
||||||
|
|
||||||
public void ChangeDataModel(DataModelPropertiesViewModel dataModel)
|
public void ChangeDataModel(DataModelPropertiesViewModel dataModel)
|
||||||
{
|
{
|
||||||
if (DataModelViewModel != null)
|
if (DataModelViewModel != null)
|
||||||
@ -199,17 +201,17 @@ namespace Artemis.UI.Shared.Input
|
|||||||
|
|
||||||
private void OnUpdateTimerOnElapsed(object sender, ElapsedEventArgs e)
|
private void OnUpdateTimerOnElapsed(object sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
// if (!IsDataModelViewModelOpen)
|
if (!IsDataModelViewModelOpen)
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// UpdateDataModelVisualization();
|
UpdateDataModelVisualization();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateDataModelVisualization()
|
private void UpdateDataModelVisualization()
|
||||||
{
|
{
|
||||||
DataModelViewModel.Update(_dataModelUIService);
|
DataModelViewModel.Update(_dataModelUIService, new DataModelUpdateConfiguration(LoadEventChildren));
|
||||||
foreach (DataModelPropertiesViewModel extraDataModelViewModel in ExtraDataModelViewModels)
|
foreach (DataModelPropertiesViewModel extraDataModelViewModel in ExtraDataModelViewModels)
|
||||||
extraDataModelViewModel.Update(_dataModelUIService);
|
extraDataModelViewModel.Update(_dataModelUIService, new DataModelUpdateConfiguration(LoadEventChildren));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
using Artemis.Core;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using Artemis.Core;
|
||||||
using Artemis.Core.DataModelExpansions;
|
using Artemis.Core.DataModelExpansions;
|
||||||
using Artemis.UI.Shared.Services;
|
using Artemis.UI.Shared.Services;
|
||||||
|
|
||||||
@ -6,12 +8,36 @@ namespace Artemis.UI.Shared
|
|||||||
{
|
{
|
||||||
public class DataModelEventViewModel : DataModelVisualizationViewModel
|
public class DataModelEventViewModel : DataModelVisualizationViewModel
|
||||||
{
|
{
|
||||||
|
private Type _displayValueType;
|
||||||
|
|
||||||
internal DataModelEventViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, DataModelPath dataModelPath) : base(dataModel, parent, dataModelPath)
|
internal DataModelEventViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, DataModelPath dataModelPath) : base(dataModel, parent, dataModelPath)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(IDataModelUIService dataModelUIService)
|
public Type DisplayValueType
|
||||||
{
|
{
|
||||||
|
get => _displayValueType;
|
||||||
|
set => SetAndNotify(ref _displayValueType, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
|
||||||
|
{
|
||||||
|
DisplayValueType = DataModelPath?.GetPropertyType();
|
||||||
|
|
||||||
|
if (configuration != null)
|
||||||
|
{
|
||||||
|
if (configuration.CreateEventChildren)
|
||||||
|
PopulateProperties(dataModelUIService, configuration);
|
||||||
|
else if (Children.Any())
|
||||||
|
Children.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only update children if the parent is expanded
|
||||||
|
if (Parent != null && !Parent.IsRootViewModel && !Parent.IsVisualizationExpanded)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (DataModelVisualizationViewModel dataModelVisualizationViewModel in Children)
|
||||||
|
dataModelVisualizationViewModel.Update(dataModelUIService, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override object GetCurrentValue()
|
public override object GetCurrentValue()
|
||||||
|
|||||||
@ -39,17 +39,17 @@ namespace Artemis.UI.Shared
|
|||||||
|
|
||||||
public override string DisplayPath => null;
|
public override string DisplayPath => null;
|
||||||
|
|
||||||
public override void Update(IDataModelUIService dataModelUIService)
|
public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
|
||||||
{
|
{
|
||||||
((ListPredicateWrapperDataModel) DataModel).UntypedValue = DisplayValue;
|
((ListPredicateWrapperDataModel) DataModel).UntypedValue = DisplayValue;
|
||||||
|
|
||||||
PopulateProperties(dataModelUIService);
|
PopulateProperties(dataModelUIService, configuration);
|
||||||
if (DisplayViewModel == null)
|
if (DisplayViewModel == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (IsVisualizationExpanded && !DisplayViewModel.IsVisualizationExpanded)
|
if (IsVisualizationExpanded && !DisplayViewModel.IsVisualizationExpanded)
|
||||||
DisplayViewModel.IsVisualizationExpanded = IsVisualizationExpanded;
|
DisplayViewModel.IsVisualizationExpanded = IsVisualizationExpanded;
|
||||||
DisplayViewModel.Update(dataModelUIService);
|
DisplayViewModel.Update(dataModelUIService, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override object GetCurrentValue()
|
public override object GetCurrentValue()
|
||||||
|
|||||||
@ -39,7 +39,7 @@ namespace Artemis.UI.Shared
|
|||||||
return DisplayValue;
|
return DisplayValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(IDataModelUIService dataModelUIService)
|
public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
|
||||||
{
|
{
|
||||||
// Display value gets updated by parent, don't do anything if it is null
|
// Display value gets updated by parent, don't do anything if it is null
|
||||||
if (DisplayValue == null)
|
if (DisplayValue == null)
|
||||||
|
|||||||
@ -45,7 +45,7 @@ namespace Artemis.UI.Shared
|
|||||||
|
|
||||||
public BindableCollection<DataModelVisualizationViewModel> ListChildren { get; set; }
|
public BindableCollection<DataModelVisualizationViewModel> ListChildren { get; set; }
|
||||||
|
|
||||||
public override void Update(IDataModelUIService dataModelUIService)
|
public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
|
||||||
{
|
{
|
||||||
if (Parent != null && !Parent.IsVisualizationExpanded)
|
if (Parent != null && !Parent.IsVisualizationExpanded)
|
||||||
return;
|
return;
|
||||||
@ -83,7 +83,7 @@ namespace Artemis.UI.Shared
|
|||||||
dataModelListPropertyViewModel.Index = index;
|
dataModelListPropertyViewModel.Index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
child.Update(dataModelUIService);
|
child.Update(dataModelUIService, configuration);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ namespace Artemis.UI.Shared
|
|||||||
set => SetAndNotify(ref _displayValue, value);
|
set => SetAndNotify(ref _displayValue, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(IDataModelUIService dataModelUIService)
|
public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
|
||||||
{
|
{
|
||||||
DisplayValueType = DataModelPath?.GetPropertyType();
|
DisplayValueType = DataModelPath?.GetPropertyType();
|
||||||
|
|
||||||
@ -38,14 +38,14 @@ namespace Artemis.UI.Shared
|
|||||||
DisplayValue = null;
|
DisplayValue = null;
|
||||||
|
|
||||||
// Always populate properties
|
// Always populate properties
|
||||||
PopulateProperties(dataModelUIService);
|
PopulateProperties(dataModelUIService, configuration);
|
||||||
|
|
||||||
// Only update children if the parent is expanded
|
// Only update children if the parent is expanded
|
||||||
if (Parent != null && !Parent.IsRootViewModel && !Parent.IsVisualizationExpanded)
|
if (Parent != null && !Parent.IsRootViewModel && !Parent.IsVisualizationExpanded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (DataModelVisualizationViewModel dataModelVisualizationViewModel in Children)
|
foreach (DataModelVisualizationViewModel dataModelVisualizationViewModel in Children)
|
||||||
dataModelVisualizationViewModel.Update(dataModelUIService);
|
dataModelVisualizationViewModel.Update(dataModelUIService, configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override object GetCurrentValue()
|
public override object GetCurrentValue()
|
||||||
|
|||||||
@ -33,7 +33,7 @@ namespace Artemis.UI.Shared
|
|||||||
set => SetAndNotify(ref _displayViewModel, value);
|
set => SetAndNotify(ref _displayViewModel, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(IDataModelUIService dataModelUIService)
|
public override void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
|
||||||
{
|
{
|
||||||
if (Parent != null && !Parent.IsVisualizationExpanded && !Parent.IsRootViewModel)
|
if (Parent != null && !Parent.IsVisualizationExpanded && !Parent.IsRootViewModel)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -87,8 +87,9 @@ namespace Artemis.UI.Shared
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the datamodel and if in an parent, any children
|
/// Updates the datamodel and if in an parent, any children
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dataModelUIService"></param>
|
/// <param name="dataModelUIService">The data model UI service used during update</param>
|
||||||
public abstract void Update(IDataModelUIService dataModelUIService);
|
/// <param name="configuration">The configuration to apply while updating</param>
|
||||||
|
public abstract void Update(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration);
|
||||||
|
|
||||||
public virtual object GetCurrentValue()
|
public virtual object GetCurrentValue()
|
||||||
{
|
{
|
||||||
@ -147,7 +148,7 @@ namespace Artemis.UI.Shared
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void PopulateProperties(IDataModelUIService dataModelUIService)
|
internal void PopulateProperties(IDataModelUIService dataModelUIService, DataModelUpdateConfiguration dataModelUpdateConfiguration)
|
||||||
{
|
{
|
||||||
if (IsRootViewModel && DataModel == null)
|
if (IsRootViewModel && DataModel == null)
|
||||||
return;
|
return;
|
||||||
@ -260,4 +261,14 @@ namespace Artemis.UI.Shared
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class DataModelUpdateConfiguration
|
||||||
|
{
|
||||||
|
public bool CreateEventChildren { get; }
|
||||||
|
|
||||||
|
public DataModelUpdateConfiguration(bool createEventChildren)
|
||||||
|
{
|
||||||
|
CreateEventChildren = createEventChildren;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -6,21 +6,21 @@ namespace Artemis.UI.Shared
|
|||||||
{
|
{
|
||||||
public static class DataModelWrapperExtensions
|
public static class DataModelWrapperExtensions
|
||||||
{
|
{
|
||||||
public static DataModelPropertiesViewModel CreateViewModel(this EventPredicateWrapperDataModel wrapper, IDataModelUIService dataModelUIService)
|
public static DataModelPropertiesViewModel CreateViewModel(this EventPredicateWrapperDataModel wrapper, IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
|
||||||
{
|
{
|
||||||
DataModelPropertiesViewModel viewModel = new DataModelPropertiesViewModel(wrapper, null, new DataModelPath(wrapper));
|
DataModelPropertiesViewModel viewModel = new DataModelPropertiesViewModel(wrapper, null, new DataModelPath(wrapper));
|
||||||
viewModel.Update(dataModelUIService);
|
viewModel.Update(dataModelUIService, configuration);
|
||||||
viewModel.UpdateRequested += (sender, args) => viewModel.Update(dataModelUIService);
|
viewModel.UpdateRequested += (sender, args) => viewModel.Update(dataModelUIService, configuration);
|
||||||
viewModel.Children.First().IsVisualizationExpanded = true;
|
viewModel.Children.First().IsVisualizationExpanded = true;
|
||||||
|
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataModelPropertiesViewModel CreateViewModel(this ListPredicateWrapperDataModel wrapper, IDataModelUIService dataModelUIService)
|
public static DataModelPropertiesViewModel CreateViewModel(this ListPredicateWrapperDataModel wrapper, IDataModelUIService dataModelUIService, DataModelUpdateConfiguration configuration)
|
||||||
{
|
{
|
||||||
DataModelPropertiesViewModel viewModel = new DataModelPropertiesViewModel(wrapper, null, new DataModelPath(wrapper));
|
DataModelPropertiesViewModel viewModel = new DataModelPropertiesViewModel(wrapper, null, new DataModelPath(wrapper));
|
||||||
viewModel.Update(dataModelUIService);
|
viewModel.Update(dataModelUIService, configuration);
|
||||||
viewModel.UpdateRequested += (sender, args) => viewModel.Update(dataModelUIService);
|
viewModel.UpdateRequested += (sender, args) => viewModel.Update(dataModelUIService, configuration);
|
||||||
viewModel.Children.First().IsVisualizationExpanded = true;
|
viewModel.Children.First().IsVisualizationExpanded = true;
|
||||||
|
|
||||||
return viewModel;
|
return viewModel;
|
||||||
|
|||||||
@ -37,8 +37,8 @@ namespace Artemis.UI.Shared.Services
|
|||||||
viewModel.Children.Add(new DataModelPropertiesViewModel(dataModelExpansion, viewModel, new DataModelPath(dataModelExpansion)));
|
viewModel.Children.Add(new DataModelPropertiesViewModel(dataModelExpansion, viewModel, new DataModelPath(dataModelExpansion)));
|
||||||
|
|
||||||
// Update to populate children
|
// Update to populate children
|
||||||
viewModel.Update(this);
|
viewModel.Update(this, null);
|
||||||
viewModel.UpdateRequested += (sender, args) => viewModel.Update(this);
|
viewModel.UpdateRequested += (sender, args) => viewModel.Update(this, null);
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +67,8 @@ namespace Artemis.UI.Shared.Services
|
|||||||
viewModel.Children.Add(new DataModelPropertiesViewModel(dataModel, viewModel, null));
|
viewModel.Children.Add(new DataModelPropertiesViewModel(dataModel, viewModel, null));
|
||||||
|
|
||||||
// Update to populate children
|
// Update to populate children
|
||||||
viewModel.Update(this);
|
viewModel.Update(this, null);
|
||||||
viewModel.UpdateRequested += (sender, args) => viewModel.Update(this);
|
viewModel.UpdateRequested += (sender, args) => viewModel.Update(this, null);
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ namespace Artemis.UI.Shared.Services
|
|||||||
else
|
else
|
||||||
result = _kernel.Get<DefaultDataModelDisplayViewModel>();
|
result = _kernel.Get<DefaultDataModelDisplayViewModel>();
|
||||||
|
|
||||||
if (result != null)
|
if (result != null)
|
||||||
result.PropertyDescription = description;
|
result.PropertyDescription = description;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@ -47,25 +47,11 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions.Abstract
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event
|
|
||||||
if (IsEvent(newType))
|
|
||||||
{
|
|
||||||
if (this is DataModelConditionEventViewModel)
|
|
||||||
return false;
|
|
||||||
groupViewModel.ConvertToConditionEvent(this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Predicate
|
// Predicate
|
||||||
if (this is DataModelConditionPredicateViewModel)
|
if (this is DataModelConditionPredicateViewModel)
|
||||||
return false;
|
return false;
|
||||||
groupViewModel.ConvertToPredicate(this);
|
groupViewModel.ConvertToPredicate(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool IsEvent(Type type)
|
|
||||||
{
|
|
||||||
return type == typeof(DataModelEvent) || type.IsGenericType && type.GetGenericTypeDefinition() == typeof(DataModelEvent<>);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
@ -32,19 +32,11 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
{
|
{
|
||||||
LeftSideSelectionViewModel = _dataModelUIService.GetDynamicSelectionViewModel(_profileEditorService.GetCurrentModule());
|
LeftSideSelectionViewModel = _dataModelUIService.GetDynamicSelectionViewModel(_profileEditorService.GetCurrentModule());
|
||||||
LeftSideSelectionViewModel.PropertySelected += LeftSideSelectionViewModelOnPropertySelected;
|
LeftSideSelectionViewModel.PropertySelected += LeftSideSelectionViewModelOnPropertySelected;
|
||||||
|
LeftSideSelectionViewModel.LoadEventChildren = false;
|
||||||
|
|
||||||
IReadOnlyCollection<DataModelVisualizationRegistration> editors = _dataModelUIService.RegisteredDataModelEditors;
|
IReadOnlyCollection<DataModelVisualizationRegistration> editors = _dataModelUIService.RegisteredDataModelEditors;
|
||||||
List<Type> supportedInputTypes = editors.Select(e => e.SupportedType).ToList();
|
List<Type> supportedInputTypes = new List<Type> {typeof(DataModelEvent), typeof(DataModelEvent<>)};
|
||||||
supportedInputTypes.AddRange(editors.Where(e => e.CompatibleConversionTypes != null).SelectMany(e => e.CompatibleConversionTypes));
|
|
||||||
supportedInputTypes.Add(typeof(IEnumerable<>));
|
|
||||||
|
|
||||||
// Events are only supported in the root group enforce that here
|
|
||||||
if (Parent is DataModelConditionGroupViewModel groupViewModel && groupViewModel.IsRootGroup)
|
|
||||||
{
|
|
||||||
supportedInputTypes.Add(typeof(DataModelEvent));
|
|
||||||
supportedInputTypes.Add(typeof(DataModelEvent<>));
|
|
||||||
}
|
|
||||||
|
|
||||||
LeftSideSelectionViewModel.FilterTypes = supportedInputTypes.ToArray();
|
LeftSideSelectionViewModel.FilterTypes = supportedInputTypes.ToArray();
|
||||||
LeftSideSelectionViewModel.ButtonBrush = new SolidColorBrush(Color.FromRgb(185, 164, 10));
|
LeftSideSelectionViewModel.ButtonBrush = new SolidColorBrush(Color.FromRgb(185, 164, 10));
|
||||||
LeftSideSelectionViewModel.Placeholder = "Select an event";
|
LeftSideSelectionViewModel.Placeholder = "Select an event";
|
||||||
@ -84,11 +76,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
|
|
||||||
public void ApplyEvent()
|
public void ApplyEvent()
|
||||||
{
|
{
|
||||||
Type newType = LeftSideSelectionViewModel.DataModelPath.GetPropertyType();
|
|
||||||
bool converted = ConvertIfRequired(newType);
|
|
||||||
if (converted)
|
|
||||||
return;
|
|
||||||
|
|
||||||
DataModelConditionEvent.UpdateEvent(LeftSideSelectionViewModel.DataModelPath);
|
DataModelConditionEvent.UpdateEvent(LeftSideSelectionViewModel.DataModelPath);
|
||||||
_profileEditorService.UpdateSelectedProfileElement();
|
_profileEditorService.UpdateSelectedProfileElement();
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
<ResourceDictionary Source="pack://application:,,,/Artemis.UI;component/ResourceDictionaries/DataModelConditions.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/Artemis.UI;component/ResourceDictionaries/DataModelConditions.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
<Converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
|
<Converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
|
||||||
|
<utilities:BindingProxy x:Key="DataContextProxy" Data="{Binding}" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
@ -109,12 +110,20 @@
|
|||||||
</Button.Style>
|
</Button.Style>
|
||||||
<Button.ContextMenu>
|
<Button.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="Add condition" ToolTip="A condition that compares with another value" Command="{s:Action AddCondition}">
|
<MenuItem Header="Add condition" ToolTip="A condition that evaluates the state of a property in the data model" Command="{s:Action AddCondition}">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<materialDesign:PackIcon Kind="Equal" />
|
<materialDesign:PackIcon Kind="Equal" />
|
||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem Header="Add group" ToolTip="A group can contain conditions and other groups" Command="{s:Action AddGroup}">
|
<MenuItem Header="Add event condition"
|
||||||
|
ToolTip="An event condition that responds to data model events"
|
||||||
|
Command="{s:Action AddEventCondition}"
|
||||||
|
Visibility="{Binding Data.CanAddEventCondition, Source={StaticResource DataContextProxy}, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="LightningBolt" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Add group" ToolTip="A group for conditions and other groups" Command="{s:Action AddGroup}">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<materialDesign:PackIcon Kind="CodeParentheses" />
|
<materialDesign:PackIcon Kind="CodeParentheses" />
|
||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
|
|||||||
@ -40,15 +40,21 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConditionGroupType GroupType { get; set; }
|
public ConditionGroupType GroupType { get; }
|
||||||
public DataModelConditionGroup DataModelConditionGroup => (DataModelConditionGroup) Model;
|
public DataModelConditionGroup DataModelConditionGroup => (DataModelConditionGroup) Model;
|
||||||
|
|
||||||
public bool IsRootGroup
|
public bool IsRootGroup
|
||||||
{
|
{
|
||||||
get => _isRootGroup;
|
get => _isRootGroup;
|
||||||
set => SetAndNotify(ref _isRootGroup, value);
|
set
|
||||||
|
{
|
||||||
|
if (!SetAndNotify(ref _isRootGroup, value)) return;
|
||||||
|
NotifyOfPropertyChange(nameof(CanAddEventCondition));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanAddEventCondition => IsRootGroup && GroupType == ConditionGroupType.General;
|
||||||
|
|
||||||
public bool IsEventGroup
|
public bool IsEventGroup
|
||||||
{
|
{
|
||||||
get => _isEventGroup;
|
get => _isEventGroup;
|
||||||
@ -94,6 +100,23 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
_profileEditorService.UpdateSelectedProfileElement();
|
_profileEditorService.UpdateSelectedProfileElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddEventCondition()
|
||||||
|
{
|
||||||
|
if (!CanAddEventCondition)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Find a good spot for the event, behind the last existing event
|
||||||
|
int index = 0;
|
||||||
|
DataModelConditionPart existing = DataModelConditionGroup.Children.LastOrDefault(c => c is DataModelConditionEvent);
|
||||||
|
if (existing != null)
|
||||||
|
index = DataModelConditionGroup.Children.IndexOf(existing) + 1;
|
||||||
|
|
||||||
|
DataModelConditionGroup.AddChild(new DataModelConditionEvent(DataModelConditionGroup), index);
|
||||||
|
|
||||||
|
Update();
|
||||||
|
_profileEditorService.UpdateSelectedProfileElement();
|
||||||
|
}
|
||||||
|
|
||||||
public void AddGroup()
|
public void AddGroup()
|
||||||
{
|
{
|
||||||
DataModelConditionGroup.AddChild(new DataModelConditionGroup(DataModelConditionGroup));
|
DataModelConditionGroup.AddChild(new DataModelConditionGroup(DataModelConditionGroup));
|
||||||
@ -171,24 +194,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConvertToConditionEvent(DataModelConditionViewModel predicateViewModel)
|
|
||||||
{
|
|
||||||
// Remove the old child
|
|
||||||
DataModelConditionGroup.RemoveChild(predicateViewModel.Model);
|
|
||||||
|
|
||||||
DataModelConditionPart rootGroup = DataModelConditionGroup;
|
|
||||||
while (rootGroup.Parent != null)
|
|
||||||
rootGroup = rootGroup.Parent;
|
|
||||||
|
|
||||||
// Insert an event at the start of the root group
|
|
||||||
DataModelConditionEvent conditionEvent = new DataModelConditionEvent(rootGroup);
|
|
||||||
conditionEvent.UpdateEvent(predicateViewModel.LeftSideSelectionViewModel.DataModelPath);
|
|
||||||
rootGroup.AddChild(conditionEvent, 0);
|
|
||||||
|
|
||||||
// Update to switch the VMs
|
|
||||||
Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ConvertToPredicate(DataModelConditionViewModel listViewModel)
|
public void ConvertToPredicate(DataModelConditionViewModel listViewModel)
|
||||||
{
|
{
|
||||||
// Store the old index and remove the old predicate
|
// Store the old index and remove the old predicate
|
||||||
|
|||||||
@ -73,13 +73,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
supportedInputTypes.AddRange(editors.Where(e => e.CompatibleConversionTypes != null).SelectMany(e => e.CompatibleConversionTypes));
|
supportedInputTypes.AddRange(editors.Where(e => e.CompatibleConversionTypes != null).SelectMany(e => e.CompatibleConversionTypes));
|
||||||
supportedInputTypes.Add(typeof(IEnumerable<>));
|
supportedInputTypes.Add(typeof(IEnumerable<>));
|
||||||
|
|
||||||
// Events are only supported in the root group enforce that here
|
|
||||||
if (Parent is DataModelConditionGroupViewModel groupViewModel && groupViewModel.IsRootGroup)
|
|
||||||
{
|
|
||||||
supportedInputTypes.Add(typeof(DataModelEvent));
|
|
||||||
supportedInputTypes.Add(typeof(DataModelEvent<>));
|
|
||||||
}
|
|
||||||
|
|
||||||
LeftSideSelectionViewModel.FilterTypes = supportedInputTypes.ToArray();
|
LeftSideSelectionViewModel.FilterTypes = supportedInputTypes.ToArray();
|
||||||
LeftSideSelectionViewModel.ButtonBrush = new SolidColorBrush(Color.FromRgb(71, 108, 188));
|
LeftSideSelectionViewModel.ButtonBrush = new SolidColorBrush(Color.FromRgb(71, 108, 188));
|
||||||
LeftSideSelectionViewModel.Placeholder = "Select a list";
|
LeftSideSelectionViewModel.Placeholder = "Select a list";
|
||||||
|
|||||||
@ -67,7 +67,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
DataModelConditionEventPredicate.DataModelConditionEvent.EventArgumentType
|
DataModelConditionEventPredicate.DataModelConditionEvent.EventArgumentType
|
||||||
);
|
);
|
||||||
|
|
||||||
return wrapper.CreateViewModel(_dataModelUIService);
|
return wrapper.CreateViewModel(_dataModelUIService, new DataModelUpdateConfiguration(false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -34,13 +34,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
supportedInputTypes.AddRange(editors.Where(e => e.CompatibleConversionTypes != null).SelectMany(e => e.CompatibleConversionTypes));
|
supportedInputTypes.AddRange(editors.Where(e => e.CompatibleConversionTypes != null).SelectMany(e => e.CompatibleConversionTypes));
|
||||||
supportedInputTypes.Add(typeof(IEnumerable<>));
|
supportedInputTypes.Add(typeof(IEnumerable<>));
|
||||||
|
|
||||||
// Events are only supported in the root group enforce that here
|
|
||||||
if (Parent is DataModelConditionGroupViewModel groupViewModel && groupViewModel.IsRootGroup)
|
|
||||||
{
|
|
||||||
supportedInputTypes.Add(typeof(DataModelEvent));
|
|
||||||
supportedInputTypes.Add(typeof(DataModelEvent<>));
|
|
||||||
}
|
|
||||||
|
|
||||||
return supportedInputTypes;
|
return supportedInputTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -77,7 +77,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
DataModelConditionListPredicate.DataModelConditionList.ListType
|
DataModelConditionListPredicate.DataModelConditionList.ListType
|
||||||
);
|
);
|
||||||
|
|
||||||
return wrapper.CreateViewModel(_dataModelUIService);
|
return wrapper.CreateViewModel(_dataModelUIService, new DataModelUpdateConfiguration(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,6 +135,25 @@
|
|||||||
<ContentControl Grid.Column="2" s:View.Model="{Binding DisplayViewModel}" FontFamily="Consolas" />
|
<ContentControl Grid.Column="2" s:View.Model="{Binding DisplayViewModel}" FontFamily="Consolas" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</HierarchicalDataTemplate>
|
</HierarchicalDataTemplate>
|
||||||
|
|
||||||
|
<HierarchicalDataTemplate DataType="{x:Type dataModel:DataModelEventViewModel}" ItemsSource="{Binding Children}">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Grid.Column="0" Margin="0 0 5 0" FontWeight="Bold">
|
||||||
|
<Run>[</Run><Run Text="{Binding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" /><Run>]</Run>
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Grid.Column="1" Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" />
|
||||||
|
<TextBlock Grid.Column="2"
|
||||||
|
Text="{Binding CountDisplay, Mode=OneWay}"
|
||||||
|
FontFamily="Consolas"
|
||||||
|
HorizontalAlignment="Right" />
|
||||||
|
</Grid>
|
||||||
|
</HierarchicalDataTemplate>
|
||||||
|
|
||||||
<HierarchicalDataTemplate DataType="{x:Type dataModel:DataModelListPropertiesViewModel}" ItemsSource="{Binding DisplayViewModel.Children}">
|
<HierarchicalDataTemplate DataType="{x:Type dataModel:DataModelListPropertiesViewModel}" ItemsSource="{Binding DisplayViewModel.Children}">
|
||||||
<TextBlock>
|
<TextBlock>
|
||||||
<Run>List item [</Run><Run Text="{Binding Index, Mode=OneWay}" /><Run>]</Run>
|
<Run>List item [</Run><Run Text="{Binding Index, Mode=OneWay}" /><Run>]</Run>
|
||||||
|
|||||||
@ -99,7 +99,7 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
|||||||
{
|
{
|
||||||
lock (MainDataModel)
|
lock (MainDataModel)
|
||||||
{
|
{
|
||||||
MainDataModel.Update(_dataModelUIService);
|
MainDataModel.Update(_dataModelUIService, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user