mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using Artemis.Core;
|
|
using Artemis.Core.Events;
|
|
using Artemis.UI.Shared;
|
|
using Stylet;
|
|
|
|
namespace Artemis.VisualScripting.Nodes.CustomViewModels
|
|
{
|
|
public class EnumEqualsNodeCustomViewModel : CustomNodeViewModel
|
|
{
|
|
private readonly EnumEqualsNode _node;
|
|
|
|
public EnumEqualsNodeCustomViewModel(EnumEqualsNode node) : base(node)
|
|
{
|
|
_node = node;
|
|
}
|
|
|
|
public BindableCollection<ValueDescription> EnumValues { get; } = new();
|
|
|
|
public override void OnActivate()
|
|
{
|
|
_node.InputPin.PinConnected += InputPinOnPinConnected;
|
|
_node.InputPin.PinDisconnected += InputPinOnPinDisconnected;
|
|
|
|
if (_node.InputPin.Value != null && _node.InputPin.Value.GetType().IsEnum)
|
|
EnumValues.AddRange(EnumUtilities.GetAllValuesAndDescriptions(_node.InputPin.Value.GetType()));
|
|
base.OnActivate();
|
|
}
|
|
|
|
public override void OnDeactivate()
|
|
{
|
|
_node.InputPin.PinConnected -= InputPinOnPinConnected;
|
|
_node.InputPin.PinDisconnected -= InputPinOnPinDisconnected;
|
|
|
|
base.OnDeactivate();
|
|
}
|
|
|
|
private void InputPinOnPinDisconnected(object sender, SingleValueEventArgs<IPin> e)
|
|
{
|
|
EnumValues.Clear();
|
|
}
|
|
|
|
private void InputPinOnPinConnected(object sender, SingleValueEventArgs<IPin> e)
|
|
{
|
|
EnumValues.Clear();
|
|
if (_node.InputPin.Value != null && _node.InputPin.Value.GetType().IsEnum)
|
|
EnumValues.AddRange(EnumUtilities.GetAllValuesAndDescriptions(_node.InputPin.Value.GetType()));
|
|
}
|
|
}
|
|
} |