Datamodels - A few small fixes to fix errors during startup

Layer properties - Reimplemented property tree
Stylet - Add support for binding views to generic VMs
This commit is contained in:
SpoinkyNL committed 2020-05-17 18:54:15 +02:00
1 parent e036cbbfe4
commit 7b238e241e
22 files changed
+207 -42

No files matched your search

+2 -2
View File
@@ -125,7 +125,7 @@ namespace Artemis.Core.Models.Profile
General.ApplyToEntity();
Transform.ApplyToEntity();
LayerBrush.BaseProperties.ApplyToEntity();
LayerBrush?.BaseProperties.ApplyToEntity();
// LEDs
LayerEntity.Leds.Clear();
@@ -212,7 +212,7 @@ namespace Artemis.Core.Models.Profile
{
General.Override(timeOverride);
Transform.Override(timeOverride);
LayerBrush.BaseProperties.Override(timeOverride);
LayerBrush?.BaseProperties.Override(timeOverride);
}
/// <inheritdoc />
@@ -13,6 +13,11 @@ namespace Artemis.Core.Models.Profile.LayerProperties
{
}
/// <summary>
/// The parent group of this layer property, set after construction
/// </summary>
public LayerPropertyGroup Parent { get; internal set; }
/// <summary>
/// Gets whether keyframes are supported on this property
/// </summary>
@@ -23,6 +23,11 @@ namespace Artemis.Core.Models.Profile
_layerPropertyGroups = new List<LayerPropertyGroup>();
}
/// <summary>
/// The parent group of this layer property group, set after construction
/// </summary>
public LayerPropertyGroup Parent { get; internal set; }
/// <summary>
/// Gets whether this property group's properties are all initialized
/// </summary>
@@ -67,10 +72,11 @@ namespace Artemis.Core.Models.Profile
var propertyDescription = Attribute.GetCustomAttribute(propertyInfo, typeof(PropertyDescriptionAttribute));
if (propertyDescription != null)
{
if (!typeof(LayerProperty<>).IsAssignableFrom(propertyInfo.PropertyType))
if (!typeof(BaseLayerProperty).IsAssignableFrom(propertyInfo.PropertyType))
throw new ArtemisPluginException("Layer property with PropertyDescription attribute must be of type LayerProperty");
var instance = (BaseLayerProperty) Activator.CreateInstance(propertyInfo.PropertyType);
var instance = (BaseLayerProperty) Activator.CreateInstance(propertyInfo.PropertyType, true);
instance.Parent = this;
InitializeProperty(layer, path, instance);
propertyInfo.SetValue(this, instance);
_layerProperties.Add(instance);
@@ -84,6 +90,7 @@ namespace Artemis.Core.Models.Profile
throw new ArtemisPluginException("Layer property with PropertyGroupDescription attribute must be of type LayerPropertyGroup");
var instance = (LayerPropertyGroup) Activator.CreateInstance(propertyInfo.PropertyType);
instance.Parent = this;
instance.InitializeProperties(layerService, layer, $"{path}{propertyInfo.Name}.");
propertyInfo.SetValue(this, instance);
_layerPropertyGroups.Add(instance);
@@ -50,7 +50,7 @@ namespace Artemis.Core.Plugins.Abstract.DataModels
continue;
// If the a nested datamodel, ensure the properties on there are valid
if (propertyInfo.PropertyType == typeof(DataModel))
if (typeof(DataModel).IsAssignableFrom(propertyInfo.PropertyType))
ValidateType(propertyInfo.PropertyType);
else if (!SupportedTypes.Contains(propertyInfo.PropertyType))
{
+1 -1
View File
@@ -40,7 +40,7 @@ namespace Artemis.Core.Services
{
RemoveLayerBrush(layer);
var descriptorReference = layer.General.BrushReference.CurrentValue;
var descriptorReference = layer.General.BrushReference?.CurrentValue;
if (descriptorReference == null)
return null;
@@ -93,6 +93,7 @@ namespace Artemis.Core.Services.Storage
module.ChangeActiveProfile(profile, _surfaceService.ActiveSurface);
if (profile != null)
{
InitializeCoreProperties(profile);
InstantiateProfileLayerBrushes(profile);
}
}
@@ -158,6 +159,17 @@ namespace Artemis.Core.Services.Storage
_logger.Debug("Redo profile update - Success");
}
private void InitializeCoreProperties(Profile profile)
{
foreach (var layer in profile.GetAllLayers().Where(l => l.LayerBrush == null))
{
if (!layer.General.PropertiesInitialized)
layer.General.InitializeProperties(_layerService, layer, null);
if (!layer.Transform.PropertiesInitialized)
layer.Transform.InitializeProperties(_layerService, layer, null);
};
}
private void InstantiateProfileLayerBrushes(Profile profile)
{
// Only instantiate brushes for layers without an existing brush instance