mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Data model visualization - Simplified and improved VMs
Layer conditions - Added left side property selection
This commit is contained in:
1 parent
f9d26a8ba3
commit
c0f2cf08de
38 files changed
+908
-359
No files matched your search
+67
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user