mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Data model visualization - Moved services and VMs to UI.Shared
Data model visualization - Added support for custom display VMs Data model visualization - Added framework for custom input VMs Shared UI - Made internal converters public
This commit is contained in:
1 parent
addb06c348
commit
448d94915c
30 files changed
+537
-129
No files matched your search
@@ -0,0 +1,79 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
{
|
||||
public class DataModelListViewModel : DataModelVisualizationViewModel
|
||||
{
|
||||
private readonly IDataModelVisualizationService _dataModelVisualizationService;
|
||||
private BindableCollection<DataModelVisualizationViewModel> _children;
|
||||
private string _count;
|
||||
private IList _list;
|
||||
|
||||
internal DataModelListViewModel(PropertyInfo propertyInfo, DataModelPropertyAttribute propertyDescription, DataModelVisualizationViewModel parent,
|
||||
IDataModelVisualizationService dataModelVisualizationService)
|
||||
{
|
||||
_dataModelVisualizationService = dataModelVisualizationService;
|
||||
PropertyInfo = propertyInfo;
|
||||
Parent = parent;
|
||||
PropertyDescription = propertyDescription;
|
||||
Children = new BindableCollection<DataModelVisualizationViewModel>();
|
||||
}
|
||||
|
||||
public BindableCollection<DataModelVisualizationViewModel> Children
|
||||
{
|
||||
get => _children;
|
||||
set => SetAndNotify(ref _children, value);
|
||||
}
|
||||
|
||||
public IList List
|
||||
{
|
||||
get => _list;
|
||||
set => SetAndNotify(ref _list, value);
|
||||
}
|
||||
|
||||
public string Count
|
||||
{
|
||||
get => _count;
|
||||
set => SetAndNotify(ref _count, value);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (PropertyInfo != null && Parent?.Model != null && PropertyInfo.GetValue(Parent.Model) is IList listValue)
|
||||
{
|
||||
Model = new List<object>(listValue.Cast<object>());
|
||||
List = (IList) Model;
|
||||
}
|
||||
|
||||
var index = 0;
|
||||
foreach (var item in List)
|
||||
{
|
||||
DataModelVisualizationViewModel child;
|
||||
if (Children.Count <= index)
|
||||
{
|
||||
child = CreateChild(_dataModelVisualizationService, item);
|
||||
Children.Add(child);
|
||||
}
|
||||
else
|
||||
{
|
||||
child = Children[index];
|
||||
child.Model = item;
|
||||
}
|
||||
|
||||
child.Update();
|
||||
index++;
|
||||
}
|
||||
|
||||
while (Children.Count > List.Count)
|
||||
Children.RemoveAt(Children.Count - 1);
|
||||
|
||||
Count = $"{Children.Count} {(Children.Count == 1 ? "item" : "items")}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user