1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00
Artemis/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListPropertiesViewModel.cs
Robert 3fcfe4ceec Data model paths - Added support for lists
Data model paths - Added deferred compilation to accessors
Data models - Fixed property name being empty sometimes
Plugins - Fixed disabling plugins that failed to load
2020-10-05 19:52:22 +02:00

63 lines
1.7 KiB
C#

using System;
using Artemis.Core.DataModelExpansions;
using Artemis.UI.Shared.Services;
namespace Artemis.UI.Shared
{
public class DataModelListPropertiesViewModel : DataModelPropertiesViewModel
{
private object _displayValue;
private int _index;
private Type _listType;
public DataModelListPropertiesViewModel(DataModel dataModel, object listItem) : base(null, null, null)
{
DataModel = dataModel;
ListType = listItem.GetType();
DisplayValue = listItem;
}
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 string DisplayPath => null;
public override void Update(IDataModelUIService dataModelUIService)
{
// Display value gets updated by parent, don't do anything if it is null
if (DisplayValue == null)
return;
ListType = DisplayValue.GetType();
PopulateProperties(dataModelUIService, DisplayValue);
foreach (var dataModelVisualizationViewModel in Children)
dataModelVisualizationViewModel.Update(dataModelUIService);
}
public override object GetCurrentValue()
{
return DisplayValue;
}
/// <inheritdoc />
public override string ToString()
{
return $"[List item {Index}] {DisplayPath ?? Path}";
}
}
}