Display conditions - Implemented lists in the core, UI needs more work

This commit is contained in:
Robert committed 2020-08-12 23:32:30 +02:00
1 parent ae708fa26a
commit f2f77da953
13 files changed
+288 -84

No files matched your search

@@ -34,6 +34,10 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
set => SetAndNotify(ref _displayValue, value);
}
public override string PropertyPath => Parent?.PropertyPath;
public override string DisplayPropertyPath => Parent?.DisplayPropertyPath;
public override void Update(IDataModelVisualizationService dataModelVisualizationService)
{
// Display value gets updated by parent, don't do anything if it is null
@@ -3,7 +3,6 @@ using System.Collections;
using System.Reflection;
using Artemis.Core.Extensions;
using Artemis.Core.Plugins.Abstract.DataModels;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
using Artemis.UI.Shared.Services;
using Stylet;
@@ -26,12 +25,6 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
set => SetAndNotify(ref _list, value);
}
public DataModelVisualizationViewModel ListTypePropertyViewModel
{
get => _listTypePropertyViewModel;
set => SetAndNotify(ref _listTypePropertyViewModel, value);
}
public BindableCollection<DataModelVisualizationViewModel> ListChildren { get; set; }
public string Count
@@ -40,6 +33,30 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
set => SetAndNotify(ref _count, value);
}
public DataModelPropertiesViewModel GetListTypeViewModel(IDataModelVisualizationService dataModelVisualizationService)
{
// Create a property VM describing the type of the list
var viewModel = CreateListChild(dataModelVisualizationService, List.GetType().GenericTypeArguments[0]);
// Put an empty value into the list type property view model
if (viewModel is DataModelListPropertiesViewModel dataModelListClassViewModel)
{
dataModelListClassViewModel.DisplayValue = Activator.CreateInstance(dataModelListClassViewModel.ListType);
dataModelListClassViewModel.Update(dataModelVisualizationService);
return dataModelListClassViewModel;
}
if (viewModel is DataModelListPropertyViewModel dataModelListPropertyViewModel)
{
dataModelListPropertyViewModel.DisplayValue = Activator.CreateInstance(dataModelListPropertyViewModel.ListType);
var wrapper = new DataModelPropertiesViewModel(null,null,null);
wrapper.Children.Add(dataModelListPropertyViewModel);
return wrapper;
}
return null;
}
public override void Update(IDataModelVisualizationService dataModelVisualizationService)
{
if (Parent != null && !Parent.IsVisualizationExpanded)
@@ -49,20 +66,6 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
if (List == null)
return;
if (ListTypePropertyViewModel == null)
{
// Create a property VM describing the type of the list
ListTypePropertyViewModel = CreateListChild(dataModelVisualizationService, List.GetType().GenericTypeArguments[0]);
// Put an empty value into the list type property view model
if (ListTypePropertyViewModel is DataModelListPropertiesViewModel dataModelListClassViewModel)
dataModelListClassViewModel.DisplayValue = Activator.CreateInstance(dataModelListClassViewModel.ListType);
else if (ListTypePropertyViewModel is DataModelListPropertyViewModel dataModelListPropertyViewModel)
dataModelListPropertyViewModel.DisplayValue = Activator.CreateInstance(dataModelListPropertyViewModel.ListType);
ListTypePropertyViewModel.Update(dataModelVisualizationService);
}
var index = 0;
foreach (var item in List)
{
@@ -1,12 +1,11 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Windows.Documents;
using Artemis.Core.Extensions;
using Artemis.Core.Models.Profile.Conditions;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Abstract.DataModels;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
using Artemis.UI.Shared.Exceptions;
@@ -26,7 +25,6 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
private DataModelVisualizationViewModel _parent;
private DataModelPropertyAttribute _propertyDescription;
private PropertyInfo _propertyInfo;
private bool _isIgnored;
internal DataModelVisualizationViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, PropertyInfo propertyInfo)
{
@@ -91,7 +89,7 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
}
}
public string PropertyPath
public virtual string PropertyPath
{
get
{
@@ -106,7 +104,7 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
}
}
public string DisplayPropertyPath
public virtual string DisplayPropertyPath
{
get
{
@@ -176,7 +174,7 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
IsMatchingFilteredTypes = false;
return;
}
if (looseMatch)
IsMatchingFilteredTypes = filteredTypes.Any(t => t.IsCastableFrom(PropertyInfo.PropertyType));
else
@@ -213,12 +211,14 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
if (IsRootViewModel)
{
var child = Children.FirstOrDefault(c => c.DataModel.PluginInfo.Guid == dataModelGuid);
var child = Children.FirstOrDefault(c => c.DataModel != null &&
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);
var child = Children.FirstOrDefault(c => c.DataModel != null &&
c.DataModel.PluginInfo.Guid == dataModelGuid && c.PropertyInfo?.Name == currentPart);
if (child == null)
return null;