From 8d0258ebea3df0990748ef0c538196abcf6e249e Mon Sep 17 00:00:00 2001
From: fengjiayi <12821976+ning_xi@user.noreply.gitee.com>
Date: Sat, 14 Dec 2024 23:46:37 +0800
Subject: [PATCH] =?UTF-8?q?Workbench=E9=A1=B9=E7=9B=AE=E4=B8=AD=EF=BC=8C?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E8=8A=82=E7=82=B9=E7=9A=84=E5=A4=8D?=
=?UTF-8?q?=E5=88=B6=E3=80=81=E7=B2=98=E8=B4=B4=EF=BC=8C=E5=8A=A0=E8=BD=BD?=
=?UTF-8?q?=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Library/FlowNode/NodeModelBaseFunc.cs | 139 +++---
Library/FlowNode/ParameterDetails.cs | 20 +-
NodeFlow/Env/FlowEnvironment.cs | 2 +-
NodeFlow/Model/SingleConditionNode.cs | 2 +-
NodeFlow/Model/SingleExpOpNode.cs | 2 +-
NodeFlow/Tool/NodeMethodDetailsHelper.cs | 18 +-
WorkBench/MainWindow.xaml | 12 +-
WorkBench/MainWindow.xaml.cs | 405 ++++++++++--------
WorkBench/Node/View/ActionNodeControl.xaml | 52 +--
WorkBench/Node/View/ActionNodeControl.xaml.cs | 2 +
.../Node/Junction/JunctionControlBase.cs | 20 +-
.../Node/Junction/View/ArgJunctionControl.cs | 4 +-
.../Junction/View/ExecuteJunctionControl.cs | 4 +-
.../Junction/View/NextStepJunctionControl.cs | 4 +-
.../Junction/View/ResultJunctionControl.cs | 4 +-
Workbench/Node/NodeControlBase.cs | 1 +
Workbench/Node/View/ConnectionControl.cs | 3 -
17 files changed, 396 insertions(+), 298 deletions(-)
diff --git a/Library/FlowNode/NodeModelBaseFunc.cs b/Library/FlowNode/NodeModelBaseFunc.cs
index ac7fd69..35097e9 100644
--- a/Library/FlowNode/NodeModelBaseFunc.cs
+++ b/Library/FlowNode/NodeModelBaseFunc.cs
@@ -28,7 +28,26 @@ namespace Serein.Library
///
public abstract partial class NodeModelBase : IDynamicFlowNode
{
- #region 节点移除相关
+ #region 节点相关事件
+
+ ///
+ /// 保存自定义信息
+ ///
+ ///
+ public virtual NodeInfo SaveCustomData(NodeInfo nodeInfo)
+ {
+ return nodeInfo;
+ }
+
+ ///
+ /// 加载自定义数据
+ ///
+ ///
+ public virtual void LoadCustomData(NodeInfo nodeInfo)
+ {
+ return;
+ }
+
///
/// 移除该节点
///
@@ -36,16 +55,52 @@ namespace Serein.Library
{
}
+ ///
+ /// 移除该节点
+ ///
+ public virtual void RemoveFromEnv()
+ {
+ if (this.DebugSetting.CancelInterruptCallback != null)
+ {
+ this.DebugSetting.CancelInterruptCallback?.Invoke();
+ }
+ this.DebugSetting.GetInterruptTask = null;
+ this.DebugSetting.NodeModel = null;
+ this.DebugSetting.CancelInterruptCallback = null;
+ this.DebugSetting = null;
+ foreach (var pd in this.MethodDetails.ParameterDetailss)
+ {
+ pd.DataValue = null;
+ pd.Items = null;
+ pd.NodeModel = null;
+ pd.ExplicitType = null;
+ pd.DataType = null;
+ pd.Name = null;
+ pd.ArgDataSourceNodeGuid = null;
+ pd.ExplicitTypeName = null;
+ }
+ this.MethodDetails.ParameterDetailss = null;
+ this.MethodDetails.ActingInstance = null;
+ this.MethodDetails.NodeModel = null;
+ this.MethodDetails.ReturnType = null;
+ this.MethodDetails.AssemblyName = null;
+ this.MethodDetails.MethodAnotherName = null;
+ this.MethodDetails.MethodLockName = null;
+ this.MethodDetails.MethodName = null;
+ this.MethodDetails.ActingInstanceType = null;
+ this.MethodDetails = null;
+ this.Position = null;
+ this.DisplayName = null;
- #endregion
+ this.Env = null;
+ }
- #region 导出/导入项目文件节点信息
///
/// 输出方法参数信息
///
///
- public virtual ParameterData[] SaveParameterInfo()
+ public ParameterData[] SaveParameterInfo()
{
if(MethodDetails.ParameterDetailss == null)
{
@@ -69,20 +124,13 @@ namespace Serein.Library
}
}
- ///
- /// 保存自定义信息
- ///
- ///
- public virtual NodeInfo SaveCustomData(NodeInfo nodeInfo)
- {
- return nodeInfo;
- }
+
///
/// 导出为节点信息
///
///
- public virtual NodeInfo ToInfo()
+ public NodeInfo ToInfo()
{
// if (MethodDetails == null) return null;
@@ -110,25 +158,20 @@ namespace Serein.Library
IsInterrupt = this.DebugSetting.IsInterrupt,
IsEnable = this.DebugSetting.IsEnable,
};
+ nodeInfo.Position.X = Math.Round(nodeInfo.Position.X, 1);
+ nodeInfo.Position.Y = Math.Round(nodeInfo.Position.Y, 1);
nodeInfo = SaveCustomData(nodeInfo);
return nodeInfo;
}
- ///
- /// 加载自定义数据
- ///
- ///
- public virtual void LoadCustomData(NodeInfo nodeInfo)
- {
- return;
- }
+
///
/// 从节点信息加载节点
///
///
///
- public virtual void LoadInfo(NodeInfo nodeInfo)
+ public void LoadInfo(NodeInfo nodeInfo)
{
this.Guid = nodeInfo.Guid;
this.Position = nodeInfo.Position ?? new PositionOfUI(0, 0);// 加载位置信息
@@ -520,33 +563,33 @@ namespace Serein.Library
#endregion
- #region 入参存在取值转换器,调用对应的转换器获取入参数据,如果获取成功(不为null)会跳过循环
- if (pd.ExplicitType.IsEnum && !(pd.Convertor is null))
- {
- //var resultEnum = Enum.ToObject(ed.ExplicitType, ed.DataValue);
- var resultEnum = Enum.Parse(pd.ExplicitType, pd.DataValue);
- var value = pd.Convertor(resultEnum);
- if (value is null)
- {
- throw new InvalidOperationException("转换器调用失败");
+ //#region 入参存在取值转换器,调用对应的转换器获取入参数据,如果获取成功(不为null)会跳过循环
+ //if (pd.ExplicitType.IsEnum && !(pd.Convertor is null))
+ //{
+ // //var resultEnum = Enum.ToObject(ed.ExplicitType, ed.DataValue);
+ // var resultEnum = Enum.Parse(pd.ExplicitType, pd.DataValue);
+ // var value = pd.Convertor(resultEnum);
+ // if (value is null)
+ // {
+ // throw new InvalidOperationException("转换器调用失败");
- }
- else
- {
- if (hasParams)
- {
- paramsArgs.SetValue(value, paramsArgIndex++);
- // 处理可选参数
- //paramsArgs[paramsArgIndex++] = value;
- }
- else
- {
- parameters[i] = value;
- }
- continue;
- }
- }
- #endregion
+ // }
+ // else
+ // {
+ // if (hasParams)
+ // {
+ // paramsArgs.SetValue(value, paramsArgIndex++);
+ // // 处理可选参数
+ // //paramsArgs[paramsArgIndex++] = value;
+ // }
+ // else
+ // {
+ // parameters[i] = value;
+ // }
+ // continue;
+ // }
+ //}
+ //#endregion
#region 入参存在基于BinValue的类型转换器,获取枚举转换器中记录的类型,如果获取成功(不为null)会跳过循环
// 入参存在基于BinValue的类型转换器,获取枚举转换器中记录的类型
diff --git a/Library/FlowNode/ParameterDetails.cs b/Library/FlowNode/ParameterDetails.cs
index 870404f..33601cb 100644
--- a/Library/FlowNode/ParameterDetails.cs
+++ b/Library/FlowNode/ParameterDetails.cs
@@ -35,11 +35,11 @@ namespace Serein.Library
[PropertyInfo(IsNotification = true)]
private bool _isExplicitData ;
- ///
- /// 转换器 IEnumConvertor<,>
- ///
- [PropertyInfo]
- private Func