mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Profiles - Only load nodes after the entire profile structure loaded
Profiles - Added API to get all render elements Nodes - Added layer property node
This commit is contained in:
1 parent
836e979991
commit
a4667fdc03
11 files changed
+317
-57
No files matched your search
+80
@@ -0,0 +1,80 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
||||
{
|
||||
public class LayerPropertyNodeCustomViewModel : CustomNodeViewModel
|
||||
{
|
||||
private readonly LayerPropertyNode _node;
|
||||
|
||||
private RenderProfileElement _selectedProfileElement;
|
||||
private ILayerProperty _selectedLayerProperty;
|
||||
|
||||
public LayerPropertyNodeCustomViewModel(LayerPropertyNode node) : base(node)
|
||||
{
|
||||
_node = node;
|
||||
}
|
||||
|
||||
public BindableCollection<RenderProfileElement> ProfileElements { get; } = new();
|
||||
|
||||
public RenderProfileElement SelectedProfileElement
|
||||
{
|
||||
get => _selectedProfileElement;
|
||||
set
|
||||
{
|
||||
if (!SetAndNotify(ref _selectedProfileElement, value)) return;
|
||||
_node.ChangeProfileElement(_selectedProfileElement);
|
||||
GetLayerProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public BindableCollection<ILayerProperty> LayerProperties { get; } = new();
|
||||
|
||||
public ILayerProperty SelectedLayerProperty
|
||||
{
|
||||
get => _selectedLayerProperty;
|
||||
set
|
||||
{
|
||||
if (!SetAndNotify(ref _selectedLayerProperty, value)) return;
|
||||
_node.ChangeLayerProperty(_selectedLayerProperty);
|
||||
}
|
||||
}
|
||||
|
||||
private void GetProfileElements()
|
||||
{
|
||||
ProfileElements.Clear();
|
||||
if (_node.Script.Context is not Profile profile)
|
||||
return;
|
||||
|
||||
List<RenderProfileElement> elements = new(profile.GetAllRenderElements());
|
||||
|
||||
ProfileElements.AddRange(elements.OrderBy(e => e.Order));
|
||||
_selectedProfileElement = _node.ProfileElement;
|
||||
NotifyOfPropertyChange(nameof(SelectedProfileElement));
|
||||
}
|
||||
|
||||
private void GetLayerProperties()
|
||||
{
|
||||
LayerProperties.Clear();
|
||||
if (_node.ProfileElement == null)
|
||||
return;
|
||||
|
||||
LayerProperties.AddRange(_node.ProfileElement.GetAllLayerProperties().Where(l => l.GetAllDataBindingRegistrations().Any()));
|
||||
_selectedLayerProperty = _node.LayerProperty;
|
||||
NotifyOfPropertyChange(nameof(SelectedLayerProperty));
|
||||
}
|
||||
|
||||
#region Overrides of CustomNodeViewModel
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnDisplay()
|
||||
{
|
||||
GetProfileElements();
|
||||
GetLayerProperties();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user