You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
3.2 KiB
139 lines
3.2 KiB
using ReactiveUI;
|
|
using System;
|
|
|
|
namespace AuroraDesk.Core.Entities;
|
|
|
|
/// <summary>
|
|
/// 节点模板 - 定义可用的节点类型
|
|
/// </summary>
|
|
public class NodeTemplate : ReactiveObject
|
|
{
|
|
private string _name = string.Empty;
|
|
private string _displayName = string.Empty;
|
|
private string _description = string.Empty;
|
|
private string _content = string.Empty;
|
|
private int _inputCount = 1;
|
|
private int _outputCount = 3;
|
|
private double _width = 120;
|
|
private double _height = 80;
|
|
|
|
/// <summary>
|
|
/// 模板唯一标识符
|
|
/// </summary>
|
|
public string Id { get; set; } = Guid.NewGuid().ToString();
|
|
|
|
/// <summary>
|
|
/// 模板名称(用于内部标识)
|
|
/// </summary>
|
|
public string Name
|
|
{
|
|
get => _name;
|
|
set => this.RaiseAndSetIfChanged(ref _name, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示名称
|
|
/// </summary>
|
|
public string DisplayName
|
|
{
|
|
get => _displayName;
|
|
set => this.RaiseAndSetIfChanged(ref _displayName, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 描述
|
|
/// </summary>
|
|
public string Description
|
|
{
|
|
get => _description;
|
|
set => this.RaiseAndSetIfChanged(ref _description, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 节点内容(显示在节点内部的文本)
|
|
/// </summary>
|
|
public string Content
|
|
{
|
|
get => _content;
|
|
set => this.RaiseAndSetIfChanged(ref _content, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 输入连接点数量
|
|
/// </summary>
|
|
public int InputCount
|
|
{
|
|
get => _inputCount;
|
|
set => this.RaiseAndSetIfChanged(ref _inputCount, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 输出连接点数量
|
|
/// </summary>
|
|
public int OutputCount
|
|
{
|
|
get => _outputCount;
|
|
set => this.RaiseAndSetIfChanged(ref _outputCount, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 节点宽度
|
|
/// </summary>
|
|
public double Width
|
|
{
|
|
get => _width;
|
|
set => this.RaiseAndSetIfChanged(ref _width, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 节点高度
|
|
/// </summary>
|
|
public double Height
|
|
{
|
|
get => _height;
|
|
set => this.RaiseAndSetIfChanged(ref _height, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据模板创建节点实例
|
|
/// </summary>
|
|
public Node CreateNode(double x, double y)
|
|
{
|
|
var node = new Node
|
|
{
|
|
X = x,
|
|
Y = y,
|
|
Title = DisplayName,
|
|
Content = Content,
|
|
Width = Width,
|
|
Height = Height
|
|
};
|
|
|
|
// 创建输入连接点(左侧)
|
|
for (int i = 0; i < InputCount; i++)
|
|
{
|
|
node.ConnectionPoints.Add(new ConnectionPoint
|
|
{
|
|
Label = "",
|
|
Type = ConnectionPointType.Input,
|
|
Index = i,
|
|
Node = node
|
|
});
|
|
}
|
|
|
|
// 创建输出连接点(右侧)
|
|
for (int i = 0; i < OutputCount; i++)
|
|
{
|
|
node.ConnectionPoints.Add(new ConnectionPoint
|
|
{
|
|
Label = (i + 1).ToString(),
|
|
Type = ConnectionPointType.Output,
|
|
Index = i,
|
|
Node = node
|
|
});
|
|
}
|
|
|
|
return node;
|
|
}
|
|
}
|
|
|
|
|