mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Profile editor - Redesigned adding/removing timeline segments
General module - Added some basic window information to the data model Profiles - Don't render when opacity is 0 Profile editor - Render non-selected layers in their main segment Profile editor - Condition editor fixes
This commit is contained in:
1 parent
732ee2f429
commit
64a1010100
39 files changed
+831
-261
No files matched your search
+63
-7
@@ -15,9 +15,11 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
{
|
||||
public abstract class DataModelVisualizationViewModel : PropertyChangedBase
|
||||
{
|
||||
private const int MaxDepth = 4;
|
||||
private BindableCollection<DataModelVisualizationViewModel> _children;
|
||||
private DataModel _dataModel;
|
||||
private bool _isMatchingFilteredTypes;
|
||||
private bool _isVisualizationExpanded;
|
||||
private DataModelVisualizationViewModel _parent;
|
||||
private DataModelPropertyAttribute _propertyDescription;
|
||||
private PropertyInfo _propertyInfo;
|
||||
@@ -37,6 +39,7 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
}
|
||||
|
||||
public bool IsRootViewModel { get; }
|
||||
public int Depth { get; set; }
|
||||
|
||||
public DataModel DataModel
|
||||
{
|
||||
@@ -74,6 +77,16 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
set => SetAndNotify(ref _isMatchingFilteredTypes, value);
|
||||
}
|
||||
|
||||
public bool IsVisualizationExpanded
|
||||
{
|
||||
get => _isVisualizationExpanded;
|
||||
set
|
||||
{
|
||||
if (!SetAndNotify(ref _isVisualizationExpanded, value)) return;
|
||||
RequestUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public string PropertyPath
|
||||
{
|
||||
get
|
||||
@@ -104,11 +117,26 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the datamodel and if in an parent, any children
|
||||
/// </summary>
|
||||
/// <param name="dataModelVisualizationService"></param>
|
||||
public abstract void Update(IDataModelVisualizationService dataModelVisualizationService);
|
||||
|
||||
public virtual object GetCurrentValue()
|
||||
{
|
||||
return Parent == null ? null : PropertyInfo.GetValue(Parent.GetCurrentValue());
|
||||
try
|
||||
{
|
||||
if (PropertyInfo.GetGetMethod() == null)
|
||||
return null;
|
||||
|
||||
return Parent == null ? null : PropertyInfo.GetValue(Parent.GetCurrentValue());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored, who knows what kind of shit can go wrong here...
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyTypeFilter(bool looseMatch, params Type[] filteredTypes)
|
||||
@@ -157,6 +185,7 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
{
|
||||
if (predicate.LeftDataModel == null || predicate.LeftPropertyPath == null)
|
||||
return null;
|
||||
|
||||
return GetChildByPath(predicate.LeftDataModel.PluginInfo.Guid, predicate.LeftPropertyPath);
|
||||
}
|
||||
|
||||
@@ -167,6 +196,14 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
|
||||
public DataModelVisualizationViewModel GetChildByPath(Guid dataModelGuid, string propertyPath)
|
||||
{
|
||||
// Ensure children are populated by requesting an update
|
||||
if (!IsVisualizationExpanded)
|
||||
{
|
||||
IsVisualizationExpanded = true;
|
||||
RequestUpdate();
|
||||
IsVisualizationExpanded = false;
|
||||
}
|
||||
|
||||
var path = propertyPath.Split(".");
|
||||
var currentPart = path.First();
|
||||
|
||||
@@ -187,8 +224,10 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
}
|
||||
}
|
||||
|
||||
protected DataModelVisualizationViewModel CreateChild(IDataModelVisualizationService dataModelVisualizationService, PropertyInfo propertyInfo)
|
||||
protected DataModelVisualizationViewModel CreateChild(IDataModelVisualizationService dataModelVisualizationService, PropertyInfo propertyInfo, int depth)
|
||||
{
|
||||
if (depth > MaxDepth)
|
||||
return null;
|
||||
// Skip properties decorated with DataModelIgnore
|
||||
if (Attribute.IsDefined(propertyInfo, typeof(DataModelIgnoreAttribute)))
|
||||
return null;
|
||||
@@ -196,19 +235,36 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
// If a display VM was found, prefer to use that in any case
|
||||
var typeViewModel = dataModelVisualizationService.GetDataModelDisplayViewModel(propertyInfo.PropertyType);
|
||||
if (typeViewModel != null)
|
||||
return new DataModelPropertyViewModel(DataModel, this, propertyInfo) {DisplayViewModel = typeViewModel};
|
||||
return new DataModelPropertyViewModel(DataModel, this, propertyInfo) {DisplayViewModel = typeViewModel, Depth = depth};
|
||||
// For primitives, create a property view model, it may be null that is fine
|
||||
if (propertyInfo.PropertyType.IsPrimitive || propertyInfo.PropertyType == typeof(string))
|
||||
return new DataModelPropertyViewModel(DataModel, this, propertyInfo);
|
||||
return new DataModelPropertyViewModel(DataModel, this, propertyInfo) {Depth = depth};
|
||||
if (typeof(IList).IsAssignableFrom(propertyInfo.PropertyType))
|
||||
return new DataModelListViewModel(DataModel, this, propertyInfo);
|
||||
return new DataModelListViewModel(DataModel, this, propertyInfo) {Depth = depth};
|
||||
// For other value types create a child view model
|
||||
if (propertyInfo.PropertyType.IsClass || propertyInfo.PropertyType.IsStruct())
|
||||
return new DataModelPropertiesViewModel(DataModel, this, propertyInfo);
|
||||
return new DataModelPropertiesViewModel(DataModel, this, propertyInfo) {Depth = depth};
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
public event EventHandler UpdateRequested;
|
||||
|
||||
protected virtual void OnUpdateRequested()
|
||||
{
|
||||
UpdateRequested?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void RequestUpdate()
|
||||
{
|
||||
Parent?.RequestUpdate();
|
||||
OnUpdateRequested();
|
||||
}
|
||||
|
||||
private void GetDescription()
|
||||
{
|
||||
// If this is the first child of a root view model, use the data model description
|
||||
@@ -218,7 +274,7 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
else if (PropertyInfo != null)
|
||||
{
|
||||
PropertyDescription = (DataModelPropertyAttribute) Attribute.GetCustomAttribute(PropertyInfo, typeof(DataModelPropertyAttribute)) ??
|
||||
new DataModelPropertyAttribute {Name = PropertyInfo.Name.Humanize()};
|
||||
new DataModelPropertyAttribute {Name = PropertyInfo.Name.Humanize(), ResetsDepth = false};
|
||||
}
|
||||
else
|
||||
throw new ArtemisSharedUIException("Failed to get property description because plugin info is null but the parent has a datamodel");
|
||||
|
||||
Reference in new issue
Block a user