mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Nodes - Properly implemented custom VMs
This commit is contained in:
1 parent
7eadc58bee
commit
61d7f1e1fb
8 files changed
+46
-50
No files matched your search
@@ -386,7 +386,7 @@ namespace Artemis.Core
|
||||
|
||||
if (Timeline.EventOverlapMode != TimeLineEventOverlapMode.Toggle)
|
||||
_toggledOnByEvent = false;
|
||||
|
||||
|
||||
DisplayCondition.Run();
|
||||
bool conditionMet = DisplayCondition.Result;
|
||||
if (Parent is RenderProfileElement parent && !parent.DisplayConditionMet)
|
||||
|
||||
@@ -51,8 +51,8 @@ namespace Artemis.Core.Services
|
||||
private INode CreateNode(Type nodeType)
|
||||
{
|
||||
INode node = _kernel.Get(nodeType) as INode ?? throw new InvalidOperationException($"Node {nodeType} is not an INode");
|
||||
if (node.CustomViewModelType != null)
|
||||
node.CustomViewModel = _kernel.Get(node.CustomViewModelType);
|
||||
if (node is CustomViewModelNode customViewModelNode)
|
||||
customViewModelNode.BaseCustomViewModel = _kernel.Get(customViewModelNode.CustomViewModelType);
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,6 @@ namespace Artemis.Core
|
||||
public IReadOnlyCollection<IPin> Pins { get; }
|
||||
public IReadOnlyCollection<IPinCollection> PinCollections { get; }
|
||||
|
||||
public Type? CustomViewModelType { get; }
|
||||
public object? CustomViewModel { get; set; }
|
||||
|
||||
event EventHandler Resetting;
|
||||
|
||||
void Evaluate();
|
||||
|
||||
@@ -6,6 +6,8 @@ namespace Artemis.Core
|
||||
{
|
||||
public abstract class Node : CorePropertyChanged, INode
|
||||
{
|
||||
public event EventHandler Resetting;
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
private string _name;
|
||||
@@ -48,15 +50,6 @@ namespace Artemis.Core
|
||||
private readonly List<IPinCollection> _pinCollections = new();
|
||||
public IReadOnlyCollection<IPinCollection> PinCollections => new ReadOnlyCollection<IPinCollection>(_pinCollections);
|
||||
|
||||
public Type? CustomViewModelType { get; private set; }
|
||||
public object? CustomViewModel { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
public event EventHandler Resetting;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Construtors
|
||||
@@ -67,8 +60,8 @@ namespace Artemis.Core
|
||||
|
||||
protected Node(string name, string description)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Description = description;
|
||||
Name = name;
|
||||
Description = description;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -135,11 +128,6 @@ namespace Artemis.Core
|
||||
return pin;
|
||||
}
|
||||
|
||||
protected void RegisterCustomViewModel<T>()
|
||||
{
|
||||
CustomViewModelType = typeof(T);
|
||||
}
|
||||
|
||||
public abstract void Evaluate();
|
||||
|
||||
public virtual void Reset()
|
||||
@@ -149,4 +137,34 @@ namespace Artemis.Core
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public abstract class Node<T> : CustomViewModelNode
|
||||
{
|
||||
protected Node()
|
||||
{
|
||||
}
|
||||
|
||||
protected Node(string name, string description) : base(name, description)
|
||||
{
|
||||
}
|
||||
|
||||
public override Type CustomViewModelType => typeof(T);
|
||||
public T? CustomViewModel => (T?) BaseCustomViewModel;
|
||||
}
|
||||
|
||||
public abstract class CustomViewModelNode : Node
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected CustomViewModelNode()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected CustomViewModelNode(string name, string description) : base(name, description)
|
||||
{
|
||||
}
|
||||
|
||||
public abstract Type CustomViewModelType { get; }
|
||||
public object? BaseCustomViewModel { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user