mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-03 23:06:34 +08:00
从节点Model解耦出容器接口,重新设计了节点的保存、加载。
This commit is contained in:
@@ -53,6 +53,12 @@ namespace Serein.Library.Api
|
||||
/// <param name="eventArgs"></param>
|
||||
public delegate void NodeCreateHandler(NodeCreateEventArgs eventArgs);
|
||||
|
||||
/// <summary>
|
||||
/// 容器节点与子项节点的关系发生改变
|
||||
/// </summary>
|
||||
/// <param name="eventArgs"></param>
|
||||
public delegate void NodeContainerChildChangeHandler(NodeContainerChildChangeEventArgs eventArgs);
|
||||
|
||||
/// <summary>
|
||||
/// 环境中流程起始节点发生了改变
|
||||
/// </summary>
|
||||
@@ -279,34 +285,80 @@ namespace Serein.Library.Api
|
||||
/// </summary>
|
||||
/// <param name="nodeModel">节点对象</param>
|
||||
/// <param name="position">位置</param>
|
||||
public NodeCreateEventArgs(object nodeModel, PositionOfUI position)
|
||||
public NodeCreateEventArgs(NodeModelBase nodeModel, PositionOfUI position)
|
||||
{
|
||||
this.NodeModel = nodeModel;
|
||||
this.Position = position;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 区域子项节点添加事件参数
|
||||
/// </summary>
|
||||
/// <param name="nodeModel">节点对象</param>
|
||||
/// <param name="isAddInRegion">是否添加在区域中</param>
|
||||
/// <param name="regeionGuid">区域Guid</param>
|
||||
public NodeCreateEventArgs(object nodeModel, bool isAddInRegion, string regeionGuid)
|
||||
{
|
||||
this.NodeModel = nodeModel;
|
||||
this.RegeionGuid = regeionGuid;
|
||||
this.IsAddInRegion = isAddInRegion;
|
||||
}
|
||||
///// <summary>
|
||||
///// 区域子项节点添加事件参数
|
||||
///// </summary>
|
||||
///// <param name="nodeModel">节点对象</param>
|
||||
///// <param name="isAddInRegion">是否添加在区域中</param>
|
||||
///// <param name="regeionGuid">区域Guid</param>
|
||||
//public NodeCreateEventArgs(object nodeModel, bool isAddInRegion, string regeionGuid)
|
||||
//{
|
||||
// this.NodeModel = nodeModel;
|
||||
// this.RegeionGuid = regeionGuid;
|
||||
// this.IsAddInRegion = isAddInRegion;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 节点Model对象,目前需要手动转换对应的类型
|
||||
/// </summary>
|
||||
public object NodeModel { get; private set; }
|
||||
public PositionOfUI Position { get; private set; }
|
||||
public bool IsAddInRegion { get; private set; }
|
||||
//public bool IsAddInRegion { get; private set; }
|
||||
public string RegeionGuid { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 节点父子关系改变
|
||||
/// </summary>
|
||||
public class NodeContainerChildChangeEventArgs : FlowEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 变更类型
|
||||
/// </summary>
|
||||
public enum Type
|
||||
{
|
||||
/// <summary>
|
||||
/// 放置
|
||||
/// </summary>
|
||||
Place,
|
||||
/// <summary>
|
||||
/// 取出
|
||||
/// </summary>
|
||||
TakeOut
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="childNodeGuid">子项节点</param>
|
||||
/// <param name="containerNodeGuid">容器节点</param>
|
||||
/// <param name="state">类别</param>
|
||||
public NodeContainerChildChangeEventArgs(string childNodeGuid, string containerNodeGuid, Type state)
|
||||
{
|
||||
ChildNodeGuid = childNodeGuid;
|
||||
ContainerNodeGuid = containerNodeGuid;
|
||||
State = state;
|
||||
}
|
||||
/// <summary>
|
||||
/// 子节点,该数据为此次时间的主节点
|
||||
/// </summary>
|
||||
public string ChildNodeGuid { get; private set; }
|
||||
/// <summary>
|
||||
/// 父节点
|
||||
/// </summary>
|
||||
public string ContainerNodeGuid { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 改变类型
|
||||
/// </summary>
|
||||
public Type State { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 环境中移除了一个节点
|
||||
/// </summary>
|
||||
@@ -611,6 +663,11 @@ namespace Serein.Library.Api
|
||||
/// </summary>
|
||||
event NodeRemoveHandler OnNodeRemove;
|
||||
|
||||
/// <summary>
|
||||
/// 节点父子关系发生改变事件
|
||||
/// </summary>
|
||||
event NodeContainerChildChangeHandler OnNodeParentChildChange;
|
||||
|
||||
/// <summary>
|
||||
/// 起始节点变化事件
|
||||
/// </summary>
|
||||
@@ -647,7 +704,7 @@ namespace Serein.Library.Api
|
||||
event NodeLocatedHandler OnNodeLocated;
|
||||
|
||||
/// <summary>
|
||||
/// 节点移动了(远程插件)
|
||||
/// 节点移动了(远程环境)
|
||||
/// </summary>
|
||||
event NodeMovedHandler OnNodeMoved;
|
||||
|
||||
@@ -811,13 +868,22 @@ namespace Serein.Library.Api
|
||||
Task LoadNodeInfosAsync(List<NodeInfo> nodeInfos);
|
||||
|
||||
/// <summary>
|
||||
/// 创建节点/区域/基础控件
|
||||
/// 创建节点
|
||||
/// </summary>
|
||||
/// <param name="nodeType">节点/区域/基础控件类型</param>
|
||||
/// <param name="nodeType">控件类型</param>
|
||||
/// <param name="position">节点在画布上的位置(</param>
|
||||
/// <param name="methodDetailsInfo">节点绑定的方法说明</param>
|
||||
Task<NodeInfo> CreateNodeAsync(NodeControlType nodeType, PositionOfUI position, MethodDetailsInfo methodDetailsInfo = null);
|
||||
|
||||
/// <summary>
|
||||
/// 将节点放置在容器中/从容器中取出
|
||||
/// </summary>
|
||||
/// <param name="childNodeGuid">子节点(主要节点)</param>
|
||||
/// <param name="parentNodeGuid">父节点</param>
|
||||
/// <param name="isPlace">是否组合(反之为分解节点组合关系)</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> ChangeNodeContainerChild(string childNodeGuid,string parentNodeGuid,bool isAssembly);
|
||||
|
||||
/// <summary>
|
||||
/// 设置两个节点某个类型的方法调用关系为优先调用
|
||||
/// </summary>
|
||||
|
||||
31
Library/Api/INodeContainer.cs
Normal file
31
Library/Api/INodeContainer.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Library.Api
|
||||
{
|
||||
/// <summary>
|
||||
/// 约束具有容器功能的节点应该有什么方法
|
||||
/// </summary>
|
||||
public interface INodeContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// 放置一个节点
|
||||
/// </summary>
|
||||
/// <param name="nodeModel"></param>
|
||||
void PlaceNode(NodeModelBase nodeModel);
|
||||
|
||||
/// <summary>
|
||||
/// 取出一个节点
|
||||
/// </summary>
|
||||
/// <param name="nodeModel"></param>
|
||||
void TakeOutNode(NodeModelBase nodeModel);
|
||||
|
||||
/// <summary>
|
||||
/// 取出所有节点(用于删除容器)
|
||||
/// </summary>
|
||||
void TakeOutAll();
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace Serein.Library
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 节点基类(数据):条件控件,动作控件,条件区域,动作区域
|
||||
/// 节点基类(数据)
|
||||
/// </summary>
|
||||
[NodeProperty(ValuePath = NodeValuePath.None)]
|
||||
public abstract partial class NodeModelBase : IDynamicFlowNode
|
||||
@@ -69,6 +69,16 @@ namespace Serein.Library
|
||||
|
||||
public abstract partial class NodeModelBase : IDynamicFlowNode
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否为基础节点
|
||||
/// </summary>
|
||||
public virtual bool IsBase { get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 可以放置多少个节点
|
||||
/// </summary>
|
||||
public virtual int MaxChildrenCount { get; } = 0;
|
||||
|
||||
public NodeModelBase(IFlowEnvironment environment)
|
||||
{
|
||||
PreviousNodes = new Dictionary<ConnectionInvokeType, List<NodeModelBase>>();
|
||||
@@ -78,21 +88,33 @@ namespace Serein.Library
|
||||
PreviousNodes[ctType] = new List<NodeModelBase>();
|
||||
SuccessorNodes[ctType] = new List<NodeModelBase>();
|
||||
}
|
||||
ChildrenNode = new List<NodeModelBase>();
|
||||
DebugSetting = new NodeDebugSetting(this);
|
||||
this.Env = environment;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 不同分支的父节点
|
||||
/// 不同分支的父节点(流程调用)
|
||||
/// </summary>
|
||||
public Dictionary<ConnectionInvokeType, List<NodeModelBase>> PreviousNodes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 不同分支的子节点
|
||||
/// 不同分支的子节点(流程调用)
|
||||
/// </summary>
|
||||
public Dictionary<ConnectionInvokeType, List<NodeModelBase>> SuccessorNodes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 该节点的父级节点(容器)
|
||||
/// </summary>
|
||||
public NodeModelBase ParentNode { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// 该节点的子项节点(容器)
|
||||
/// </summary>
|
||||
public List<NodeModelBase> ChildrenNode { get; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,6 +164,8 @@ namespace Serein.Library
|
||||
IsProtectionParameter = this.MethodDetails.IsProtectionParameter,
|
||||
IsInterrupt = this.DebugSetting.IsInterrupt,
|
||||
IsEnable = this.DebugSetting.IsEnable,
|
||||
ParentNodeGuid = ParentNode?.Guid,
|
||||
ChildNodeGuids = ChildrenNode.Select(item => item.Guid).ToArray(),
|
||||
};
|
||||
nodeInfo.Position.X = Math.Round(nodeInfo.Position.X, 1);
|
||||
nodeInfo.Position.Y = Math.Round(nodeInfo.Position.Y, 1);
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace Serein.Library
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[{this.Index}] {this.Name} : {this.ExplicitType.FullName} -> {this.DataType.FullName}";
|
||||
return $"[{this.Index}] {this.Name} : {this.ExplicitType?.FullName} -> {this.DataType?.FullName}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -230,8 +230,15 @@ namespace Serein.Library
|
||||
/// </summary>
|
||||
public ParameterData[] ParameterData { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 如果是区域控件,则会存在子项。
|
||||
/// 父级节点Guid
|
||||
/// </summary>
|
||||
public string ParentNodeGuid{ get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 如果是区域控件,则会存在子项,这里记录的是子项的Guid。
|
||||
/// </summary>
|
||||
public string[] ChildNodeGuids { get; set; }
|
||||
|
||||
|
||||
@@ -173,10 +173,10 @@ namespace Serein.Library.Network.WebSocketCommunication.Handle
|
||||
|
||||
|
||||
SereinEnv.WriteLine(InfoType.INFO, $"add websocket handle model :");
|
||||
SereinEnv.WriteLine(InfoType.ERROR, $"theme key, data key : {themeKey}, {dataKey}");
|
||||
SereinEnv.WriteLine(InfoType.INFO, $"theme key, data key : {themeKey}, {dataKey}");
|
||||
foreach (var config in configs)
|
||||
{
|
||||
SereinEnv.WriteLine(InfoType.ERROR, $"theme value : {config.ThemeValue} ");
|
||||
SereinEnv.WriteLine(InfoType.INFO, $"theme value : {config.ThemeValue} ");
|
||||
var result = handleModule.AddHandleConfigs(config);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,11 +101,11 @@ namespace Serein.Library.Utils.SereinExpression
|
||||
{
|
||||
result = InvokeMethod(targetObJ, operand);
|
||||
}
|
||||
//else if (operation.Equals("@set",StringComparison.OrdinalIgnoreCase))
|
||||
//{
|
||||
// isChange = true;
|
||||
// result = SetMember(targetObJ, operand);
|
||||
//}
|
||||
else if (operation.Equals("@set",StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
isChange = true;
|
||||
result = SetMember(targetObJ, operand);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException($"Operation {operation} is not supported.");
|
||||
|
||||
Reference in New Issue
Block a user