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