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.
115 lines
2.6 KiB
115 lines
2.6 KiB
using ReactiveUI;
|
|
using System;
|
|
|
|
namespace AuroraDesk.Core.Entities;
|
|
|
|
/// <summary>
|
|
/// 连接点实体 - 节点的输入/输出连接点
|
|
/// </summary>
|
|
public class ConnectionPoint : ReactiveObject
|
|
{
|
|
private const double MinDiameter = 0;
|
|
private const double MaxDiameter = 400;
|
|
|
|
private string _label = string.Empty;
|
|
private ConnectionPointType _type = ConnectionPointType.Output;
|
|
private int _index;
|
|
private bool _isConnected;
|
|
private double _diameter = 10;
|
|
private string _color = "#3498DB";
|
|
private ConnectorPlacementMode _placement = ConnectorPlacementMode.Inside;
|
|
|
|
/// <summary>
|
|
/// 连接点唯一标识符
|
|
/// </summary>
|
|
public string Id { get; set; } = Guid.NewGuid().ToString();
|
|
|
|
/// <summary>
|
|
/// 连接点标签(显示在连接点旁边的文本)
|
|
/// </summary>
|
|
public string Label
|
|
{
|
|
get => _label;
|
|
set => this.RaiseAndSetIfChanged(ref _label, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 连接点类型(输入或输出)
|
|
/// </summary>
|
|
public ConnectionPointType Type
|
|
{
|
|
get => _type;
|
|
set => this.RaiseAndSetIfChanged(ref _type, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 连接点索引(在节点上的位置顺序)
|
|
/// </summary>
|
|
public int Index
|
|
{
|
|
get => _index;
|
|
set => this.RaiseAndSetIfChanged(ref _index, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否已连接
|
|
/// </summary>
|
|
public bool IsConnected
|
|
{
|
|
get => _isConnected;
|
|
set => this.RaiseAndSetIfChanged(ref _isConnected, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 附件圆直径
|
|
/// </summary>
|
|
public double Diameter
|
|
{
|
|
get => _diameter;
|
|
set
|
|
{
|
|
var clamped = Math.Clamp(value, MinDiameter, MaxDiameter);
|
|
this.RaiseAndSetIfChanged(ref _diameter, clamped);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 附件圆颜色(Hex)
|
|
/// </summary>
|
|
public string Color
|
|
{
|
|
get => _color;
|
|
set => this.RaiseAndSetIfChanged(ref _color, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 附件圆定位(内侧/外侧)
|
|
/// </summary>
|
|
public ConnectorPlacementMode Placement
|
|
{
|
|
get => _placement;
|
|
set => this.RaiseAndSetIfChanged(ref _placement, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 所属节点
|
|
/// </summary>
|
|
public Node? Node { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 连接点类型枚举
|
|
/// </summary>
|
|
public enum ConnectionPointType
|
|
{
|
|
/// <summary>
|
|
/// 输入连接点(在左侧)
|
|
/// </summary>
|
|
Input,
|
|
|
|
/// <summary>
|
|
/// 输出连接点(在右侧)
|
|
/// </summary>
|
|
Output
|
|
}
|
|
|
|
|