mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
30 lines
1001 B
C#
30 lines
1001 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reactive;
|
|
using Artemis.Core;
|
|
using ReactiveUI;
|
|
|
|
namespace Artemis.UI.Screens.VisualScripting;
|
|
|
|
public class NodeMenuItemViewModel
|
|
{
|
|
public NodeMenuItemViewModel(ReactiveCommand<NodeData, Unit> createNode, DynamicData.List.IGrouping<NodeData, string> category)
|
|
{
|
|
Header = category.Key;
|
|
Items = category.Items.Select(d => new NodeMenuItemViewModel(createNode, d)).ToList();
|
|
}
|
|
|
|
public NodeMenuItemViewModel(ReactiveCommand<NodeData, Unit> createNode, NodeData nodeData)
|
|
{
|
|
Header = nodeData.Name;
|
|
Subtitle = nodeData.Description;
|
|
Items = new List<NodeMenuItemViewModel>();
|
|
CreateNode = ReactiveCommand.Create(() => { createNode.Execute(nodeData).Subscribe(); });
|
|
}
|
|
|
|
public string Header { get; }
|
|
public string? Subtitle { get; }
|
|
public List<NodeMenuItemViewModel> Items { get; }
|
|
public ReactiveCommand<Unit, Unit>? CreateNode { get; }
|
|
} |