mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Data model visualization - Simplified and improved VMs
Layer conditions - Added left side property selection
This commit is contained in:
parent
55555ed6a8
commit
4e1a09308f
@ -0,0 +1,36 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Artemis.Core.Models.Profile.Conditions.Abstract
|
||||||
|
{
|
||||||
|
public abstract class DisplayConditionPart
|
||||||
|
{
|
||||||
|
private readonly List<DisplayConditionPart> _children;
|
||||||
|
|
||||||
|
protected DisplayConditionPart()
|
||||||
|
{
|
||||||
|
_children = new List<DisplayConditionPart>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DisplayConditionPart Parent { get; set; }
|
||||||
|
public IReadOnlyList<DisplayConditionPart> Children => _children.AsReadOnly();
|
||||||
|
|
||||||
|
public void AddChild(DisplayConditionPart displayConditionPart)
|
||||||
|
{
|
||||||
|
if (!_children.Contains(displayConditionPart))
|
||||||
|
{
|
||||||
|
displayConditionPart.Parent = this;
|
||||||
|
_children.Add(displayConditionPart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveChild(DisplayConditionPart displayConditionPart)
|
||||||
|
{
|
||||||
|
if (_children.Contains(displayConditionPart))
|
||||||
|
{
|
||||||
|
displayConditionPart.Parent = null;
|
||||||
|
_children.Remove(displayConditionPart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,14 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Artemis.Core.Models.Profile.Conditions.Abstract
|
|
||||||
{
|
|
||||||
public abstract class LayerConditionPart
|
|
||||||
{
|
|
||||||
protected LayerConditionPart()
|
|
||||||
{
|
|
||||||
Children = new List<LayerConditionPart>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<LayerConditionPart> Children { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -4,9 +4,9 @@ using Artemis.Core.Plugins.Abstract.DataModels;
|
|||||||
|
|
||||||
namespace Artemis.Core.Models.Profile.Conditions
|
namespace Artemis.Core.Models.Profile.Conditions
|
||||||
{
|
{
|
||||||
public class LayerCondition
|
public class DisplayCondition
|
||||||
{
|
{
|
||||||
public Expression<Func<DataModel, bool>> ExpressionTree { get; set; }
|
public Expression<Func<DataModel, bool>> ExpressionTree { get; set; }
|
||||||
public LayerConditionGroup RootGroup { get; set; }
|
public DisplayConditionGroup RootGroup { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Artemis.Core.Models.Profile.Conditions
|
namespace Artemis.Core.Models.Profile.Conditions
|
||||||
{
|
{
|
||||||
public class LayerConditionGroup : LayerConditionPart
|
public class DisplayConditionGroup : DisplayConditionPart
|
||||||
{
|
{
|
||||||
public BooleanOperator BooleanOperator { get; set; }
|
public BooleanOperator BooleanOperator { get; set; }
|
||||||
}
|
}
|
||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Artemis.Core.Models.Profile.Conditions
|
namespace Artemis.Core.Models.Profile.Conditions
|
||||||
{
|
{
|
||||||
public class LayerConditionListStatement : LayerConditionPart
|
public class DisplayConditionListPredicate : DisplayConditionPart
|
||||||
{
|
{
|
||||||
public ListOperator ListOperator { get; set; }
|
public ListOperator ListOperator { get; set; }
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ using Artemis.Core.Services.Interfaces;
|
|||||||
|
|
||||||
namespace Artemis.Core.Models.Profile.Conditions
|
namespace Artemis.Core.Models.Profile.Conditions
|
||||||
{
|
{
|
||||||
public abstract class LayerConditionOperator
|
public abstract class DisplayConditionOperator
|
||||||
{
|
{
|
||||||
private IDataModelService _dataModelService;
|
private IDataModelService _dataModelService;
|
||||||
private bool _registered;
|
private bool _registered;
|
||||||
@ -3,12 +3,12 @@ using Artemis.Core.Models.Profile.Conditions.Abstract;
|
|||||||
|
|
||||||
namespace Artemis.Core.Models.Profile.Conditions
|
namespace Artemis.Core.Models.Profile.Conditions
|
||||||
{
|
{
|
||||||
public class LayerConditionStatement : LayerConditionPart
|
public class DisplayConditionPredicate : DisplayConditionPart
|
||||||
{
|
{
|
||||||
public Guid DataModelGuid { get; set; }
|
public Guid DataModelGuid { get; set; }
|
||||||
public string PropertyPath { get; set; }
|
public string PropertyPath { get; set; }
|
||||||
|
|
||||||
public LayerConditionOperator Operator { get; set; }
|
public DisplayConditionOperator Operator { get; set; }
|
||||||
public object Value { get; set; }
|
public object Value { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,7 +4,7 @@ using System.Linq.Expressions;
|
|||||||
|
|
||||||
namespace Artemis.Core.Models.Profile.Conditions.Operators
|
namespace Artemis.Core.Models.Profile.Conditions.Operators
|
||||||
{
|
{
|
||||||
public class GreaterThanConditionOperator : LayerConditionOperator
|
public class GreaterThanConditionOperator : DisplayConditionOperator
|
||||||
{
|
{
|
||||||
public override IReadOnlyCollection<Type> CompatibleTypes => new List<Type>
|
public override IReadOnlyCollection<Type> CompatibleTypes => new List<Type>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Artemis.Core.Extensions;
|
using Artemis.Core.Extensions;
|
||||||
|
using Artemis.Core.Models.Profile.Conditions;
|
||||||
using Artemis.Core.Models.Profile.LayerProperties;
|
using Artemis.Core.Models.Profile.LayerProperties;
|
||||||
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
|
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
|
||||||
using Artemis.Core.Models.Profile.LayerShapes;
|
using Artemis.Core.Models.Profile.LayerShapes;
|
||||||
@ -22,6 +23,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class Layer : EffectProfileElement
|
public sealed class Layer : EffectProfileElement
|
||||||
{
|
{
|
||||||
|
private DisplayConditionGroup _displayConditionGroup;
|
||||||
private LayerGeneralProperties _general;
|
private LayerGeneralProperties _general;
|
||||||
private SKBitmap _layerBitmap;
|
private SKBitmap _layerBitmap;
|
||||||
private BaseLayerBrush _layerBrush;
|
private BaseLayerBrush _layerBrush;
|
||||||
@ -115,6 +117,15 @@ namespace Artemis.Core.Models.Profile
|
|||||||
internal set => SetAndNotify(ref _layerBrush, value);
|
internal set => SetAndNotify(ref _layerBrush, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the root display condition group
|
||||||
|
/// </summary>
|
||||||
|
public DisplayConditionGroup DisplayConditionGroup
|
||||||
|
{
|
||||||
|
get => _displayConditionGroup;
|
||||||
|
set => SetAndNotify(ref _displayConditionGroup, value);
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"[Layer] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
|
return $"[Layer] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
|
||||||
|
|||||||
@ -21,13 +21,13 @@ namespace Artemis.Core.Services
|
|||||||
{
|
{
|
||||||
private readonly List<DataModel> _dataModelExpansions;
|
private readonly List<DataModel> _dataModelExpansions;
|
||||||
private readonly IPluginService _pluginService;
|
private readonly IPluginService _pluginService;
|
||||||
private readonly List<LayerConditionOperator> _registeredConditionOperators;
|
private readonly List<DisplayConditionOperator> _registeredConditionOperators;
|
||||||
|
|
||||||
internal DataModelService(IPluginService pluginService)
|
internal DataModelService(IPluginService pluginService)
|
||||||
{
|
{
|
||||||
_pluginService = pluginService;
|
_pluginService = pluginService;
|
||||||
_dataModelExpansions = new List<DataModel>();
|
_dataModelExpansions = new List<DataModel>();
|
||||||
_registeredConditionOperators = new List<LayerConditionOperator>();
|
_registeredConditionOperators = new List<DisplayConditionOperator>();
|
||||||
|
|
||||||
_pluginService.PluginEnabled += PluginServiceOnPluginEnabled;
|
_pluginService.PluginEnabled += PluginServiceOnPluginEnabled;
|
||||||
_pluginService.PluginDisabled += PluginServiceOnPluginDisabled;
|
_pluginService.PluginDisabled += PluginServiceOnPluginDisabled;
|
||||||
@ -81,40 +81,50 @@ namespace Artemis.Core.Services
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool GetPluginExtendsDataModel(Plugin plugin)
|
||||||
|
{
|
||||||
|
if (plugin is Module module)
|
||||||
|
return module.InternalExpandsMainDataModel;
|
||||||
|
if (plugin is BaseDataModelExpansion)
|
||||||
|
return true;
|
||||||
|
|
||||||
public void RegisterConditionOperator(PluginInfo pluginInfo, LayerConditionOperator layerConditionOperator)
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void RegisterConditionOperator(PluginInfo pluginInfo, DisplayConditionOperator displayConditionOperator)
|
||||||
{
|
{
|
||||||
if (pluginInfo == null)
|
if (pluginInfo == null)
|
||||||
throw new ArgumentNullException(nameof(pluginInfo));
|
throw new ArgumentNullException(nameof(pluginInfo));
|
||||||
if (layerConditionOperator == null)
|
if (displayConditionOperator == null)
|
||||||
throw new ArgumentNullException(nameof(layerConditionOperator));
|
throw new ArgumentNullException(nameof(displayConditionOperator));
|
||||||
|
|
||||||
lock (_registeredConditionOperators)
|
lock (_registeredConditionOperators)
|
||||||
{
|
{
|
||||||
if (_registeredConditionOperators.Contains(layerConditionOperator))
|
if (_registeredConditionOperators.Contains(displayConditionOperator))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
layerConditionOperator.Register(pluginInfo, this);
|
displayConditionOperator.Register(pluginInfo, this);
|
||||||
_registeredConditionOperators.Add(layerConditionOperator);
|
_registeredConditionOperators.Add(displayConditionOperator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveConditionOperator(LayerConditionOperator layerConditionOperator)
|
public void RemoveConditionOperator(DisplayConditionOperator displayConditionOperator)
|
||||||
{
|
{
|
||||||
if (layerConditionOperator == null)
|
if (displayConditionOperator == null)
|
||||||
throw new ArgumentNullException(nameof(layerConditionOperator));
|
throw new ArgumentNullException(nameof(displayConditionOperator));
|
||||||
|
|
||||||
lock (_registeredConditionOperators)
|
lock (_registeredConditionOperators)
|
||||||
{
|
{
|
||||||
if (!_registeredConditionOperators.Contains(layerConditionOperator))
|
if (!_registeredConditionOperators.Contains(displayConditionOperator))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
layerConditionOperator.Unsubscribe();
|
displayConditionOperator.Unsubscribe();
|
||||||
_registeredConditionOperators.Remove(layerConditionOperator);
|
_registeredConditionOperators.Remove(displayConditionOperator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LayerConditionOperator> GetCompatibleConditionOperators(Type type)
|
public List<DisplayConditionOperator> GetCompatibleConditionOperators(Type type)
|
||||||
{
|
{
|
||||||
lock (_registeredConditionOperators)
|
lock (_registeredConditionOperators)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -29,17 +29,24 @@ namespace Artemis.Core.Services.Interfaces
|
|||||||
/// <param name="plugin">Should be a module with a data model or a data model expansion</param>
|
/// <param name="plugin">Should be a module with a data model or a data model expansion</param>
|
||||||
DataModel GetPluginDataModel(Plugin plugin);
|
DataModel GetPluginDataModel(Plugin plugin);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether the given plugin expands the main data model
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plugin"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool GetPluginExtendsDataModel(Plugin plugin);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers a new condition operator for use in layer conditions
|
/// Registers a new condition operator for use in layer conditions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pluginInfo">The PluginInfo of the plugin this condition operator belongs to</param>
|
/// <param name="pluginInfo">The PluginInfo of the plugin this condition operator belongs to</param>
|
||||||
/// <param name="layerConditionOperator">The condition operator to register</param>
|
/// <param name="displayConditionOperator">The condition operator to register</param>
|
||||||
void RegisterConditionOperator([NotNull] PluginInfo pluginInfo, [NotNull] LayerConditionOperator layerConditionOperator);
|
void RegisterConditionOperator([NotNull] PluginInfo pluginInfo, [NotNull] DisplayConditionOperator displayConditionOperator);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes a condition operator so it is no longer available for use in layer conditions
|
/// Removes a condition operator so it is no longer available for use in layer conditions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="layerConditionOperator">The layer condition operator to remove</param>
|
/// <param name="displayConditionOperator">The layer condition operator to remove</param>
|
||||||
void RemoveConditionOperator([NotNull] LayerConditionOperator layerConditionOperator);
|
void RemoveConditionOperator([NotNull] DisplayConditionOperator displayConditionOperator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using Artemis.Core.Plugins.Abstract.DataModels;
|
||||||
|
using Artemis.UI.Shared.Services;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||||
|
{
|
||||||
|
public class DataModelListPropertiesViewModel : DataModelPropertiesViewModel
|
||||||
|
{
|
||||||
|
private object _displayValue;
|
||||||
|
private int _index;
|
||||||
|
private Type _listType;
|
||||||
|
|
||||||
|
public DataModelListPropertiesViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, PropertyInfo propertyInfo) : base(dataModel, parent, propertyInfo)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Index
|
||||||
|
{
|
||||||
|
get => _index;
|
||||||
|
set => SetAndNotify(ref _index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type ListType
|
||||||
|
{
|
||||||
|
get => _listType;
|
||||||
|
set => SetAndNotify(ref _listType, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object DisplayValue
|
||||||
|
{
|
||||||
|
get => _displayValue;
|
||||||
|
set => SetAndNotify(ref _displayValue, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(IDataModelVisualizationService dataModelVisualizationService)
|
||||||
|
{
|
||||||
|
// Display value gets updated by parent, don't do anything if it is null
|
||||||
|
if (DisplayValue == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ListType = DisplayValue.GetType();
|
||||||
|
PopulateProperties(dataModelVisualizationService);
|
||||||
|
foreach (var dataModelVisualizationViewModel in Children)
|
||||||
|
dataModelVisualizationViewModel.Update(dataModelVisualizationService);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object GetCurrentValue()
|
||||||
|
{
|
||||||
|
return DisplayValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PopulateProperties(IDataModelVisualizationService dataModelVisualizationService)
|
||||||
|
{
|
||||||
|
if (Children.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var propertyInfo in ListType.GetProperties())
|
||||||
|
{
|
||||||
|
var child = CreateChild(dataModelVisualizationService, propertyInfo);
|
||||||
|
if (child != null)
|
||||||
|
Children.Add(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using Artemis.Core.Plugins.Abstract.DataModels;
|
||||||
|
using Artemis.UI.Shared.Services;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||||
|
{
|
||||||
|
public class DataModelListPropertyViewModel : DataModelPropertyViewModel
|
||||||
|
{
|
||||||
|
private int _index;
|
||||||
|
private Type _listType;
|
||||||
|
|
||||||
|
public DataModelListPropertyViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, PropertyInfo propertyInfo) : base(dataModel, parent, propertyInfo)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Index
|
||||||
|
{
|
||||||
|
get => _index;
|
||||||
|
set => SetAndNotify(ref _index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type ListType
|
||||||
|
{
|
||||||
|
get => _listType;
|
||||||
|
set => SetAndNotify(ref _listType, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object GetCurrentValue()
|
||||||
|
{
|
||||||
|
return DisplayValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(IDataModelVisualizationService dataModelVisualizationService)
|
||||||
|
{
|
||||||
|
// Display value gets updated by parent, don't do anything if it is null
|
||||||
|
if (DisplayValue == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (DisplayViewModel == null && dataModelVisualizationService.RegisteredDataModelDisplays.Any(d => d.SupportedType == DisplayValue.GetType()))
|
||||||
|
dataModelVisualizationService.GetDataModelDisplayViewModel(DisplayValue.GetType());
|
||||||
|
|
||||||
|
ListType = DisplayValue.GetType();
|
||||||
|
UpdateDisplayParameters();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,8 @@
|
|||||||
using System.Collections;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections;
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Artemis.Core.Extensions;
|
||||||
|
using Artemis.Core.Plugins.Abstract.DataModels;
|
||||||
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
|
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
|
||||||
using Artemis.UI.Shared.Services;
|
using Artemis.UI.Shared.Services;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
@ -10,25 +11,12 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
|||||||
{
|
{
|
||||||
public class DataModelListViewModel : DataModelVisualizationViewModel
|
public class DataModelListViewModel : DataModelVisualizationViewModel
|
||||||
{
|
{
|
||||||
private readonly IDataModelVisualizationService _dataModelVisualizationService;
|
|
||||||
private BindableCollection<DataModelVisualizationViewModel> _children;
|
|
||||||
private string _count;
|
private string _count;
|
||||||
private IList _list;
|
private IList _list;
|
||||||
|
|
||||||
internal DataModelListViewModel(PropertyInfo propertyInfo, DataModelPropertyAttribute propertyDescription, DataModelVisualizationViewModel parent,
|
internal DataModelListViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, PropertyInfo propertyInfo) : base(dataModel, parent, propertyInfo)
|
||||||
IDataModelVisualizationService dataModelVisualizationService)
|
|
||||||
{
|
{
|
||||||
_dataModelVisualizationService = dataModelVisualizationService;
|
ListChildren = new BindableCollection<DataModelVisualizationViewModel>();
|
||||||
PropertyInfo = propertyInfo;
|
|
||||||
Parent = parent;
|
|
||||||
PropertyDescription = propertyDescription;
|
|
||||||
Children = new BindableCollection<DataModelVisualizationViewModel>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BindableCollection<DataModelVisualizationViewModel> Children
|
|
||||||
{
|
|
||||||
get => _children;
|
|
||||||
set => SetAndNotify(ref _children, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList List
|
public IList List
|
||||||
@ -37,43 +25,67 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
|||||||
set => SetAndNotify(ref _list, value);
|
set => SetAndNotify(ref _list, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BindableCollection<DataModelVisualizationViewModel> ListChildren { get; set; }
|
||||||
|
|
||||||
public string Count
|
public string Count
|
||||||
{
|
{
|
||||||
get => _count;
|
get => _count;
|
||||||
set => SetAndNotify(ref _count, value);
|
set => SetAndNotify(ref _count, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update(IDataModelVisualizationService dataModelVisualizationService)
|
||||||
{
|
{
|
||||||
if (PropertyInfo != null && Parent?.Model != null && PropertyInfo.GetValue(Parent.Model) is IList listValue)
|
List = GetCurrentValue() as IList;
|
||||||
{
|
if (List == null)
|
||||||
Model = new List<object>(listValue.Cast<object>());
|
return;
|
||||||
List = (IList) Model;
|
|
||||||
}
|
|
||||||
|
|
||||||
var index = 0;
|
var index = 0;
|
||||||
foreach (var item in List)
|
foreach (var item in List)
|
||||||
{
|
{
|
||||||
DataModelVisualizationViewModel child;
|
DataModelVisualizationViewModel child;
|
||||||
if (Children.Count <= index)
|
if (ListChildren.Count <= index)
|
||||||
{
|
{
|
||||||
child = CreateChild(_dataModelVisualizationService, item);
|
child = CreateListChild(dataModelVisualizationService, item.GetType());
|
||||||
Children.Add(child);
|
ListChildren.Add(child);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
child = ListChildren[index];
|
||||||
|
|
||||||
|
if (child is DataModelListPropertiesViewModel dataModelListClassViewModel)
|
||||||
{
|
{
|
||||||
child = Children[index];
|
dataModelListClassViewModel.DisplayValue = item;
|
||||||
child.Model = item;
|
dataModelListClassViewModel.Index = index;
|
||||||
|
}
|
||||||
|
else if (child is DataModelListPropertyViewModel dataModelListPropertyViewModel)
|
||||||
|
{
|
||||||
|
dataModelListPropertyViewModel.DisplayValue = item;
|
||||||
|
dataModelListPropertyViewModel.Index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
child.Update();
|
child.Update(dataModelVisualizationService);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (Children.Count > List.Count)
|
while (ListChildren.Count > List.Count)
|
||||||
Children.RemoveAt(Children.Count - 1);
|
ListChildren.RemoveAt(ListChildren.Count - 1);
|
||||||
|
|
||||||
Count = $"{Children.Count} {(Children.Count == 1 ? "item" : "items")}";
|
Count = $"{ListChildren.Count} {(ListChildren.Count == 1 ? "item" : "items")}";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DataModelVisualizationViewModel CreateListChild(IDataModelVisualizationService dataModelVisualizationService, Type listType)
|
||||||
|
{
|
||||||
|
// If a display VM was found, prefer to use that in any case
|
||||||
|
var typeViewModel = dataModelVisualizationService.GetDataModelDisplayViewModel(listType);
|
||||||
|
if (typeViewModel != null)
|
||||||
|
return new DataModelListPropertyViewModel(DataModel, this, PropertyInfo) {DisplayViewModel = typeViewModel};
|
||||||
|
// For primitives, create a property view model, it may be null that is fine
|
||||||
|
if (listType.IsPrimitive || listType == typeof(string))
|
||||||
|
return new DataModelListPropertyViewModel(DataModel, this, PropertyInfo);
|
||||||
|
// For other value types create a child view model
|
||||||
|
if (listType.IsClass || listType.IsStruct())
|
||||||
|
return new DataModelListPropertiesViewModel(DataModel, this, PropertyInfo);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using Artemis.Core.Plugins.Abstract.DataModels;
|
||||||
|
using Artemis.UI.Shared.Services;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||||
|
{
|
||||||
|
public class DataModelPropertiesViewModel : DataModelVisualizationViewModel
|
||||||
|
{
|
||||||
|
internal DataModelPropertiesViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, PropertyInfo propertyInfo) : base(dataModel, parent, propertyInfo)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(IDataModelVisualizationService dataModelVisualizationService)
|
||||||
|
{
|
||||||
|
PopulateProperties(dataModelVisualizationService);
|
||||||
|
foreach (var dataModelVisualizationViewModel in Children)
|
||||||
|
dataModelVisualizationViewModel.Update(dataModelVisualizationService);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object GetCurrentValue()
|
||||||
|
{
|
||||||
|
return Parent.IsRootViewModel ? DataModel : base.GetCurrentValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void PopulateProperties(IDataModelVisualizationService dataModelVisualizationService)
|
||||||
|
{
|
||||||
|
if (Children.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
|
var modelType = Parent.IsRootViewModel ? DataModel.GetType() : PropertyInfo.PropertyType;
|
||||||
|
foreach (var propertyInfo in modelType.GetProperties())
|
||||||
|
{
|
||||||
|
var child = CreateChild(dataModelVisualizationService, propertyInfo);
|
||||||
|
if (child != null)
|
||||||
|
Children.Add(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,20 +1,26 @@
|
|||||||
using System.Reflection;
|
using System.Linq;
|
||||||
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
|
using System.Reflection;
|
||||||
|
using Artemis.Core.Plugins.Abstract.DataModels;
|
||||||
|
using Artemis.UI.Shared.Services;
|
||||||
|
|
||||||
namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||||
{
|
{
|
||||||
public class DataModelPropertyViewModel : DataModelVisualizationViewModel
|
public class DataModelPropertyViewModel : DataModelVisualizationViewModel
|
||||||
{
|
{
|
||||||
|
private object _displayValue;
|
||||||
private DataModelDisplayViewModel _displayViewModel;
|
private DataModelDisplayViewModel _displayViewModel;
|
||||||
private bool _showNull;
|
private bool _showNull;
|
||||||
private bool _showToString;
|
private bool _showToString;
|
||||||
private bool _showViewModel;
|
private bool _showViewModel;
|
||||||
|
|
||||||
internal DataModelPropertyViewModel(PropertyInfo propertyInfo, DataModelPropertyAttribute propertyDescription, DataModelVisualizationViewModel parent)
|
internal DataModelPropertyViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, PropertyInfo propertyInfo) : base(dataModel, parent, propertyInfo)
|
||||||
{
|
{
|
||||||
PropertyInfo = propertyInfo;
|
}
|
||||||
Parent = parent;
|
|
||||||
PropertyDescription = propertyDescription;
|
public object DisplayValue
|
||||||
|
{
|
||||||
|
get => _displayValue;
|
||||||
|
set => SetAndNotify(ref _displayValue, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataModelDisplayViewModel DisplayViewModel
|
public DataModelDisplayViewModel DisplayViewModel
|
||||||
@ -41,19 +47,22 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
|||||||
set => SetAndNotify(ref _showViewModel, value);
|
set => SetAndNotify(ref _showViewModel, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update(IDataModelVisualizationService dataModelVisualizationService)
|
||||||
{
|
{
|
||||||
if (PropertyInfo != null && Parent?.Model != null)
|
if (DisplayViewModel == null && dataModelVisualizationService.RegisteredDataModelDisplays.Any(d => d.SupportedType == PropertyInfo.PropertyType))
|
||||||
{
|
dataModelVisualizationService.GetDataModelDisplayViewModel(PropertyInfo.PropertyType);
|
||||||
Model = PropertyInfo.GetValue(Parent.Model);
|
|
||||||
DisplayViewModel?.UpdateValue(Model);
|
|
||||||
}
|
|
||||||
|
|
||||||
ShowToString = Model != null && DisplayViewModel == null;
|
DisplayValue = GetCurrentValue();
|
||||||
ShowNull = Model == null;
|
UpdateDisplayParameters();
|
||||||
ShowViewModel = Model != null && DisplayViewModel != null;
|
}
|
||||||
|
|
||||||
UpdateListStatus();
|
protected void UpdateDisplayParameters()
|
||||||
|
{
|
||||||
|
ShowToString = DisplayValue != null && DisplayViewModel == null;
|
||||||
|
ShowNull = DisplayValue == null;
|
||||||
|
ShowViewModel = DisplayValue != null && DisplayViewModel != null;
|
||||||
|
|
||||||
|
DisplayViewModel?.UpdateValue(DisplayValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,60 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
using Artemis.Core.Extensions;
|
|
||||||
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
|
|
||||||
using Artemis.UI.Shared.Services;
|
|
||||||
using Stylet;
|
|
||||||
|
|
||||||
namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
|
||||||
{
|
|
||||||
public class DataModelViewModel : DataModelVisualizationViewModel
|
|
||||||
{
|
|
||||||
private readonly IDataModelVisualizationService _dataModelVisualizationService;
|
|
||||||
private BindableCollection<DataModelVisualizationViewModel> _children;
|
|
||||||
|
|
||||||
internal DataModelViewModel()
|
|
||||||
{
|
|
||||||
Children = new BindableCollection<DataModelVisualizationViewModel>();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal DataModelViewModel(PropertyInfo propertyInfo, object model, DataModelPropertyAttribute propertyDescription, DataModelVisualizationViewModel parent,
|
|
||||||
IDataModelVisualizationService dataModelVisualizationService)
|
|
||||||
{
|
|
||||||
_dataModelVisualizationService = dataModelVisualizationService;
|
|
||||||
PropertyInfo = propertyInfo;
|
|
||||||
Model = model;
|
|
||||||
PropertyDescription = propertyDescription;
|
|
||||||
Parent = parent;
|
|
||||||
Children = new BindableCollection<DataModelVisualizationViewModel>();
|
|
||||||
|
|
||||||
PopulateProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BindableCollection<DataModelVisualizationViewModel> Children
|
|
||||||
{
|
|
||||||
get => _children;
|
|
||||||
set => SetAndNotify(ref _children, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PopulateProperties()
|
|
||||||
{
|
|
||||||
Children.Clear();
|
|
||||||
foreach (var propertyInfo in Model.GetType().GetProperties())
|
|
||||||
{
|
|
||||||
var child = CreateChild(_dataModelVisualizationService, propertyInfo);
|
|
||||||
if (child != null)
|
|
||||||
Children.Add(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Update()
|
|
||||||
{
|
|
||||||
if (PropertyInfo != null && PropertyInfo.PropertyType.IsStruct())
|
|
||||||
Model = PropertyInfo.GetValue(Parent.Model);
|
|
||||||
|
|
||||||
foreach (var dataModelVisualizationViewModel in Children)
|
|
||||||
dataModelVisualizationViewModel.Update();
|
|
||||||
|
|
||||||
UpdateListStatus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Artemis.Core.Extensions;
|
using Artemis.Core.Extensions;
|
||||||
|
using Artemis.Core.Plugins.Abstract.DataModels;
|
||||||
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
|
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
|
||||||
|
using Artemis.UI.Shared.Exceptions;
|
||||||
using Artemis.UI.Shared.Services;
|
using Artemis.UI.Shared.Services;
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
@ -11,22 +14,31 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
|||||||
{
|
{
|
||||||
public abstract class DataModelVisualizationViewModel : PropertyChangedBase
|
public abstract class DataModelVisualizationViewModel : PropertyChangedBase
|
||||||
{
|
{
|
||||||
private bool _isListProperty;
|
private BindableCollection<DataModelVisualizationViewModel> _children;
|
||||||
private string _listDescription;
|
private DataModel _dataModel;
|
||||||
private object _model;
|
|
||||||
private DataModelVisualizationViewModel _parent;
|
private DataModelVisualizationViewModel _parent;
|
||||||
private DataModelPropertyAttribute _propertyDescription;
|
private DataModelPropertyAttribute _propertyDescription;
|
||||||
private PropertyInfo _propertyInfo;
|
private PropertyInfo _propertyInfo;
|
||||||
private Type _propertyType;
|
|
||||||
|
|
||||||
internal DataModelVisualizationViewModel()
|
internal DataModelVisualizationViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, PropertyInfo propertyInfo)
|
||||||
{
|
{
|
||||||
|
DataModel = dataModel;
|
||||||
|
PropertyInfo = propertyInfo;
|
||||||
|
Parent = parent;
|
||||||
|
Children = new BindableCollection<DataModelVisualizationViewModel>();
|
||||||
|
|
||||||
|
if (dataModel == null && parent == null && propertyInfo == null)
|
||||||
|
IsRootViewModel = true;
|
||||||
|
else
|
||||||
|
GetDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataModelPropertyAttribute PropertyDescription
|
public bool IsRootViewModel { get; }
|
||||||
|
|
||||||
|
public DataModel DataModel
|
||||||
{
|
{
|
||||||
get => _propertyDescription;
|
get => _dataModel;
|
||||||
protected set => SetAndNotify(ref _propertyDescription, value);
|
set => SetAndNotify(ref _dataModel, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyInfo PropertyInfo
|
public PropertyInfo PropertyInfo
|
||||||
@ -35,10 +47,10 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
|||||||
protected set => SetAndNotify(ref _propertyInfo, value);
|
protected set => SetAndNotify(ref _propertyInfo, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type PropertyType
|
public DataModelPropertyAttribute PropertyDescription
|
||||||
{
|
{
|
||||||
get => _propertyType;
|
get => _propertyDescription;
|
||||||
set => SetAndNotify(ref _propertyType, value);
|
protected set => SetAndNotify(ref _propertyDescription, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataModelVisualizationViewModel Parent
|
public DataModelVisualizationViewModel Parent
|
||||||
@ -47,25 +59,53 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
|||||||
protected set => SetAndNotify(ref _parent, value);
|
protected set => SetAndNotify(ref _parent, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Model
|
public BindableCollection<DataModelVisualizationViewModel> Children
|
||||||
{
|
{
|
||||||
get => _model;
|
get => _children;
|
||||||
set => SetAndNotify(ref _model, value);
|
set => SetAndNotify(ref _children, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsListProperty
|
public abstract void Update(IDataModelVisualizationService dataModelVisualizationService);
|
||||||
|
|
||||||
|
public virtual object GetCurrentValue()
|
||||||
{
|
{
|
||||||
get => _isListProperty;
|
return Parent == null ? null : PropertyInfo.GetValue(Parent.GetCurrentValue());
|
||||||
set => SetAndNotify(ref _isListProperty, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ListDescription
|
public DataModelVisualizationViewModel GetChildByPath(Guid dataModelGuid, string propertyPath)
|
||||||
{
|
{
|
||||||
get => _listDescription;
|
var path = propertyPath.Split(".");
|
||||||
set => SetAndNotify(ref _listDescription, value);
|
var currentPart = path.First();
|
||||||
|
|
||||||
|
if (IsRootViewModel)
|
||||||
|
{
|
||||||
|
var child = Children.FirstOrDefault(c => c.DataModel.PluginInfo.Guid == dataModelGuid);
|
||||||
|
return child?.GetChildByPath(dataModelGuid, propertyPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var child = Children.FirstOrDefault(c => c.DataModel.PluginInfo.Guid == dataModelGuid && c.PropertyInfo?.Name == currentPart);
|
||||||
|
if (child == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (path.Length > 1)
|
||||||
|
return child.GetChildByPath(dataModelGuid, string.Join(".", path.Skip(1)));
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void Update();
|
public string GetCurrentPath()
|
||||||
|
{
|
||||||
|
if (Parent == null)
|
||||||
|
return PropertyInfo?.Name;
|
||||||
|
|
||||||
|
if (PropertyInfo == null)
|
||||||
|
return Parent.GetCurrentPath();
|
||||||
|
|
||||||
|
var parentPath = Parent.GetCurrentPath();
|
||||||
|
return parentPath != null ? $"{parentPath}.{PropertyInfo.Name}" : PropertyInfo.Name;
|
||||||
|
}
|
||||||
|
|
||||||
protected DataModelVisualizationViewModel CreateChild(IDataModelVisualizationService dataModelVisualizationService, PropertyInfo propertyInfo)
|
protected DataModelVisualizationViewModel CreateChild(IDataModelVisualizationService dataModelVisualizationService, PropertyInfo propertyInfo)
|
||||||
{
|
{
|
||||||
@ -73,64 +113,33 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
|||||||
if (Attribute.IsDefined(propertyInfo, typeof(DataModelIgnoreAttribute)))
|
if (Attribute.IsDefined(propertyInfo, typeof(DataModelIgnoreAttribute)))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var dataModelPropertyAttribute = (DataModelPropertyAttribute) Attribute.GetCustomAttribute(propertyInfo, typeof(DataModelPropertyAttribute));
|
|
||||||
// If no DataModelProperty attribute was provided, pull one out of our ass
|
|
||||||
if (dataModelPropertyAttribute == null)
|
|
||||||
dataModelPropertyAttribute = new DataModelPropertyAttribute {Name = propertyInfo.Name.Humanize()};
|
|
||||||
|
|
||||||
// If a display VM was found, prefer to use that in any case
|
// If a display VM was found, prefer to use that in any case
|
||||||
var typeViewModel = dataModelVisualizationService.GetDataModelDisplayViewModel(propertyInfo.PropertyType);
|
var typeViewModel = dataModelVisualizationService.GetDataModelDisplayViewModel(propertyInfo.PropertyType);
|
||||||
if (typeViewModel != null)
|
if (typeViewModel != null)
|
||||||
return new DataModelPropertyViewModel(propertyInfo, dataModelPropertyAttribute, this) {DisplayViewModel = typeViewModel};
|
return new DataModelPropertyViewModel(DataModel, this, propertyInfo) {DisplayViewModel = typeViewModel};
|
||||||
// For primitives, create a property view model, it may be null that is fine
|
// For primitives, create a property view model, it may be null that is fine
|
||||||
if (propertyInfo.PropertyType.IsPrimitive || propertyInfo.PropertyType == typeof(string))
|
if (propertyInfo.PropertyType.IsPrimitive || propertyInfo.PropertyType == typeof(string))
|
||||||
return new DataModelPropertyViewModel(propertyInfo, dataModelPropertyAttribute, this);
|
return new DataModelPropertyViewModel(DataModel, this, propertyInfo);
|
||||||
if (typeof(IList).IsAssignableFrom(propertyInfo.PropertyType))
|
if (typeof(IList).IsAssignableFrom(propertyInfo.PropertyType))
|
||||||
return new DataModelListViewModel(propertyInfo, dataModelPropertyAttribute, this, dataModelVisualizationService);
|
return new DataModelListViewModel(DataModel, this, propertyInfo);
|
||||||
// For other value types create a child view model if the value type is not null
|
// For other value types create a child view model
|
||||||
if (propertyInfo.PropertyType.IsClass || propertyInfo.PropertyType.IsStruct())
|
if (propertyInfo.PropertyType.IsClass || propertyInfo.PropertyType.IsStruct())
|
||||||
{
|
return new DataModelPropertiesViewModel(DataModel, this, propertyInfo);
|
||||||
var value = propertyInfo.GetValue(Model);
|
|
||||||
if (value == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new DataModelViewModel(propertyInfo, value, dataModelPropertyAttribute, this, dataModelVisualizationService);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DataModelVisualizationViewModel CreateChild(IDataModelVisualizationService dataModelVisualizationService, object value)
|
private void GetDescription()
|
||||||
{
|
{
|
||||||
var dataModelPropertyAttribute = new DataModelPropertyAttribute {Name = "Unknown property"};
|
// If this is the first child of a root view model, use the data model description
|
||||||
|
if (Parent.IsRootViewModel)
|
||||||
// If a display VM was found, prefer to use that in any case
|
PropertyDescription = DataModel?.DataModelDescription;
|
||||||
var typeViewModel = dataModelVisualizationService.GetDataModelDisplayViewModel(value.GetType());
|
// Rely on property info for the description
|
||||||
if (typeViewModel != null)
|
else if (PropertyInfo != null)
|
||||||
return new DataModelPropertyViewModel(null, dataModelPropertyAttribute, this) {Model = value, DisplayViewModel = typeViewModel};
|
PropertyDescription = (DataModelPropertyAttribute) Attribute.GetCustomAttribute(PropertyInfo, typeof(DataModelPropertyAttribute)) ??
|
||||||
// For primitives, create a property view model, it may be null that is fine
|
new DataModelPropertyAttribute {Name = PropertyInfo.Name.Humanize()};
|
||||||
if (value.GetType().IsPrimitive || value is string)
|
|
||||||
return new DataModelPropertyViewModel(null, dataModelPropertyAttribute, this) {Model = value};
|
|
||||||
// For other value types create a child view model if the value type is not null
|
|
||||||
if (value.GetType().IsClass || value.GetType().IsStruct())
|
|
||||||
return new DataModelViewModel(null, value, dataModelPropertyAttribute, this, dataModelVisualizationService);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void UpdateListStatus()
|
|
||||||
{
|
|
||||||
if (Parent is DataModelListViewModel listViewModel)
|
|
||||||
{
|
|
||||||
IsListProperty = true;
|
|
||||||
ListDescription = $"List item [{listViewModel.List.IndexOf(Model)}]";
|
|
||||||
PropertyType = Model.GetType();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
throw new ArtemisSharedUIException("Failed to get property description because plugin info is null but the parent has a datamodel");
|
||||||
IsListProperty = false;
|
|
||||||
PropertyType = PropertyInfo?.PropertyType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
19
src/Artemis.UI.Shared/Exceptions/ArtemisUIException.cs
Normal file
19
src/Artemis.UI.Shared/Exceptions/ArtemisUIException.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Shared.Exceptions
|
||||||
|
{
|
||||||
|
public class ArtemisSharedUIException : Exception
|
||||||
|
{
|
||||||
|
internal ArtemisSharedUIException()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
internal ArtemisSharedUIException(string message) : base(message)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
internal ArtemisSharedUIException(string message, Exception inner) : base(message, inner)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -18,6 +18,8 @@ namespace Artemis.UI.Shared.Services
|
|||||||
private readonly IKernel _kernel;
|
private readonly IKernel _kernel;
|
||||||
private readonly List<DataModelVisualizationRegistration> _registeredDataModelDisplays;
|
private readonly List<DataModelVisualizationRegistration> _registeredDataModelDisplays;
|
||||||
private readonly List<DataModelVisualizationRegistration> _registeredDataModelEditors;
|
private readonly List<DataModelVisualizationRegistration> _registeredDataModelEditors;
|
||||||
|
private DataModelPropertiesViewModel _cachedMainDataModel;
|
||||||
|
private Dictionary<Plugin, DataModelPropertiesViewModel> _cachedDataModels;
|
||||||
|
|
||||||
public DataModelVisualizationService(IDataModelService dataModelService, IKernel kernel)
|
public DataModelVisualizationService(IDataModelService dataModelService, IKernel kernel)
|
||||||
{
|
{
|
||||||
@ -25,28 +27,66 @@ namespace Artemis.UI.Shared.Services
|
|||||||
_kernel = kernel;
|
_kernel = kernel;
|
||||||
_registeredDataModelEditors = new List<DataModelVisualizationRegistration>();
|
_registeredDataModelEditors = new List<DataModelVisualizationRegistration>();
|
||||||
_registeredDataModelDisplays = new List<DataModelVisualizationRegistration>();
|
_registeredDataModelDisplays = new List<DataModelVisualizationRegistration>();
|
||||||
|
_cachedDataModels = new Dictionary<Plugin, DataModelPropertiesViewModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataModelViewModel GetMainDataModelVisualization()
|
public IReadOnlyCollection<DataModelVisualizationRegistration> RegisteredDataModelEditors => _registeredDataModelEditors.AsReadOnly();
|
||||||
|
public IReadOnlyCollection<DataModelVisualizationRegistration> RegisteredDataModelDisplays => _registeredDataModelDisplays.AsReadOnly();
|
||||||
|
|
||||||
|
public DataModelPropertiesViewModel GetMainDataModelVisualization(bool useCache)
|
||||||
{
|
{
|
||||||
var viewModel = new DataModelViewModel();
|
// Return from cache if found
|
||||||
|
if (useCache && _cachedMainDataModel != null)
|
||||||
|
return _cachedMainDataModel;
|
||||||
|
|
||||||
|
var viewModel = new DataModelPropertiesViewModel(null, null, null);
|
||||||
foreach (var dataModelExpansion in _dataModelService.DataModelExpansions)
|
foreach (var dataModelExpansion in _dataModelService.DataModelExpansions)
|
||||||
viewModel.Children.Add(new DataModelViewModel(null, dataModelExpansion, dataModelExpansion.DataModelDescription, viewModel, this));
|
viewModel.Children.Add(new DataModelPropertiesViewModel(dataModelExpansion, viewModel, null));
|
||||||
|
|
||||||
|
// Update to populate children
|
||||||
|
viewModel.Update(this);
|
||||||
|
|
||||||
|
// Add to cache
|
||||||
|
_cachedMainDataModel = viewModel;
|
||||||
|
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataModelViewModel GetPluginDataModelVisualization(Plugin plugin)
|
public DataModelPropertiesViewModel GetPluginDataModelVisualization(Plugin plugin, bool useCache)
|
||||||
{
|
{
|
||||||
|
// Return from cache if found
|
||||||
|
var isCached = _cachedDataModels.TryGetValue(plugin, out var cachedMainDataModel);
|
||||||
|
if (useCache && isCached)
|
||||||
|
return cachedMainDataModel;
|
||||||
|
|
||||||
var dataModel = _dataModelService.GetPluginDataModel(plugin);
|
var dataModel = _dataModelService.GetPluginDataModel(plugin);
|
||||||
if (dataModel == null)
|
if (dataModel == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var viewModel = new DataModelViewModel();
|
var viewModel = new DataModelPropertiesViewModel(null, null, null);
|
||||||
viewModel.Children.Add(new DataModelViewModel(null, dataModel, dataModel.DataModelDescription, viewModel, this));
|
viewModel.Children.Add(new DataModelPropertiesViewModel(dataModel, viewModel, null));
|
||||||
|
|
||||||
|
// Update to populate children
|
||||||
|
viewModel.Update(this);
|
||||||
|
|
||||||
|
// Add to cache
|
||||||
|
if (!isCached)
|
||||||
|
_cachedDataModels.Add(plugin, viewModel);
|
||||||
|
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool GetPluginExtendsDataModel(Plugin plugin)
|
||||||
|
{
|
||||||
|
return _dataModelService.GetPluginExtendsDataModel(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BustCache()
|
||||||
|
{
|
||||||
|
_cachedMainDataModel = null;
|
||||||
|
_cachedDataModels.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
public DataModelVisualizationRegistration RegisterDataModelInput<T>(PluginInfo pluginInfo) where T : DataModelInputViewModel
|
public DataModelVisualizationRegistration RegisterDataModelInput<T>(PluginInfo pluginInfo) where T : DataModelInputViewModel
|
||||||
{
|
{
|
||||||
var viewModelType = typeof(T);
|
var viewModelType = typeof(T);
|
||||||
@ -133,8 +173,17 @@ namespace Artemis.UI.Shared.Services
|
|||||||
|
|
||||||
public interface IDataModelVisualizationService : IArtemisSharedUIService
|
public interface IDataModelVisualizationService : IArtemisSharedUIService
|
||||||
{
|
{
|
||||||
DataModelViewModel GetMainDataModelVisualization();
|
DataModelPropertiesViewModel GetMainDataModelVisualization(bool useCached);
|
||||||
DataModelViewModel GetPluginDataModelVisualization(Plugin plugin);
|
DataModelPropertiesViewModel GetPluginDataModelVisualization(Plugin plugin, bool useCached);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether the given plugin expands the main data model
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plugin"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool GetPluginExtendsDataModel(Plugin plugin);
|
||||||
|
|
||||||
|
void BustCache();
|
||||||
|
|
||||||
DataModelVisualizationRegistration RegisterDataModelInput<T>(PluginInfo pluginInfo) where T : DataModelInputViewModel;
|
DataModelVisualizationRegistration RegisterDataModelInput<T>(PluginInfo pluginInfo) where T : DataModelInputViewModel;
|
||||||
DataModelVisualizationRegistration RegisterDataModelDisplay<T>(PluginInfo pluginInfo) where T : DataModelDisplayViewModel;
|
DataModelVisualizationRegistration RegisterDataModelDisplay<T>(PluginInfo pluginInfo) where T : DataModelDisplayViewModel;
|
||||||
@ -142,5 +191,7 @@ namespace Artemis.UI.Shared.Services
|
|||||||
void RemoveDataModelDisplay(DataModelVisualizationRegistration registration);
|
void RemoveDataModelDisplay(DataModelVisualizationRegistration registration);
|
||||||
|
|
||||||
DataModelDisplayViewModel GetDataModelDisplayViewModel(Type propertyType);
|
DataModelDisplayViewModel GetDataModelDisplayViewModel(Type propertyType);
|
||||||
|
IReadOnlyCollection<DataModelVisualizationRegistration> RegisteredDataModelEditors { get; }
|
||||||
|
IReadOnlyCollection<DataModelVisualizationRegistration> RegisteredDataModelDisplays { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -27,6 +27,7 @@ namespace Artemis.UI.Shared.Services.Interfaces
|
|||||||
void RedoUpdateProfile(ProfileModule module);
|
void RedoUpdateProfile(ProfileModule module);
|
||||||
void StopRegularRender();
|
void StopRegularRender();
|
||||||
void ResumeRegularRender();
|
void ResumeRegularRender();
|
||||||
|
Module GetCurrentModule();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when a new profile is selected
|
/// Occurs when a new profile is selected
|
||||||
|
|||||||
@ -189,6 +189,11 @@ namespace Artemis.UI.Shared.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Module GetCurrentModule()
|
||||||
|
{
|
||||||
|
return (Module) SelectedProfile?.PluginInfo.Instance;
|
||||||
|
}
|
||||||
|
|
||||||
public event EventHandler<ProfileElementEventArgs> ProfileSelected;
|
public event EventHandler<ProfileElementEventArgs> ProfileSelected;
|
||||||
public event EventHandler<ProfileElementEventArgs> SelectedProfileUpdated;
|
public event EventHandler<ProfileElementEventArgs> SelectedProfileUpdated;
|
||||||
public event EventHandler<ProfileElementEventArgs> ProfileElementSelected;
|
public event EventHandler<ProfileElementEventArgs> ProfileElementSelected;
|
||||||
|
|||||||
@ -34,7 +34,7 @@ namespace Artemis.UI
|
|||||||
|
|
||||||
protected override void Launch()
|
protected override void Launch()
|
||||||
{
|
{
|
||||||
var test = new LayerCondition();
|
var test = new DisplayCondition();
|
||||||
|
|
||||||
StartupArguments = Args.ToList();
|
StartupArguments = Args.ToList();
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Artemis.UI.Exceptions
|
namespace Artemis.UI.Exceptions
|
||||||
{
|
{
|
||||||
// ReSharper disable once InconsistentNaming
|
|
||||||
public class ArtemisUIException : Exception
|
public class ArtemisUIException : Exception
|
||||||
{
|
{
|
||||||
public ArtemisUIException()
|
public ArtemisUIException()
|
||||||
@ -1,9 +1,12 @@
|
|||||||
using Artemis.Core.Models.Profile;
|
using Artemis.Core.Models.Profile;
|
||||||
|
using Artemis.Core.Models.Profile.Conditions;
|
||||||
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
|
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
|
||||||
using Artemis.Core.Models.Surface;
|
using Artemis.Core.Models.Surface;
|
||||||
using Artemis.Core.Plugins.Abstract;
|
using Artemis.Core.Plugins.Abstract;
|
||||||
using Artemis.UI.Screens.Module;
|
using Artemis.UI.Screens.Module;
|
||||||
using Artemis.UI.Screens.Module.ProfileEditor;
|
using Artemis.UI.Screens.Module.ProfileEditor;
|
||||||
|
using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions;
|
||||||
|
using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions.Abstract;
|
||||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties;
|
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties;
|
||||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
|
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
|
||||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerEffects;
|
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerEffects;
|
||||||
@ -71,6 +74,12 @@ namespace Artemis.UI.Ninject.Factories
|
|||||||
SelectionToolViewModel SelectionToolViewModel(ProfileViewModel profileViewModel);
|
SelectionToolViewModel SelectionToolViewModel(ProfileViewModel profileViewModel);
|
||||||
SelectionRemoveToolViewModel SelectionRemoveToolViewModel(ProfileViewModel profileViewModel);
|
SelectionRemoveToolViewModel SelectionRemoveToolViewModel(ProfileViewModel profileViewModel);
|
||||||
}
|
}
|
||||||
|
public interface IDisplayConditionsVmFactory : IVmFactory
|
||||||
|
{
|
||||||
|
DisplayConditionGroupViewModel DisplayConditionGroupViewModel(DisplayConditionGroup displayConditionGroup, DisplayConditionViewModel parent);
|
||||||
|
DisplayConditionListPredicateViewModel DisplayConditionListPredicateViewModel(DisplayConditionListPredicate displayConditionListPredicate, DisplayConditionViewModel parent);
|
||||||
|
DisplayConditionPredicateViewModel DisplayConditionPredicateViewModel(DisplayConditionPredicate displayConditionPredicate, DisplayConditionViewModel parent);
|
||||||
|
}
|
||||||
|
|
||||||
public interface ILayerPropertyVmFactory : IVmFactory
|
public interface ILayerPropertyVmFactory : IVmFactory
|
||||||
{
|
{
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style x:Key="DisplayConditionButtonLeftClickMenu" TargetType="{x:Type Button}" BasedOn="{StaticResource DisplayConditionButton}">
|
<Style x:Key="DisplayConditionButtonLeftClickMenu" TargetType="{x:Type Button}" BasedOn="{StaticResource DisplayConditionButton}">
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
<EventTrigger RoutedEvent="Click">
|
<EventTrigger RoutedEvent="Click">
|
||||||
<EventTrigger.Actions>
|
<EventTrigger.Actions>
|
||||||
|
|||||||
@ -1,16 +1,28 @@
|
|||||||
using Stylet;
|
using Artemis.Core.Models.Profile.Conditions;
|
||||||
|
using Artemis.Core.Models.Profile.Conditions.Abstract;
|
||||||
|
using Stylet;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions.Abstract
|
namespace Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions.Abstract
|
||||||
{
|
{
|
||||||
public abstract class DisplayConditionViewModel : PropertyChangedBase
|
public abstract class DisplayConditionViewModel : PropertyChangedBase
|
||||||
{
|
{
|
||||||
protected DisplayConditionViewModel()
|
protected DisplayConditionViewModel(DisplayConditionPart model, DisplayConditionViewModel parent)
|
||||||
{
|
{
|
||||||
|
Model = model;
|
||||||
|
Parent = parent;
|
||||||
Children = new BindableCollection<DisplayConditionViewModel>();
|
Children = new BindableCollection<DisplayConditionViewModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DisplayConditionPart Model { get; }
|
||||||
|
public DisplayConditionViewModel Parent { get; set; }
|
||||||
public BindableCollection<DisplayConditionViewModel> Children { get; }
|
public BindableCollection<DisplayConditionViewModel> Children { get; }
|
||||||
|
|
||||||
public abstract void Update();
|
public abstract void Update();
|
||||||
|
|
||||||
|
public void Delete()
|
||||||
|
{
|
||||||
|
Model.Parent.RemoveChild(Model);
|
||||||
|
Parent.Update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -29,7 +29,8 @@
|
|||||||
Visibility="{Binding IsRootGroup, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}"
|
Visibility="{Binding IsRootGroup, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}"
|
||||||
Width="25"
|
Width="25"
|
||||||
Height="25"
|
Height="25"
|
||||||
Foreground="#E74C4C">
|
Foreground="#E74C4C"
|
||||||
|
Command="{s:Action Delete}">
|
||||||
<materialDesign:PackIcon Kind="Close" Width="18" Height="18" />
|
<materialDesign:PackIcon Kind="Close" Width="18" Height="18" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button Grid.Row="0"
|
<Button Grid.Row="0"
|
||||||
@ -37,25 +38,47 @@
|
|||||||
Style="{StaticResource DisplayConditionButtonLeftClickMenu}"
|
Style="{StaticResource DisplayConditionButtonLeftClickMenu}"
|
||||||
Background="#E74C4C"
|
Background="#E74C4C"
|
||||||
BorderBrush="#E74C4C"
|
BorderBrush="#E74C4C"
|
||||||
Margin="3 1">
|
Margin="3 1"
|
||||||
|
Content="{Binding SelectedBooleanOperator}">
|
||||||
<Button.ContextMenu>
|
<Button.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="And" />
|
<MenuItem Header="And" Command="{s:Action SelectBooleanOperator}" CommandParameter="And"/>
|
||||||
<MenuItem Header="Or" />
|
<MenuItem Header="Or" Command="{s:Action SelectBooleanOperator}" CommandParameter="Or"/>
|
||||||
<MenuItem Header="And not" />
|
<MenuItem Header="And not" Command="{s:Action SelectBooleanOperator}" CommandParameter="AndNot"/>
|
||||||
<MenuItem Header="Or not" />
|
<MenuItem Header="Or not" Command="{s:Action SelectBooleanOperator}" CommandParameter="OrNot"/>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</Button.ContextMenu>
|
</Button.ContextMenu>
|
||||||
Or
|
|
||||||
</Button>
|
</Button>
|
||||||
<Button Grid.Row="0"
|
<Button Grid.Row="0"
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
Style="{StaticResource MaterialDesignIconForegroundButton}"
|
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Foreground="#4CE758"
|
Foreground="#4CE758"
|
||||||
Width="25"
|
Width="25"
|
||||||
Height="25">
|
Height="25">
|
||||||
|
<Button.Style>
|
||||||
|
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignIconForegroundButton}">
|
||||||
|
<Style.Triggers>
|
||||||
|
<EventTrigger RoutedEvent="Click">
|
||||||
|
<EventTrigger.Actions>
|
||||||
|
<BeginStoryboard>
|
||||||
|
<Storyboard>
|
||||||
|
<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="ContextMenu.IsOpen">
|
||||||
|
<DiscreteBooleanKeyFrame KeyTime="0:0:0" Value="True"/>
|
||||||
|
</BooleanAnimationUsingKeyFrames>
|
||||||
|
</Storyboard>
|
||||||
|
</BeginStoryboard>
|
||||||
|
</EventTrigger.Actions>
|
||||||
|
</EventTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
<materialDesign:PackIcon Kind="Add" Width="18" Height="18" />
|
<materialDesign:PackIcon Kind="Add" Width="18" Height="18" />
|
||||||
|
<Button.ContextMenu>
|
||||||
|
<ContextMenu>
|
||||||
|
<MenuItem Header="Add condition" Command="{s:Action AddCondition}" />
|
||||||
|
<MenuItem Header="Add group" Command="{s:Action AddGroup}" />
|
||||||
|
</ContextMenu>
|
||||||
|
</Button.ContextMenu>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<ItemsControl Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" ItemsSource="{Binding Children}">
|
<ItemsControl Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" ItemsSource="{Binding Children}">
|
||||||
|
|||||||
@ -1,24 +1,80 @@
|
|||||||
using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions.Abstract;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using Artemis.Core.Models.Profile.Conditions;
|
||||||
|
using Artemis.UI.Ninject.Factories;
|
||||||
|
using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions.Abstract;
|
||||||
|
using Humanizer;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions
|
namespace Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions
|
||||||
{
|
{
|
||||||
public class DisplayConditionGroupViewModel : DisplayConditionViewModel
|
public class DisplayConditionGroupViewModel : DisplayConditionViewModel
|
||||||
{
|
{
|
||||||
|
private readonly IDisplayConditionsVmFactory _displayConditionsVmFactory;
|
||||||
private bool _isRootGroup;
|
private bool _isRootGroup;
|
||||||
|
|
||||||
|
public DisplayConditionGroupViewModel(DisplayConditionGroup displayConditionGroup, DisplayConditionViewModel parent, IDisplayConditionsVmFactory displayConditionsVmFactory) : base(displayConditionGroup, parent)
|
||||||
|
{
|
||||||
|
_displayConditionsVmFactory = displayConditionsVmFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DisplayConditionGroup DisplayConditionGroup => (DisplayConditionGroup) Model;
|
||||||
|
|
||||||
public bool IsRootGroup
|
public bool IsRootGroup
|
||||||
{
|
{
|
||||||
get => _isRootGroup;
|
get => _isRootGroup;
|
||||||
set => SetAndNotify(ref _isRootGroup, value);
|
set => SetAndNotify(ref _isRootGroup, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DisplayConditionGroupViewModel()
|
public string SelectedBooleanOperator => DisplayConditionGroup.BooleanOperator.Humanize();
|
||||||
|
|
||||||
|
public void SelectBooleanOperator(string type)
|
||||||
{
|
{
|
||||||
|
var enumValue = Enum.Parse<BooleanOperator>(type);
|
||||||
|
DisplayConditionGroup.BooleanOperator = enumValue;
|
||||||
|
NotifyOfPropertyChange(nameof(SelectedBooleanOperator));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddCondition()
|
||||||
|
{
|
||||||
|
DisplayConditionGroup.AddChild(new DisplayConditionPredicate());
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddGroup()
|
||||||
|
{
|
||||||
|
DisplayConditionGroup.AddChild(new DisplayConditionGroup());
|
||||||
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
NotifyOfPropertyChange(nameof(SelectedBooleanOperator));
|
||||||
|
|
||||||
|
// Remove VMs of effects no longer applied on the layer
|
||||||
|
var toRemove = Children.Where(c => !DisplayConditionGroup.Children.Contains(c.Model)).ToList();
|
||||||
|
Children.RemoveRange(toRemove);
|
||||||
|
|
||||||
|
foreach (var childModel in Model.Children)
|
||||||
|
{
|
||||||
|
if (Children.Any(c => c.Model == childModel))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch (childModel)
|
||||||
|
{
|
||||||
|
case DisplayConditionGroup displayConditionGroup:
|
||||||
|
Children.Add(_displayConditionsVmFactory.DisplayConditionGroupViewModel(displayConditionGroup, this));
|
||||||
|
break;
|
||||||
|
case DisplayConditionListPredicate displayConditionListPredicate:
|
||||||
|
Children.Add(_displayConditionsVmFactory.DisplayConditionListPredicateViewModel(displayConditionListPredicate, this));
|
||||||
|
break;
|
||||||
|
case DisplayConditionPredicate displayConditionPredicate:
|
||||||
|
Children.Add(_displayConditionsVmFactory.DisplayConditionPredicateViewModel(displayConditionPredicate, this));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var childViewModel in Children)
|
||||||
|
childViewModel.Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions.DisplayConditionListPredicateView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
|
d:DataContext="{d:DesignInstance Type=local:DisplayConditionListPredicateViewModel, IsDesignTimeCreatable=False}">
|
||||||
|
<Grid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
using Artemis.Core.Models.Profile.Conditions;
|
||||||
|
using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions.Abstract;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions
|
||||||
|
{
|
||||||
|
public class DisplayConditionListPredicateViewModel : DisplayConditionViewModel
|
||||||
|
{
|
||||||
|
public DisplayConditionListPredicateViewModel(DisplayConditionListPredicate displayConditionListPredicate, DisplayConditionViewModel parent) : base(displayConditionListPredicate, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public DisplayConditionListPredicate DisplayConditionListPredicate => (DisplayConditionListPredicate) Model;
|
||||||
|
|
||||||
|
public override void Update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,16 +1,28 @@
|
|||||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions.DisplayConditionPredicateView"
|
<UserControl
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions"
|
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions"
|
||||||
xmlns:s="https://github.com/canton7/Stylet"
|
xmlns:s="https://github.com/canton7/Stylet"
|
||||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
mc:Ignorable="d"
|
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||||
d:DesignHeight="450" d:DesignWidth="800"
|
xmlns:utilities="clr-namespace:Artemis.UI.Utilities"
|
||||||
d:DataContext="{d:DesignInstance Type=local:DisplayConditionPredicateViewModel, IsDesignTimeCreatable=False}">
|
x:Class="Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions.DisplayConditionPredicateView"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
|
d:DataContext="{d:DesignInstance IsDesignTimeCreatable=False, Type={x:Type local:DisplayConditionPredicateViewModel}}"
|
||||||
|
x:Name="DisplayConditionPredicateRoot">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<ResourceDictionary Source="pack://application:,,,/Artemis.UI;component/ResourceDictionaries/DisplayConditions.xaml" />
|
<ResourceDictionary>
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/Artemis.UI;component/ResourceDictionaries/DisplayConditions.xaml" />
|
||||||
|
<ResourceDictionary>
|
||||||
|
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
||||||
|
<utilities:BindingProxy x:Key="DataContextProxy" Data="{Binding}" />
|
||||||
|
</ResourceDictionary>
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
</ResourceDictionary>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Grid Margin="0 2">
|
<Grid Margin="0 2">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@ -25,60 +37,45 @@
|
|||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Foreground="#E74C4C"
|
Foreground="#E74C4C"
|
||||||
Width="25"
|
Width="25"
|
||||||
Height="25">
|
Height="25"
|
||||||
|
Command="{s:Action Delete}">
|
||||||
<materialDesign:PackIcon Kind="Close" Width="18" Height="18" />
|
<materialDesign:PackIcon Kind="Close" Width="18" Height="18" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button Grid.Row="0"
|
<Button Grid.Row="0"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Style="{StaticResource DisplayConditionButtonLeftClickMenu}"
|
|
||||||
Background="{DynamicResource SecondaryAccentBrush}"
|
Background="{DynamicResource SecondaryAccentBrush}"
|
||||||
BorderBrush="{DynamicResource SecondaryAccentBrush}">
|
BorderBrush="{DynamicResource SecondaryAccentBrush}"
|
||||||
|
Style="{StaticResource DisplayConditionButtonLeftClickMenu}">
|
||||||
<Button.ContextMenu>
|
<Button.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu ItemsSource="{Binding DataModel.Children}">
|
||||||
<MenuItem Header="Equals">
|
<ContextMenu.ItemContainerStyle>
|
||||||
<MenuItem.Icon>
|
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource MaterialDesignMenuItem}">
|
||||||
<materialDesign:PackIcon Kind="Equal" />
|
<Setter Property="ItemsSource" Value="{Binding Children}" />
|
||||||
</MenuItem.Icon>
|
<Setter Property="Header" Value="{Binding PropertyDescription.Name}" />
|
||||||
</MenuItem>
|
<Setter Property="ToolTip" Value="{Binding PropertyDescription.Description}" />
|
||||||
<MenuItem Header="Does not equal">
|
<Setter Property="Command" Value="{Binding Data.SelectPropertyCommand, Source={StaticResource DataContextProxy}}" />
|
||||||
<MenuItem.Icon>
|
<Setter Property="CommandParameter" Value="{Binding}" />
|
||||||
<materialDesign:PackIcon Kind="NotEqualVariant" />
|
<Setter Property="CommandTarget" Value="{Binding}" />
|
||||||
</MenuItem.Icon>
|
|
||||||
</MenuItem>
|
</Style>
|
||||||
<MenuItem Header="Contains">
|
</ContextMenu.ItemContainerStyle>
|
||||||
<MenuItem.Icon>
|
|
||||||
<materialDesign:PackIcon Kind="Contain" />
|
|
||||||
</MenuItem.Icon>
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem Header="Starts with">
|
|
||||||
<MenuItem.Icon>
|
|
||||||
<materialDesign:PackIcon Kind="ContainStart" />
|
|
||||||
</MenuItem.Icon>
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem Header="Ends with">
|
|
||||||
<MenuItem.Icon>
|
|
||||||
<materialDesign:PackIcon Kind="ContainEnd" />
|
|
||||||
</MenuItem.Icon>
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem Header="Does not contain">
|
|
||||||
<MenuItem.Icon>
|
|
||||||
<materialDesign:PackIcon Kind="FormatStrikethrough" />
|
|
||||||
</MenuItem.Icon>
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem Header="Is null">
|
|
||||||
<MenuItem.Icon>
|
|
||||||
<materialDesign:PackIcon Kind="Null" />
|
|
||||||
</MenuItem.Icon>
|
|
||||||
</MenuItem>
|
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</Button.ContextMenu>
|
</Button.ContextMenu>
|
||||||
Category
|
<Grid>
|
||||||
|
<TextBlock Text="{Binding SelectedLeftSideProperty.PropertyDescription.Name}"
|
||||||
|
ToolTip="{Binding SelectedLeftSideProperty.PropertyDescription.Description}"
|
||||||
|
Visibility="{Binding SelectedLeftSideProperty, Converter={StaticResource NullToVisibilityConverter}}" />
|
||||||
|
<TextBlock Text="« Select a property »"
|
||||||
|
FontStyle="Italic"
|
||||||
|
Visibility="{Binding SelectedLeftSideProperty, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=Inverted}" />
|
||||||
|
</Grid>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button Grid.Row="0"
|
<Button Grid.Row="0"
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
Style="{StaticResource DisplayConditionButtonLeftClickMenu}"
|
Style="{StaticResource DisplayConditionButtonLeftClickMenu}"
|
||||||
Background="#7B7B7B"
|
Background="#7B7B7B"
|
||||||
BorderBrush="#7B7B7B">
|
BorderBrush="#7B7B7B" Content="Equals">
|
||||||
<Button.ContextMenu>
|
<Button.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="Equals">
|
<MenuItem Header="Equals">
|
||||||
@ -118,14 +115,11 @@
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</Button.ContextMenu>
|
</Button.ContextMenu>
|
||||||
Equals
|
|
||||||
</Button>
|
</Button>
|
||||||
<Button Grid.Row="0"
|
<Button Grid.Row="0"
|
||||||
Grid.Column="3"
|
Grid.Column="3"
|
||||||
Style="{StaticResource DisplayConditionButton}"
|
Style="{StaticResource DisplayConditionButton}"
|
||||||
Background="{DynamicResource PrimaryHueMidBrush}"
|
Background="{DynamicResource PrimaryHueMidBrush}"
|
||||||
BorderBrush="{DynamicResource PrimaryHueMidBrush}">
|
BorderBrush="{DynamicResource PrimaryHueMidBrush}" Content="PredicateRightSide" />
|
||||||
Video Players
|
|
||||||
</Button>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -1,16 +1,86 @@
|
|||||||
using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions.Abstract;
|
using Artemis.Core.Models.Profile.Conditions;
|
||||||
|
using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions.Abstract;
|
||||||
|
using Artemis.UI.Shared.DataModelVisualization.Shared;
|
||||||
|
using Artemis.UI.Shared.Services;
|
||||||
|
using Artemis.UI.Shared.Services.Interfaces;
|
||||||
|
using Artemis.UI.Utilities;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions
|
namespace Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions
|
||||||
{
|
{
|
||||||
public class DisplayConditionPredicateViewModel : DisplayConditionViewModel
|
public class DisplayConditionPredicateViewModel : DisplayConditionViewModel
|
||||||
{
|
{
|
||||||
public DisplayConditionPredicateViewModel()
|
private readonly IDataModelVisualizationService _dataModelVisualizationService;
|
||||||
|
private readonly IProfileEditorService _profileEditorService;
|
||||||
|
private DataModelPropertiesViewModel _dataModel;
|
||||||
|
private DataModelVisualizationViewModel _selectedLeftSideProperty;
|
||||||
|
private bool _leftSidePropertySelectionOpen;
|
||||||
|
|
||||||
|
public DisplayConditionPredicateViewModel(DisplayConditionPredicate displayConditionPredicate, DisplayConditionViewModel parent,
|
||||||
|
IProfileEditorService profileEditorService, IDataModelVisualizationService dataModelVisualizationService) : base(displayConditionPredicate, parent)
|
||||||
{
|
{
|
||||||
|
_profileEditorService = profileEditorService;
|
||||||
|
_dataModelVisualizationService = dataModelVisualizationService;
|
||||||
|
|
||||||
|
SelectPropertyCommand = new DelegateCommand(ExecuteSelectProperty);
|
||||||
|
|
||||||
|
GetDataModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DelegateCommand SelectPropertyCommand { get; }
|
||||||
|
|
||||||
|
public DataModelPropertiesViewModel DataModel
|
||||||
|
{
|
||||||
|
get => _dataModel;
|
||||||
|
set => SetAndNotify(ref _dataModel, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataModelVisualizationViewModel SelectedLeftSideProperty
|
||||||
|
{
|
||||||
|
get => _selectedLeftSideProperty;
|
||||||
|
set => SetAndNotify(ref _selectedLeftSideProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool LeftSidePropertySelectionOpen
|
||||||
|
{
|
||||||
|
get => _leftSidePropertySelectionOpen;
|
||||||
|
set => SetAndNotify(ref _leftSidePropertySelectionOpen, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public DisplayConditionPredicate DisplayConditionPredicate => (DisplayConditionPredicate) Model;
|
||||||
|
|
||||||
|
public void ToggleLeftSidePropertySelectionOpen()
|
||||||
|
{
|
||||||
|
LeftSidePropertySelectionOpen = !LeftSidePropertySelectionOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetDataModel()
|
||||||
|
{
|
||||||
|
var mainDataModel = _dataModelVisualizationService.GetMainDataModelVisualization(true);
|
||||||
|
if (!_dataModelVisualizationService.GetPluginExtendsDataModel(_profileEditorService.GetCurrentModule()))
|
||||||
|
mainDataModel.Children.Add(_dataModelVisualizationService.GetPluginDataModelVisualization(_profileEditorService.GetCurrentModule(), true));
|
||||||
|
|
||||||
|
DataModel = mainDataModel;
|
||||||
|
|
||||||
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
if (DisplayConditionPredicate.PropertyPath != null)
|
||||||
|
SelectedLeftSideProperty = DataModel.GetChildByPath(DisplayConditionPredicate.DataModelGuid, DisplayConditionPredicate.PropertyPath);
|
||||||
|
else
|
||||||
|
SelectedLeftSideProperty = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteSelectProperty(object context)
|
||||||
|
{
|
||||||
|
if (!(context is DataModelVisualizationViewModel vm))
|
||||||
|
return;
|
||||||
|
|
||||||
|
DisplayConditionPredicate.PropertyPath = vm.GetCurrentPath();
|
||||||
|
DisplayConditionPredicate.DataModelGuid = vm.DataModel.PluginInfo.Guid;
|
||||||
|
Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,27 +1,49 @@
|
|||||||
using Stylet;
|
using System.Linq;
|
||||||
|
using Artemis.Core.Models.Profile;
|
||||||
|
using Artemis.Core.Models.Profile.Conditions;
|
||||||
|
using Artemis.UI.Ninject.Factories;
|
||||||
|
using Artemis.UI.Shared.DataModelVisualization.Shared;
|
||||||
|
using Artemis.UI.Shared.Events;
|
||||||
|
using Artemis.UI.Shared.Services;
|
||||||
|
using Artemis.UI.Shared.Services.Interfaces;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions
|
namespace Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions
|
||||||
{
|
{
|
||||||
public class DisplayConditionsViewModel : ProfileEditorPanelViewModel
|
public class DisplayConditionsViewModel : ProfileEditorPanelViewModel
|
||||||
{
|
{
|
||||||
|
private readonly IDisplayConditionsVmFactory _displayConditionsVmFactory;
|
||||||
|
private readonly IDataModelVisualizationService _dataModelVisualizationService;
|
||||||
private DisplayConditionGroupViewModel _rootGroup;
|
private DisplayConditionGroupViewModel _rootGroup;
|
||||||
|
|
||||||
|
public DisplayConditionsViewModel(IProfileEditorService profileEditorService, IDataModelVisualizationService dataModelVisualizationService,
|
||||||
|
IDisplayConditionsVmFactory displayConditionsVmFactory)
|
||||||
|
{
|
||||||
|
_dataModelVisualizationService = dataModelVisualizationService;
|
||||||
|
_displayConditionsVmFactory = displayConditionsVmFactory;
|
||||||
|
profileEditorService.ProfileElementSelected += ProfileEditorServiceOnProfileElementSelected;
|
||||||
|
}
|
||||||
|
|
||||||
public DisplayConditionGroupViewModel RootGroup
|
public DisplayConditionGroupViewModel RootGroup
|
||||||
{
|
{
|
||||||
get => _rootGroup;
|
get => _rootGroup;
|
||||||
set => SetAndNotify(ref _rootGroup, value);
|
set => SetAndNotify(ref _rootGroup, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DisplayConditionsViewModel()
|
private void ProfileEditorServiceOnProfileElementSelected(object sender, ProfileElementEventArgs e)
|
||||||
{
|
{
|
||||||
RootGroup = new DisplayConditionGroupViewModel {IsRootGroup = true};
|
_dataModelVisualizationService.BustCache();
|
||||||
var subGroup = new DisplayConditionGroupViewModel();
|
|
||||||
|
|
||||||
RootGroup.Children.Add(new DisplayConditionPredicateViewModel());
|
if (e.ProfileElement is Layer layer)
|
||||||
RootGroup.Children.Add(new DisplayConditionPredicateViewModel());
|
{
|
||||||
RootGroup.Children.Add(subGroup);
|
// Ensure the layer has a root display condition group
|
||||||
subGroup.Children.Add(new DisplayConditionPredicateViewModel());
|
if (layer.DisplayConditionGroup == null)
|
||||||
subGroup.Children.Add(new DisplayConditionPredicateViewModel());
|
layer.DisplayConditionGroup = new DisplayConditionGroup();
|
||||||
|
|
||||||
|
RootGroup = _displayConditionsVmFactory.DisplayConditionGroupViewModel(layer.DisplayConditionGroup, null);
|
||||||
|
RootGroup.IsRootGroup = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
RootGroup = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5,15 +5,11 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Settings.Debug.Tabs"
|
xmlns:local="clr-namespace:Artemis.UI.Screens.Settings.Debug.Tabs"
|
||||||
xmlns:s="https://github.com/canton7/Stylet"
|
xmlns:s="https://github.com/canton7/Stylet"
|
||||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
|
||||||
xmlns:wpf="http://materialdesigninxaml.net/winfx/xaml/themes"
|
xmlns:wpf="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
xmlns:plugins="clr-namespace:Artemis.Core.Plugins.Abstract;assembly=Artemis.Core"
|
xmlns:plugins="clr-namespace:Artemis.Core.Plugins.Abstract;assembly=Artemis.Core"
|
||||||
xmlns:dataModel="clr-namespace:Artemis.UI.Shared.DataModelVisualization.Shared;assembly=Artemis.UI.Shared"
|
xmlns:dataModel="clr-namespace:Artemis.UI.Shared.DataModelVisualization.Shared;assembly=Artemis.UI.Shared"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance local:DataModelDebugViewModel}">
|
d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance local:DataModelDebugViewModel}">
|
||||||
<UserControl.Resources>
|
|
||||||
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
|
||||||
</UserControl.Resources>
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
@ -29,18 +25,18 @@
|
|||||||
<ColumnDefinition Width="0.5*" />
|
<ColumnDefinition Width="0.5*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<!-- Property searching (nyi) -->
|
<!-- Property searching (nyi) -->
|
||||||
<wpf:PackIcon Grid.Column="0" Kind="Search" VerticalAlignment="Center"/>
|
<wpf:PackIcon Grid.Column="0" Kind="Search" VerticalAlignment="Center" />
|
||||||
<TextBox Grid.Column="1" wpf:HintAssist.Hint="Search property" VerticalAlignment="Center" Margin="5 0" IsEnabled="False"/>
|
<TextBox Grid.Column="1" wpf:HintAssist.Hint="Search property" VerticalAlignment="Center" Margin="5 0" IsEnabled="False" />
|
||||||
|
|
||||||
<!-- Module filtering -->
|
<!-- Module filtering -->
|
||||||
<TextBlock Grid.Column="3" VerticalAlignment="Center">Filter module</TextBlock>
|
<TextBlock Grid.Column="3" VerticalAlignment="Center">Filter module</TextBlock>
|
||||||
<ToggleButton Grid.Column="4"
|
<ToggleButton Grid.Column="4"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Margin="5 0"
|
Margin="5 0"
|
||||||
Style="{StaticResource MaterialDesignSwitchToggleButton}"
|
Style="{StaticResource MaterialDesignSwitchToggleButton}"
|
||||||
IsChecked="{Binding IsModuleFilterEnabled}" />
|
IsChecked="{Binding IsModuleFilterEnabled}" />
|
||||||
<ComboBox Grid.Column="5"
|
<ComboBox Grid.Column="5"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
wpf:HintAssist.Hint="Select a module"
|
wpf:HintAssist.Hint="Select a module"
|
||||||
IsEditable="True"
|
IsEditable="True"
|
||||||
TextSearch.TextPath="DisplayName"
|
TextSearch.TextPath="DisplayName"
|
||||||
@ -51,8 +47,8 @@
|
|||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel d:DataContext="{d:DesignInstance Type=plugins:Module}" Orientation="Horizontal">
|
<StackPanel d:DataContext="{d:DesignInstance Type=plugins:Module}" Orientation="Horizontal">
|
||||||
<wpf:PackIcon Kind="{Binding DisplayIcon}" VerticalAlignment="Center" Margin="0 0 5 0"/>
|
<wpf:PackIcon Kind="{Binding DisplayIcon}" VerticalAlignment="Center" Margin="0 0 5 0" />
|
||||||
<TextBlock Text="{Binding DisplayName}" VerticalAlignment="Center"></TextBlock>
|
<TextBlock Text="{Binding DisplayName}" VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ComboBox.ItemTemplate>
|
</ComboBox.ItemTemplate>
|
||||||
@ -60,24 +56,10 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
<TreeView Grid.Row="1" ItemsSource="{Binding MainDataModel.Children}" HorizontalContentAlignment="Stretch">
|
<TreeView Grid.Row="1" ItemsSource="{Binding MainDataModel.Children}" HorizontalContentAlignment="Stretch">
|
||||||
<TreeView.Resources>
|
<TreeView.Resources>
|
||||||
<HierarchicalDataTemplate DataType="{x:Type dataModel:DataModelViewModel}" ItemsSource="{Binding Children}">
|
<HierarchicalDataTemplate DataType="{x:Type dataModel:DataModelPropertiesViewModel}" ItemsSource="{Binding Children}">
|
||||||
<Grid>
|
<TextBlock Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" />
|
||||||
<TextBlock Text="{Binding PropertyDescription.Name}"
|
|
||||||
ToolTip="{Binding PropertyDescription.Description}"
|
|
||||||
Visibility="{Binding IsListProperty, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}" />
|
|
||||||
<Grid Visibility="{Binding IsListProperty, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
<ColumnDefinition Width="*" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<TextBlock Grid.Column="0" Margin="0 0 5 0" FontWeight="Bold">
|
|
||||||
<Run>[</Run><Run Text="{Binding PropertyType.Name, Mode=OneWay}" /><Run>]</Run>
|
|
||||||
</TextBlock>
|
|
||||||
<TextBlock Grid.Column="1" Text="{Binding ListDescription}" ToolTip="{Binding PropertyDescription.Description}" />
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</HierarchicalDataTemplate>
|
</HierarchicalDataTemplate>
|
||||||
<HierarchicalDataTemplate DataType="{x:Type dataModel:DataModelListViewModel}" ItemsSource="{Binding Children}">
|
<HierarchicalDataTemplate DataType="{x:Type dataModel:DataModelListViewModel}" ItemsSource="{Binding ListChildren}">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
@ -104,20 +86,13 @@
|
|||||||
|
|
||||||
<!-- Value description -->
|
<!-- Value description -->
|
||||||
<TextBlock Grid.Column="0" Margin="0 0 5 0" FontWeight="Bold">
|
<TextBlock Grid.Column="0" Margin="0 0 5 0" FontWeight="Bold">
|
||||||
<Run>[</Run><Run Text="{Binding PropertyType.Name, Mode=OneWay}" /><Run>]</Run>
|
<Run>[</Run><Run Text="{Binding PropertyInfo.PropertyType.Name, Mode=OneWay}" /><Run>]</Run>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<TextBlock Grid.Column="1"
|
<TextBlock Grid.Column="1" Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" />
|
||||||
Text="{Binding PropertyDescription.Name}"
|
|
||||||
ToolTip="{Binding PropertyDescription.Description}"
|
|
||||||
Visibility="{Binding IsListProperty, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}" />
|
|
||||||
<TextBlock Grid.Column="1"
|
|
||||||
Text="{Binding ListDescription}"
|
|
||||||
ToolTip="{Binding PropertyDescription.Description}"
|
|
||||||
Visibility="{Binding IsListProperty, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
|
||||||
|
|
||||||
<!-- Value display -->
|
<!-- Value display -->
|
||||||
<TextBlock Grid.Column="2"
|
<TextBlock Grid.Column="2"
|
||||||
Text="{Binding Model, Mode=OneWay}"
|
Text="{Binding DisplayValue, Mode=OneWay}"
|
||||||
FontFamily="Consolas"
|
FontFamily="Consolas"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Visibility="{Binding ShowToString, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
Visibility="{Binding ShowToString, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
||||||
@ -127,13 +102,51 @@
|
|||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}"
|
Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}"
|
||||||
Visibility="{Binding ShowNull, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
Visibility="{Binding ShowNull, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
||||||
<ContentControl Grid.Column="2"
|
<ContentControl Grid.Column="2"
|
||||||
s:View.Model="{Binding DisplayViewModel}"
|
s:View.Model="{Binding DisplayViewModel}"
|
||||||
FontFamily="Consolas"
|
FontFamily="Consolas"
|
||||||
Visibility="{Binding ShowViewModel, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"/>
|
Visibility="{Binding ShowViewModel, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</HierarchicalDataTemplate>
|
</HierarchicalDataTemplate>
|
||||||
|
<HierarchicalDataTemplate DataType="{x:Type dataModel:DataModelListPropertyViewModel}">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<!-- Value description -->
|
||||||
|
<TextBlock Grid.Column="0" Margin="0 0 5 0" FontWeight="Bold">
|
||||||
|
<Run>[</Run><Run Text="{Binding ListType.Name, Mode=OneWay}" /><Run>]</Run>
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Grid.Column="1" ToolTip="{Binding PropertyDescription.Description}">
|
||||||
|
<Run>List item [</Run><Run Text="{Binding Index, Mode=OneWay}" /><Run>]</Run>
|
||||||
|
</TextBlock>
|
||||||
|
|
||||||
|
<!-- Value display -->
|
||||||
|
<TextBlock Grid.Column="2"
|
||||||
|
Text="{Binding DisplayValue, Mode=OneWay}"
|
||||||
|
FontFamily="Consolas"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Visibility="{Binding ShowToString, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
||||||
|
<TextBlock Grid.Column="2"
|
||||||
|
Text="null"
|
||||||
|
FontFamily="Consolas"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}"
|
||||||
|
Visibility="{Binding ShowNull, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
||||||
|
<ContentControl Grid.Column="2"
|
||||||
|
s:View.Model="{Binding DisplayViewModel}"
|
||||||
|
FontFamily="Consolas"
|
||||||
|
Visibility="{Binding ShowViewModel, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
||||||
|
</Grid>
|
||||||
|
</HierarchicalDataTemplate>
|
||||||
|
<HierarchicalDataTemplate DataType="{x:Type dataModel:DataModelListPropertiesViewModel}" ItemsSource="{Binding Children}">
|
||||||
|
<TextBlock>
|
||||||
|
<Run>List item [</Run><Run Text="{Binding Index, Mode=OneWay}" /><Run>]</Run>
|
||||||
|
</TextBlock>
|
||||||
|
</HierarchicalDataTemplate>
|
||||||
</TreeView.Resources>
|
</TreeView.Resources>
|
||||||
</TreeView>
|
</TreeView>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@ -17,7 +17,7 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
|||||||
private readonly Timer _updateTimer;
|
private readonly Timer _updateTimer;
|
||||||
private bool _isModuleFilterEnabled;
|
private bool _isModuleFilterEnabled;
|
||||||
private Core.Plugins.Abstract.Module _selectedModule;
|
private Core.Plugins.Abstract.Module _selectedModule;
|
||||||
private DataModelViewModel _mainDataModel;
|
private DataModelPropertiesViewModel _mainDataModel;
|
||||||
private string _propertySearch;
|
private string _propertySearch;
|
||||||
private List<Core.Plugins.Abstract.Module> _modules;
|
private List<Core.Plugins.Abstract.Module> _modules;
|
||||||
|
|
||||||
@ -26,12 +26,12 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
|||||||
_dataModelVisualizationService = dataModelVisualizationService;
|
_dataModelVisualizationService = dataModelVisualizationService;
|
||||||
_pluginService = pluginService;
|
_pluginService = pluginService;
|
||||||
_updateTimer = new Timer(500);
|
_updateTimer = new Timer(500);
|
||||||
_updateTimer.Elapsed += (sender, args) => MainDataModel.Update();
|
_updateTimer.Elapsed += (sender, args) => MainDataModel.Update(_dataModelVisualizationService);
|
||||||
|
|
||||||
DisplayName = "Data model";
|
DisplayName = "Data model";
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataModelViewModel MainDataModel
|
public DataModelPropertiesViewModel MainDataModel
|
||||||
{
|
{
|
||||||
get => _mainDataModel;
|
get => _mainDataModel;
|
||||||
set => SetAndNotify(ref _mainDataModel, value);
|
set => SetAndNotify(ref _mainDataModel, value);
|
||||||
@ -93,8 +93,8 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs
|
|||||||
private void GetDataModel()
|
private void GetDataModel()
|
||||||
{
|
{
|
||||||
MainDataModel = SelectedModule != null
|
MainDataModel = SelectedModule != null
|
||||||
? _dataModelVisualizationService.GetPluginDataModelVisualization(SelectedModule)
|
? _dataModelVisualizationService.GetPluginDataModelVisualization(SelectedModule, false)
|
||||||
: _dataModelVisualizationService.GetMainDataModelVisualization();
|
: _dataModelVisualizationService.GetMainDataModelVisualization(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PluginServiceOnPluginToggled(object? sender, PluginEventArgs e)
|
private void PluginServiceOnPluginToggled(object? sender, PluginEventArgs e)
|
||||||
|
|||||||
26
src/Artemis.UI/Utilities/BindingProxy.cs
Normal file
26
src/Artemis.UI/Utilities/BindingProxy.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Utilities
|
||||||
|
{
|
||||||
|
public class BindingProxy : Freezable
|
||||||
|
{
|
||||||
|
// Using a DependencyProperty as the backing store for Data. This enables animation, styling, binding, etc...
|
||||||
|
public static readonly DependencyProperty DataProperty =
|
||||||
|
DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));
|
||||||
|
|
||||||
|
public object Data
|
||||||
|
{
|
||||||
|
get => GetValue(DataProperty);
|
||||||
|
set => SetValue(DataProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Overrides of Freezable
|
||||||
|
|
||||||
|
protected override Freezable CreateInstanceCore()
|
||||||
|
{
|
||||||
|
return new BindingProxy();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
41
src/Artemis.UI/Utilities/DelegateCommand.cs
Normal file
41
src/Artemis.UI/Utilities/DelegateCommand.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Utilities
|
||||||
|
{
|
||||||
|
public class DelegateCommand : ICommand
|
||||||
|
{
|
||||||
|
private readonly Predicate<object> _canExecute;
|
||||||
|
private readonly Action<object> _execute;
|
||||||
|
|
||||||
|
public DelegateCommand(Action<object> execute) : this(execute, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public DelegateCommand(Action<object> execute, Predicate<object> canExecute)
|
||||||
|
{
|
||||||
|
_execute = execute;
|
||||||
|
_canExecute = canExecute;
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler CanExecuteChanged;
|
||||||
|
|
||||||
|
public bool CanExecute(object parameter)
|
||||||
|
{
|
||||||
|
if (_canExecute == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return _canExecute(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Execute(object parameter)
|
||||||
|
{
|
||||||
|
_execute(parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RaiseCanExecuteChanged()
|
||||||
|
{
|
||||||
|
CanExecuteChanged?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user