2025-01-05 08:52:37 +08:00
|
|
|
|
using Serein.Library;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Net;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Serein.Workbench.Node.View
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
#region Model,不科学的全局变量
|
2025-07-30 21:15:07 +08:00
|
|
|
|
internal class MyLine
|
2025-01-05 08:52:37 +08:00
|
|
|
|
{
|
|
|
|
|
|
public MyLine(Canvas canvas, ConnectionLineShape line)
|
|
|
|
|
|
{
|
|
|
|
|
|
Canvas = canvas;
|
|
|
|
|
|
Line = line;
|
|
|
|
|
|
canvas?.Children.Add(line);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Canvas Canvas { get; set; }
|
|
|
|
|
|
public ConnectionLineShape Line { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public void Remove()
|
|
|
|
|
|
{
|
|
|
|
|
|
Canvas?.Children.Remove(Line);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-30 21:15:07 +08:00
|
|
|
|
internal class ConnectingData
|
2025-01-05 08:52:37 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否正在创建连线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsCreateing { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 起始控制点
|
|
|
|
|
|
/// </summary>
|
2025-07-30 21:15:07 +08:00
|
|
|
|
public JunctionControlBase? StartJunction { get; set; }
|
2025-01-05 08:52:37 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 当前的控制点
|
|
|
|
|
|
/// </summary>
|
2025-07-30 21:15:07 +08:00
|
|
|
|
public JunctionControlBase? CurrentJunction { get; set; }
|
2025-01-05 08:52:37 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 开始坐标
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Point StartPoint { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 线条样式
|
|
|
|
|
|
/// </summary>
|
2025-07-30 21:15:07 +08:00
|
|
|
|
public MyLine? MyLine { get; set; }
|
2025-01-05 08:52:37 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 线条类别(方法调用)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ConnectionInvokeType ConnectionInvokeType { get; set; } = ConnectionInvokeType.IsSucceed;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 线条类别(参数传递)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ConnectionArgSourceType ConnectionArgSourceType { get; set; } = ConnectionArgSourceType.GetOtherNodeData;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 判断当前连接类型
|
|
|
|
|
|
/// </summary>
|
2025-07-30 21:15:07 +08:00
|
|
|
|
public JunctionOfConnectionType Type => StartJunction?.JunctionType.ToConnectyionType() ?? JunctionOfConnectionType.None;
|
2025-01-05 08:52:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否允许连接
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsCanConnected { get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if(StartJunction is null
|
|
|
|
|
|
|| CurrentJunction is null
|
|
|
|
|
|
)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-07-13 17:34:03 +08:00
|
|
|
|
if (!StartJunction.NodeGuid.Equals(CurrentJunction.NodeGuid)
|
2025-01-05 08:52:37 +08:00
|
|
|
|
&& StartJunction.JunctionType.IsCanConnection(CurrentJunction.JunctionType))
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新临时的连接线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="point"></param>
|
|
|
|
|
|
public void UpdatePoint(Point point)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (StartJunction is null
|
|
|
|
|
|
|| CurrentJunction is null
|
|
|
|
|
|
)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StartJunction.JunctionType == Library.JunctionType.Execute
|
|
|
|
|
|
|| StartJunction.JunctionType == Library.JunctionType.ArgData)
|
|
|
|
|
|
{
|
2025-07-30 21:15:07 +08:00
|
|
|
|
MyLine?.Line.UpdateStartPoints(point);
|
2025-01-05 08:52:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-07-30 21:15:07 +08:00
|
|
|
|
MyLine?.Line.UpdateEndPoints(point);
|
2025-01-05 08:52:37 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-05-27 18:32:40 +08:00
|
|
|
|
/// 重置连线状态
|
2025-01-05 08:52:37 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void Reset()
|
|
|
|
|
|
{
|
|
|
|
|
|
IsCreateing = false;
|
|
|
|
|
|
StartJunction = null;
|
|
|
|
|
|
CurrentJunction = null;
|
|
|
|
|
|
MyLine?.Remove();
|
|
|
|
|
|
ConnectionInvokeType = ConnectionInvokeType.IsSucceed;
|
|
|
|
|
|
ConnectionArgSourceType = ConnectionArgSourceType.GetOtherNodeData;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|