mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Display conditions - List predicates WIP
This commit is contained in:
1 parent
6803bc5a37
commit
cd02a422fe
14 files changed
+162
-95
No files matched your search
@@ -13,6 +13,7 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
{
|
||||
private string _count;
|
||||
private IList _list;
|
||||
private DataModelVisualizationViewModel _listTypePropertyViewModel;
|
||||
|
||||
internal DataModelListViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, PropertyInfo propertyInfo) : base(dataModel, parent, propertyInfo)
|
||||
{
|
||||
@@ -25,6 +26,12 @@ 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
|
||||
@@ -42,6 +49,20 @@ 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)
|
||||
{
|
||||
@@ -83,10 +104,10 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
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);
|
||||
return new DataModelListPropertyViewModel(DataModel, this, PropertyInfo) {ListType = listType};
|
||||
// For other value types create a child view model
|
||||
if (listType.IsClass || listType.IsStruct())
|
||||
return new DataModelListPropertiesViewModel(DataModel, this, PropertyInfo);
|
||||
return new DataModelListPropertiesViewModel(DataModel, this, PropertyInfo) {ListType = listType};
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
Parent = parent;
|
||||
Children = new BindableCollection<DataModelVisualizationViewModel>();
|
||||
IsMatchingFilteredTypes = true;
|
||||
|
||||
|
||||
if (dataModel == null && parent == null && propertyInfo == null)
|
||||
IsRootViewModel = true;
|
||||
else
|
||||
@@ -176,7 +176,7 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
IsMatchingFilteredTypes = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (looseMatch)
|
||||
IsMatchingFilteredTypes = filteredTypes.Any(t => t.IsCastableFrom(PropertyInfo.PropertyType));
|
||||
else
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Artemis.Core.Plugins.Abstract.DataModels;
|
||||
|
||||
namespace Artemis.UI.Shared.Services.DataModelVisualization
|
||||
{
|
||||
public class ListDataModelWrapper : DataModel
|
||||
{
|
||||
public ListDataModelWrapper()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Extensions;
|
||||
@@ -9,6 +10,7 @@ using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.Shared.DataModelVisualization;
|
||||
using Artemis.UI.Shared.DataModelVisualization.Shared;
|
||||
using Artemis.UI.Shared.Services.DataModelVisualization;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
@@ -61,6 +63,17 @@ namespace Artemis.UI.Shared.Services
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
// public DataModelPropertiesViewModel GetListDataModelVisualization(IList list)
|
||||
// {
|
||||
// var viewModel = new DataModelPropertiesViewModel(null, null, null);
|
||||
// viewModel.Children.Add(new DataModelListPropertiesViewModel(null, viewModel, null) {DisplayValue = list});
|
||||
//
|
||||
// // Update to populate children
|
||||
// viewModel.Update(this);
|
||||
// viewModel.UpdateRequested += (sender, args) => viewModel.Update(this);
|
||||
// return viewModel;
|
||||
// }
|
||||
|
||||
public bool GetPluginExtendsDataModel(Plugin plugin)
|
||||
{
|
||||
return _dataModelService.GetPluginExtendsDataModel(plugin);
|
||||
|
||||
Reference in new issue
Block a user