优化了脚本生成AST时的代码提示,增加了脚本运行时错误提示。

This commit is contained in:
fengjiayi
2025-07-09 21:49:26 +08:00
parent 4da8bf6b84
commit 70f674ca1b
32 changed files with 1218 additions and 266 deletions

View File

@@ -101,7 +101,7 @@ namespace Serein.Workbench.Node.View
public void RemoveConnection(ConnectionControl connection)
{
connectionControls.Remove(connection);
connection.Remote();
connection.Remove(); // 主动删除连接
}
/// <summary>
@@ -111,7 +111,7 @@ namespace Serein.Workbench.Node.View
{
foreach (var connection in this.connectionControls)
{
connection.Remote();
connection.Remove(); // 主动删除连接
}
}

View File

@@ -1,5 +1,6 @@
using Serein.Library;
using Serein.Library.Api;
using Serein.Workbench.Api;
using Serein.Workbench.Extension;
using Serein.Workbench.Tool;
using System;
@@ -142,7 +143,7 @@ namespace Serein.Workbench.Node.View
/// <summary>
/// 连接线
/// </summary>
private ConnectionLineShape BezierLine;
public ConnectionLineShape BezierLine { get;private set; }
@@ -225,17 +226,39 @@ namespace Serein.Workbench.Node.View
private void ConfigureLineContextMenu()
{
var contextMenu = new ContextMenu();
contextMenu.Items.Add(WpfFuncTool.CreateMenuItem("删除连线", (s, e) => Remote()));
contextMenu.Items.Add(WpfFuncTool.CreateMenuItem("移除该连接关系", (s, e) => Remove()));
contextMenu.Items.Add(WpfFuncTool.CreateMenuItem("于父节点调用顺序中置顶", (s, e) => Topping()));
BezierLine.ContextMenu = contextMenu;
}
/// <summary>
/// 从画布删除
/// </summary>
public void RemoveOnCanvas()
{
Canvas.Children.Remove(BezierLine);
}
/// <summary>
/// 删除该连线
/// </summary>
public void Remote()
public void Remove()
{
/*string startGuid = Start.MyNode.Guid;
string endGuid = End.MyNode.Guid;
if (flowEventSerice is null) flowEventSerice = App.GetService<IFlowEEForwardingService>();
NodeConnectChangeHandler handler = null;
handler = (e) =>
{
if(e.ConnectionInvokeType == InvokeType && e.ChangeType == NodeConnectChangeEventArgs.ConnectChangeType.Remove)
{
}
flowEventSerice.NodeConnectChanged -= handler;
};
flowEventSerice.NodeConnectChanged += handler;*/
//
Canvas.Children.Remove(BezierLine);
var env = Start.MyNode.Env;
var canvasGuid = Start.MyNode.CanvasDetails.Guid;
@@ -247,7 +270,7 @@ namespace Serein.Workbench.Node.View
}
else if (jct == JunctionOfConnectionType.Arg)
{
env.FlowEdit.RemoveArgSourceConnect(canvasGuid,Start.MyNode.Guid, End.MyNode.Guid, ArgIndex) ;
env.FlowEdit.RemoveArgSourceConnect(canvasGuid, Start.MyNode.Guid, End.MyNode.Guid, ArgIndex);
}
}

View File

@@ -50,6 +50,11 @@ namespace Serein.Workbench.Services
/// </summary>
public Action<MethodDetailsInfo> OnViewMethodDetailsInfoChanged { get; set; }
/// <summary>
/// FlowCanvasView 监听,需要移除连接线(控件)
/// </summary>
public Action<NodeConnectChangeEventArgs> OnRemoveConnectionLine { get; set; }
#endregion
#region
@@ -244,8 +249,11 @@ namespace Serein.Workbench.Services
_ => null
};
/*if(e.ChangeType == NodeConnectChangeEventArgs.ConnectChangeType.Remove)
{
OnRemoveConnectionLine.Invoke(e); // 删除连线
}*/
action?.Invoke();
return;
}
@@ -408,7 +416,6 @@ namespace Serein.Workbench.Services
}
#endregion
/// <summary>

View File

@@ -42,6 +42,7 @@ using Clipboard = System.Windows.Clipboard;
using TextDataFormat = System.Windows.TextDataFormat;
using System.Windows.Media.Animation;
using Serein.NodeFlow.Model;
using Serein.NodeFlow.Services;
namespace Serein.Workbench.Views
{
@@ -151,6 +152,7 @@ namespace Serein.Workbench.Views
}
/// <summary>
/// 设置绑定
/// </summary>
@@ -175,9 +177,52 @@ namespace Serein.Workbench.Views
private void InitEvent()
{
keyEventService.OnKeyDown += KeyEventService_OnKeyDown;
//flowNodeService.OnRemoveConnectionLine += FlowNodeService_OnRemoveConnectionLine;
flowEEForwardingService.NodeLocated += FlowEEForwardingService_OnNodeLocated;
}
private void FlowNodeService_OnRemoveConnectionLine(NodeConnectChangeEventArgs e)
{
if(e.ChangeType == NodeConnectChangeEventArgs.ConnectChangeType.Create || e.CanvasGuid != this.Guid)
{
return;
}
var connectionControl = Connections.FirstOrDefault(c =>
{
if (c.Start.MyNode.Guid != e.FromNodeGuid
|| c.End.MyNode.Guid != e.ToNodeGuid)
{
return false; // 不是当前连接
}
var jct1 = c.Start.JunctionType.ToConnectyionType();
var jct2 = c.End.JunctionType.ToConnectyionType();
if (e.JunctionOfConnectionType == JunctionOfConnectionType.Invoke)
{
if (jct1 == JunctionOfConnectionType.Invoke
&& jct2 == JunctionOfConnectionType.Invoke)
{
return true; // 是当前连接
}
}
else
{
if (c.ArgIndex == e.ArgIndex
&& jct1 == JunctionOfConnectionType.Arg
&& jct2 == JunctionOfConnectionType.Arg)
{
return true; // 是当前连接
}
}
return true;
});
if(connectionControl is null)
{
return;
}
connectionControl.RemoveOnCanvas(); // 移除连接线
}
/// <summary>
/// 节点需要定位
/// </summary>
@@ -224,6 +269,7 @@ namespace Serein.Workbench.Views
nodeControl.RenderTransform = translateTransform;
ElasticAnimation(nodeControl, translateTransform, 6, 0.5, 0.5);
}
/// <summary>
/// 控件抖动
/// 来源https://www.cnblogs.com/RedSky/p/17705411.html
@@ -257,7 +303,6 @@ namespace Serein.Workbench.Views
};
}
/// <summary>
/// 加载完成后刷新显示
/// </summary>
@@ -267,8 +312,6 @@ namespace Serein.Workbench.Views
RefreshAllLine();
}
/// <summary>
/// 当前画布创建了节点
/// </summary>
@@ -1490,9 +1533,9 @@ namespace Serein.Workbench.Views
contextMenu.Items.Add(WpfFuncTool.CreateMenuItem("设为起点", (s, e) => flowEnvironment.FlowEdit.SetStartNode(canvasGuid, nodeGuid)));
contextMenu.Items.Add(WpfFuncTool.CreateMenuItem("删除", async (s, e) =>
contextMenu.Items.Add(WpfFuncTool.CreateMenuItem("删除", (s, e) =>
{
flowEnvironment.FlowEdit.RemoveNode(canvasGuid, nodeGuid);
flowNodeService.RemoteNode(nodeControl);
}));
#region -