mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-11 02:16:34 +08:00
将流程事件接口与流程运行环境解耦。
This commit is contained in:
@@ -22,7 +22,7 @@ namespace Serein.FlowStartTool
|
||||
flowEnvironment.SetUIContextOperation(uIContextOperation);
|
||||
flowEnvironment.LoadProject(new FlowEnvInfo { Project = flowProjectData }, fileDataPath); // 加载项目
|
||||
|
||||
flowEnvironment.Event.OnEnvOut += (infoType, value) =>
|
||||
flowEnvironment.Event.EnvOutput += (infoType, value) =>
|
||||
{
|
||||
Console.WriteLine($"{DateTime.Now} [{infoType}] : {value}{Environment.NewLine}");
|
||||
};
|
||||
|
||||
@@ -120,11 +120,6 @@ namespace Serein.Library.Api
|
||||
/// <param name="eventArgs"></param>
|
||||
public delegate void NodeLocatedHandler(NodeLocatedEventArgs eventArgs);
|
||||
|
||||
/// <summary>
|
||||
/// 节点移动了(远程插件)
|
||||
/// </summary>
|
||||
/// <param name="eventArgs"></param>
|
||||
public delegate void NodeMovedHandler(NodeMovedEventArgs eventArgs);
|
||||
|
||||
/// <summary>
|
||||
/// 远程环境内容输出
|
||||
@@ -608,30 +603,30 @@ namespace Serein.Library.Api
|
||||
public string NodeGuid { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/* /// <summary>
|
||||
/// 节点移动了
|
||||
/// </summary>
|
||||
public class NodeMovedEventArgs : FlowEventArgs
|
||||
{
|
||||
public NodeMovedEventArgs(string nodeGuid, double x, double y)
|
||||
{
|
||||
this.NodeGuid = nodeGuid;
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
}
|
||||
/// <summary>
|
||||
/// 节点唯一标识
|
||||
/// </summary>
|
||||
public string NodeGuid { get; private set; }
|
||||
/// <summary>
|
||||
/// 画布上的x坐标
|
||||
/// </summary>
|
||||
public double X { get; private set; }
|
||||
/// <summary>
|
||||
/// 画布上的y坐标
|
||||
/// </summary>
|
||||
public double Y { get; private set; }
|
||||
}
|
||||
public NodeMovedEventArgs(string nodeGuid, double x, double y)
|
||||
{
|
||||
this.NodeGuid = nodeGuid;
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
}
|
||||
/// <summary>
|
||||
/// 节点唯一标识
|
||||
/// </summary>
|
||||
public string NodeGuid { get; private set; }
|
||||
/// <summary>
|
||||
/// 画布上的x坐标
|
||||
/// </summary>
|
||||
public double X { get; private set; }
|
||||
/// <summary>
|
||||
/// 画布上的y坐标
|
||||
/// </summary>
|
||||
public double Y { get; private set; }
|
||||
}*/
|
||||
|
||||
|
||||
#endregion
|
||||
@@ -645,97 +640,112 @@ namespace Serein.Library.Api
|
||||
/// <summary>
|
||||
/// 加载Dll
|
||||
/// </summary>
|
||||
event LoadDllHandler OnDllLoad;
|
||||
event LoadDllHandler DllLoad;
|
||||
|
||||
/// <summary>
|
||||
/// 项目加载完成
|
||||
/// </summary>
|
||||
event ProjectLoadedHandler OnProjectLoaded;
|
||||
event ProjectLoadedHandler ProjectLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// 项目准备保存
|
||||
/// </summary>
|
||||
event ProjectSavingHandler OnProjectSaving;
|
||||
event ProjectSavingHandler ProjectSaving;
|
||||
|
||||
/// <summary>
|
||||
/// 节点连接属性改变事件
|
||||
/// </summary>
|
||||
event NodeConnectChangeHandler OnNodeConnectChange;
|
||||
event NodeConnectChangeHandler NodeConnectChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 增加画布事件
|
||||
/// </summary>
|
||||
event CanvasCreateHandler OnCanvasCreate;
|
||||
event CanvasCreateHandler CanvasCreated;
|
||||
|
||||
/// <summary>
|
||||
/// 删除画布事件
|
||||
/// </summary>
|
||||
event CanvasRemoveHandler OnCanvasRemove;
|
||||
event CanvasRemoveHandler CanvasRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// 节点创建事件
|
||||
/// </summary>
|
||||
event NodeCreateHandler OnNodeCreate;
|
||||
event NodeCreateHandler NodeCreated;
|
||||
|
||||
/// <summary>
|
||||
/// 移除节点事件
|
||||
/// </summary>
|
||||
event NodeRemoveHandler OnNodeRemove;
|
||||
event NodeRemoveHandler NodeRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// 节点放置事件
|
||||
/// </summary>
|
||||
event NodePlaceHandler OnNodePlace;
|
||||
event NodePlaceHandler NodePlace;
|
||||
|
||||
/// <summary>
|
||||
/// 节点取出事件
|
||||
/// </summary>
|
||||
event NodeTakeOutHandler OnNodeTakeOut;
|
||||
event NodeTakeOutHandler NodeTakeOut;
|
||||
|
||||
/// <summary>
|
||||
/// 起始节点变化事件
|
||||
/// </summary>
|
||||
event StartNodeChangeHandler OnStartNodeChange;
|
||||
event StartNodeChangeHandler StartNodeChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 流程运行完成事件
|
||||
/// </summary>
|
||||
event FlowRunCompleteHandler OnFlowRunComplete;
|
||||
event FlowRunCompleteHandler FlowRunComplete;
|
||||
|
||||
/// <summary>
|
||||
/// 被监视的对象改变事件
|
||||
/// </summary>
|
||||
event MonitorObjectChangeHandler OnMonitorObjectChange;
|
||||
event MonitorObjectChangeHandler MonitorObjectChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 节点中断状态变化事件
|
||||
/// </summary>
|
||||
event NodeInterruptStateChangeHandler OnNodeInterruptStateChange;
|
||||
event NodeInterruptStateChangeHandler NodeInterruptStateChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 触发中断
|
||||
/// </summary>
|
||||
event ExpInterruptTriggerHandler OnInterruptTrigger;
|
||||
event ExpInterruptTriggerHandler InterruptTriggered;
|
||||
|
||||
/// <summary>
|
||||
/// IOC容器发生改变
|
||||
/// </summary>
|
||||
event IOCMembersChangedHandler OnIOCMembersChanged;
|
||||
event IOCMembersChangedHandler IOCMembersChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 节点需要定位
|
||||
/// </summary>
|
||||
event NodeLocatedHandler OnNodeLocated;
|
||||
event NodeLocatedHandler NodeLocated;
|
||||
|
||||
/// <summary>
|
||||
/// 节点移动了(远程环境)
|
||||
/// </summary>
|
||||
event NodeMovedHandler OnNodeMoved;
|
||||
|
||||
/// <summary>
|
||||
/// 运行环境输出
|
||||
/// </summary>
|
||||
event EnvOutHandler OnEnvOut;
|
||||
event EnvOutHandler EnvOutput;
|
||||
|
||||
public void OnDllLoad(LoadDllEventArgs eventArgs);
|
||||
public void OnProjectLoaded(ProjectLoadedEventArgs eventArgs);
|
||||
public void OnProjectSaving(ProjectSavingEventArgs eventArgs);
|
||||
public void OnNodeConnectChanged(NodeConnectChangeEventArgs eventArgs);
|
||||
public void OnCanvasCreated(CanvasCreateEventArgs eventArgs);
|
||||
public void OnCanvasRemoved(CanvasRemoveEventArgs eventArgs);
|
||||
public void OnNodeCreated(NodeCreateEventArgs eventArgs);
|
||||
public void OnNodeRemoved(NodeRemoveEventArgs eventArgs);
|
||||
public void OnNodePlace(NodePlaceEventArgs eventArgs);
|
||||
public void OnNodeTakeOut(NodeTakeOutEventArgs eventArgs);
|
||||
public void OnStartNodeChanged(StartNodeChangeEventArgs eventArgs);
|
||||
public void OnFlowRunComplete(FlowEventArgs eventArgs);
|
||||
public void OnMonitorObjectChanged(MonitorObjectEventArgs eventArgs);
|
||||
public void OnNodeInterruptStateChanged(NodeInterruptStateChangeEventArgs eventArgs);
|
||||
public void OnInterruptTriggered(InterruptTriggerEventArgs eventArgs);
|
||||
public void OnIOCMembersChanged(IOCMembersChangedEventArgs eventArgs);
|
||||
public void OnNodeLocated(NodeLocatedEventArgs eventArgs);
|
||||
public void OnEnvOutput(InfoType type, string value);
|
||||
}
|
||||
|
||||
|
||||
@@ -904,15 +914,6 @@ namespace Serein.Library.Api
|
||||
Task<bool> RemoveCanvasAsync(string canvasGuid);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 移动了某个节点(远程插件使用)
|
||||
/// </summary>
|
||||
/// <param name="canvasGuid">所在画布</param>
|
||||
/// <param name="nodeGuid"></param>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
void MoveNode(string canvasGuid, string nodeGuid, double x, double y);
|
||||
|
||||
/// <summary>
|
||||
/// 设置流程起点节点
|
||||
/// </summary>
|
||||
@@ -1202,7 +1203,7 @@ namespace Serein.Library.Api
|
||||
/// 节点定位
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid"></param>
|
||||
void NodeLocated(string nodeGuid);
|
||||
void NodeLocate(string nodeGuid);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -34,10 +34,6 @@
|
||||
/// </summary>
|
||||
public const string RemoveCanvas = nameof(RemoveCanvas);
|
||||
/// <summary>
|
||||
/// 尝试移动某个节点
|
||||
/// </summary>
|
||||
public const string MoveNode = nameof(MoveNode);
|
||||
/// <summary>
|
||||
/// 尝试设置流程起点
|
||||
/// </summary>
|
||||
public const string SetStartNode = nameof(SetStartNode);
|
||||
|
||||
@@ -10,14 +10,15 @@ namespace Serein.NodeFlow.Env
|
||||
/// <summary>
|
||||
/// 流程运行环境
|
||||
/// </summary>
|
||||
public class FlowEnvironment : IFlowEnvironment, IFlowEnvironmentEvent
|
||||
public class FlowEnvironment : IFlowEnvironment
|
||||
{
|
||||
public FlowEnvironment()
|
||||
{
|
||||
flowEnvironment = new LocalFlowEnvironment();
|
||||
flowEnvironmentEvent = new FlowEnvironmentEvent();
|
||||
flowEnvironment = new LocalFlowEnvironment(flowEnvironmentEvent);
|
||||
// 默认使用本地环境
|
||||
currentFlowEnvironment = flowEnvironment;
|
||||
currentFlowEnvironmentEvent = flowEnvironment;
|
||||
currentFlowEnvironmentEvent = flowEnvironmentEvent;
|
||||
SereinEnv.SetEnv(currentFlowEnvironment);
|
||||
}
|
||||
|
||||
@@ -105,135 +106,128 @@ namespace Serein.NodeFlow.Env
|
||||
public RunState FlowState { get => currentFlowEnvironment.FlowState; set => currentFlowEnvironment.FlowState = value; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event LoadDllHandler OnDllLoad {
|
||||
add { currentFlowEnvironmentEvent.OnDllLoad += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnDllLoad -= value; }
|
||||
public event LoadDllHandler DllLoad {
|
||||
add { currentFlowEnvironmentEvent.DllLoad += value; }
|
||||
remove { currentFlowEnvironmentEvent.DllLoad -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event ProjectLoadedHandler OnProjectLoaded
|
||||
public event ProjectLoadedHandler ProjectLoaded
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnProjectLoaded += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnProjectLoaded -= value; }
|
||||
add { currentFlowEnvironmentEvent.ProjectLoaded += value; }
|
||||
remove { currentFlowEnvironmentEvent.ProjectLoaded -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event ProjectSavingHandler? OnProjectSaving
|
||||
public event ProjectSavingHandler? ProjectSaving
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnProjectSaving += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnProjectSaving -= value; }
|
||||
add { currentFlowEnvironmentEvent.ProjectSaving += value; }
|
||||
remove { currentFlowEnvironmentEvent.ProjectSaving -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event NodeConnectChangeHandler OnNodeConnectChange
|
||||
public event NodeConnectChangeHandler NodeConnectChanged
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodeConnectChange += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodeConnectChange -= value; }
|
||||
add { currentFlowEnvironmentEvent.NodeConnectChanged += value; }
|
||||
remove { currentFlowEnvironmentEvent.NodeConnectChanged -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event CanvasCreateHandler OnCanvasCreate
|
||||
public event CanvasCreateHandler CanvasCreated
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnCanvasCreate += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnCanvasCreate -= value; }
|
||||
add { currentFlowEnvironmentEvent.CanvasCreated += value; }
|
||||
remove { currentFlowEnvironmentEvent.CanvasCreated -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event CanvasRemoveHandler OnCanvasRemove
|
||||
public event CanvasRemoveHandler CanvasRemoved
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnCanvasRemove += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnCanvasRemove -= value; }
|
||||
add { currentFlowEnvironmentEvent.CanvasRemoved += value; }
|
||||
remove { currentFlowEnvironmentEvent.CanvasRemoved -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event NodeCreateHandler OnNodeCreate
|
||||
public event NodeCreateHandler NodeCreated
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodeCreate += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodeCreate -= value; }
|
||||
add { currentFlowEnvironmentEvent.NodeCreated += value; }
|
||||
remove { currentFlowEnvironmentEvent.NodeCreated -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event NodeRemoveHandler OnNodeRemove
|
||||
public event NodeRemoveHandler NodeRemoved
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodeRemove += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodeRemove -= value; }
|
||||
add { currentFlowEnvironmentEvent.NodeRemoved += value; }
|
||||
remove { currentFlowEnvironmentEvent.NodeRemoved -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event NodePlaceHandler OnNodePlace
|
||||
public event NodePlaceHandler NodePlace
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodePlace += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodePlace -= value; }
|
||||
add { currentFlowEnvironmentEvent.NodePlace += value; }
|
||||
remove { currentFlowEnvironmentEvent.NodePlace -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event NodeTakeOutHandler OnNodeTakeOut
|
||||
public event NodeTakeOutHandler NodeTakeOut
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodeTakeOut += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodeTakeOut -= value; }
|
||||
add { currentFlowEnvironmentEvent.NodeTakeOut += value; }
|
||||
remove { currentFlowEnvironmentEvent.NodeTakeOut -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event StartNodeChangeHandler OnStartNodeChange
|
||||
public event StartNodeChangeHandler StartNodeChanged
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnStartNodeChange += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnStartNodeChange -= value; }
|
||||
add { currentFlowEnvironmentEvent.StartNodeChanged += value; }
|
||||
remove { currentFlowEnvironmentEvent.StartNodeChanged -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event FlowRunCompleteHandler OnFlowRunComplete
|
||||
public event FlowRunCompleteHandler FlowRunComplete
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnFlowRunComplete += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnFlowRunComplete -= value; }
|
||||
add { currentFlowEnvironmentEvent.FlowRunComplete += value; }
|
||||
remove { currentFlowEnvironmentEvent.FlowRunComplete -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event MonitorObjectChangeHandler OnMonitorObjectChange
|
||||
public event MonitorObjectChangeHandler MonitorObjectChanged
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnMonitorObjectChange += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnMonitorObjectChange -= value; }
|
||||
add { currentFlowEnvironmentEvent.MonitorObjectChanged += value; }
|
||||
remove { currentFlowEnvironmentEvent.MonitorObjectChanged -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event NodeInterruptStateChangeHandler OnNodeInterruptStateChange
|
||||
public event NodeInterruptStateChangeHandler NodeInterruptStateChanged
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodeInterruptStateChange += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodeInterruptStateChange -= value; }
|
||||
add { currentFlowEnvironmentEvent.NodeInterruptStateChanged += value; }
|
||||
remove { currentFlowEnvironmentEvent.NodeInterruptStateChanged -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event ExpInterruptTriggerHandler OnInterruptTrigger
|
||||
public event ExpInterruptTriggerHandler InterruptTriggered
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnInterruptTrigger += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnInterruptTrigger -= value; }
|
||||
add { currentFlowEnvironmentEvent.InterruptTriggered += value; }
|
||||
remove { currentFlowEnvironmentEvent.InterruptTriggered -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event IOCMembersChangedHandler OnIOCMembersChanged
|
||||
public event IOCMembersChangedHandler IOCMembersChanged
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnIOCMembersChanged += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnIOCMembersChanged -= value; }
|
||||
add { currentFlowEnvironmentEvent.IOCMembersChanged += value; }
|
||||
remove { currentFlowEnvironmentEvent.IOCMembersChanged -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event NodeLocatedHandler OnNodeLocated
|
||||
public event NodeLocatedHandler NodeLocated
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodeLocated += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodeLocated -= value; }
|
||||
add { currentFlowEnvironmentEvent.NodeLocated += value; }
|
||||
remove { currentFlowEnvironmentEvent.NodeLocated -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event NodeMovedHandler OnNodeMoved
|
||||
public event EnvOutHandler EnvOutput
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodeMoved += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodeMoved -= value; }
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event EnvOutHandler OnEnvOut
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnEnvOut += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnEnvOut -= value; }
|
||||
add { currentFlowEnvironmentEvent.EnvOutput += value; }
|
||||
remove { currentFlowEnvironmentEvent.EnvOutput -= value; }
|
||||
}
|
||||
|
||||
|
||||
@@ -287,7 +281,7 @@ namespace Serein.NodeFlow.Env
|
||||
if (isConnect)
|
||||
{
|
||||
|
||||
remoteFlowEnvironment ??= new RemoteFlowEnvironment(remoteMsgUtil, this.UIContextOperation);
|
||||
remoteFlowEnvironment ??= new RemoteFlowEnvironment(remoteMsgUtil, this.Event, this.UIContextOperation);
|
||||
currentFlowEnvironment = remoteFlowEnvironment;
|
||||
}
|
||||
return (isConnect, remoteMsgUtil);
|
||||
@@ -380,16 +374,16 @@ namespace Serein.NodeFlow.Env
|
||||
currentFlowEnvironment.MonitorObjectNotification(nodeGuid, monitorData, sourceType);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
/*/// <inheritdoc/>
|
||||
public void MoveNode(string canvasGuid, string nodeGuid, double x, double y)
|
||||
{
|
||||
currentFlowEnvironment.MoveNode(canvasGuid, nodeGuid, x, y);
|
||||
}
|
||||
|
||||
*/
|
||||
/// <inheritdoc/>
|
||||
public void NodeLocated(string nodeGuid)
|
||||
public void NodeLocate(string nodeGuid)
|
||||
{
|
||||
currentFlowEnvironment.NodeLocated(nodeGuid);
|
||||
currentFlowEnvironment.NodeLocate(nodeGuid);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
121
NodeFlow/Env/FlowEnvironmentEvent.cs
Normal file
121
NodeFlow/Env/FlowEnvironmentEvent.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using Serein.Library;
|
||||
using Serein.Library.Api;
|
||||
|
||||
namespace Serein.NodeFlow.Env
|
||||
{
|
||||
public class FlowEnvironmentEvent : IFlowEnvironmentEvent
|
||||
{
|
||||
public event LoadDllHandler DllLoad;
|
||||
public event ProjectLoadedHandler ProjectLoaded;
|
||||
public event ProjectSavingHandler ProjectSaving;
|
||||
public event NodeConnectChangeHandler NodeConnectChanged;
|
||||
public event CanvasCreateHandler CanvasCreated;
|
||||
public event CanvasRemoveHandler CanvasRemoved;
|
||||
public event NodeCreateHandler NodeCreated;
|
||||
public event NodeRemoveHandler NodeRemoved;
|
||||
public event NodePlaceHandler NodePlace;
|
||||
public event NodeTakeOutHandler NodeTakeOut;
|
||||
public event StartNodeChangeHandler StartNodeChanged;
|
||||
public event FlowRunCompleteHandler FlowRunComplete;
|
||||
public event MonitorObjectChangeHandler MonitorObjectChanged;
|
||||
public event NodeInterruptStateChangeHandler NodeInterruptStateChanged;
|
||||
public event ExpInterruptTriggerHandler InterruptTriggered;
|
||||
public event IOCMembersChangedHandler IOCMembersChanged;
|
||||
public event NodeLocatedHandler NodeLocated;
|
||||
public event EnvOutHandler EnvOutput;
|
||||
|
||||
public void OnDllLoad(LoadDllEventArgs eventArgs)
|
||||
{
|
||||
DllLoad.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnProjectLoaded(ProjectLoadedEventArgs eventArgs)
|
||||
{
|
||||
ProjectLoaded.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnProjectSaving(ProjectSavingEventArgs eventArgs)
|
||||
{
|
||||
ProjectSaving.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnNodeConnectChanged(NodeConnectChangeEventArgs eventArgs)
|
||||
{
|
||||
NodeConnectChanged.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnCanvasCreated(CanvasCreateEventArgs eventArgs)
|
||||
{
|
||||
CanvasCreated.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnCanvasRemoved(CanvasRemoveEventArgs eventArgs)
|
||||
{
|
||||
CanvasRemoved.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnNodeCreated(NodeCreateEventArgs eventArgs)
|
||||
{
|
||||
NodeCreated.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnNodeRemoved(NodeRemoveEventArgs eventArgs)
|
||||
{
|
||||
NodeRemoved.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnNodePlace(NodePlaceEventArgs eventArgs)
|
||||
{
|
||||
NodePlace.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnNodeTakeOut(NodeTakeOutEventArgs eventArgs)
|
||||
{
|
||||
NodeTakeOut.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnStartNodeChanged(StartNodeChangeEventArgs eventArgs)
|
||||
{
|
||||
StartNodeChanged.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnFlowRunComplete(FlowEventArgs eventArgs)
|
||||
{
|
||||
FlowRunComplete.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnMonitorObjectChanged(MonitorObjectEventArgs eventArgs)
|
||||
{
|
||||
MonitorObjectChanged.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnNodeInterruptStateChanged(NodeInterruptStateChangeEventArgs eventArgs)
|
||||
{
|
||||
NodeInterruptStateChanged.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnInterruptTriggered(InterruptTriggerEventArgs eventArgs)
|
||||
{
|
||||
InterruptTriggered.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnIOCMembersChanged(IOCMembersChangedEventArgs eventArgs)
|
||||
{
|
||||
IOCMembersChanged.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnNodeLocated(NodeLocatedEventArgs eventArgs)
|
||||
{
|
||||
NodeLocated.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
public void OnEnvOutput(InfoType type, string value)
|
||||
{
|
||||
EnvOutput.Invoke(type, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -16,12 +16,27 @@ using System.Text;
|
||||
|
||||
namespace Serein.NodeFlow.Env
|
||||
{
|
||||
public class ADmmm
|
||||
{
|
||||
private readonly IFlowEnvironment flowEnvironment;
|
||||
private readonly IFlowEnvironmentEvent flowEnvironmentEvent;
|
||||
public ADmmm(IFlowEnvironment flowEnvironment, IFlowEnvironmentEvent flowEnvironmentEvent)
|
||||
{
|
||||
this.flowEnvironment = flowEnvironment;
|
||||
this.flowEnvironmentEvent = flowEnvironmentEvent;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 运行环境
|
||||
/// </summary>
|
||||
public class LocalFlowEnvironment : IFlowEnvironment, IFlowEnvironmentEvent
|
||||
public class LocalFlowEnvironment : IFlowEnvironment/*, IFlowEnvironmentEvent*/
|
||||
{
|
||||
/// <summary>
|
||||
/// 节点的命名空间
|
||||
@@ -34,18 +49,19 @@ namespace Serein.NodeFlow.Env
|
||||
/// <summary>
|
||||
/// 流程运行环境
|
||||
/// </summary>
|
||||
public LocalFlowEnvironment()
|
||||
public LocalFlowEnvironment(IFlowEnvironmentEvent flowEnvironmentEvent)
|
||||
{
|
||||
this.sereinIOC = new SereinIOC();
|
||||
this.Event = flowEnvironmentEvent;
|
||||
this.IsGlobalInterrupt = false;
|
||||
this.flowTaskManagement = null;
|
||||
this.sereinIOC.OnIOCMembersChanged += e =>
|
||||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
UIContextOperation?.Invoke(() => this?.OnIOCMembersChanged?.Invoke(e)); // 监听IOC容器的注册
|
||||
UIContextOperation?.Invoke(() => Event.OnIOCMembersChanged(e)); // 监听IOC容器的注册
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
this.FlowLibraryManagement = new FlowLibraryManagement(this); // 实例化类库管理
|
||||
this.NodeMVVMManagement = new NodeMVVMManagement();
|
||||
@@ -68,8 +84,8 @@ namespace Serein.NodeFlow.Env
|
||||
PersistennceInstance.Add(typeof(IFlowEnvironment), (LocalFlowEnvironment)this); // 缓存流程实例
|
||||
PersistennceInstance.Add(typeof(ISereinIOC), this); // 缓存容器服务
|
||||
|
||||
ReRegisterPersistennceInstance();
|
||||
|
||||
ReRegisterPersistennceInstance();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -115,10 +131,10 @@ namespace Serein.NodeFlow.Env
|
||||
#endregion
|
||||
|
||||
#region 环境运行事件
|
||||
/// <summary>
|
||||
/*/// <summary>
|
||||
/// 加载Dll
|
||||
/// </summary>
|
||||
public event LoadDllHandler? OnDllLoad;
|
||||
public event LoadDllHandler? DllLoad;
|
||||
|
||||
/// <summary>
|
||||
/// 移除DLL
|
||||
@@ -128,93 +144,88 @@ namespace Serein.NodeFlow.Env
|
||||
/// <summary>
|
||||
/// 项目加载完成
|
||||
/// </summary>
|
||||
public event ProjectLoadedHandler? OnProjectLoaded;
|
||||
public event ProjectLoadedHandler? ProjectLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// 项目准备保存
|
||||
/// </summary>
|
||||
public event ProjectSavingHandler? OnProjectSaving;
|
||||
public event ProjectSavingHandler? ProjectSaving;
|
||||
|
||||
/// <summary>
|
||||
/// 节点连接属性改变事件
|
||||
/// </summary>
|
||||
public event NodeConnectChangeHandler? OnNodeConnectChange;
|
||||
public event NodeConnectChangeHandler? NodeConnectChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 节点创建事件
|
||||
/// </summary>
|
||||
public event NodeCreateHandler? OnNodeCreate;
|
||||
public event NodeCreateHandler? NodeCreated;
|
||||
|
||||
/// <summary>
|
||||
/// 移除节点事件
|
||||
/// </summary>
|
||||
public event NodeRemoveHandler? OnNodeRemove;
|
||||
public event NodeRemoveHandler? NodeRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// 节点放置事件
|
||||
/// </summary>
|
||||
public event NodePlaceHandler OnNodePlace;
|
||||
public event NodePlaceHandler NodePlace;
|
||||
|
||||
/// <summary>
|
||||
/// 节点取出事件
|
||||
/// </summary>
|
||||
public event NodeTakeOutHandler OnNodeTakeOut;
|
||||
public event NodeTakeOutHandler NodeTakeOut;
|
||||
|
||||
/// <summary>
|
||||
/// 起始节点变化事件
|
||||
/// </summary>
|
||||
public event StartNodeChangeHandler? OnStartNodeChange;
|
||||
public event StartNodeChangeHandler? StartNodeChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 流程运行完成事件
|
||||
/// </summary>
|
||||
public event FlowRunCompleteHandler? OnFlowRunComplete;
|
||||
public event FlowRunCompleteHandler? FlowRunComplete;
|
||||
|
||||
/// <summary>
|
||||
/// 被监视的对象改变事件
|
||||
/// </summary>
|
||||
public event MonitorObjectChangeHandler? OnMonitorObjectChange;
|
||||
public event MonitorObjectChangeHandler? MonitorObjectChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 节点中断状态改变事件
|
||||
/// </summary>
|
||||
public event NodeInterruptStateChangeHandler? OnNodeInterruptStateChange;
|
||||
public event NodeInterruptStateChangeHandler? NodeInterruptStateChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 节点触发了中断
|
||||
/// </summary>
|
||||
public event ExpInterruptTriggerHandler? OnInterruptTrigger;
|
||||
public event ExpInterruptTriggerHandler? InterruptTriggered;
|
||||
|
||||
/// <summary>
|
||||
/// 容器改变
|
||||
/// </summary>
|
||||
public event IOCMembersChangedHandler? OnIOCMembersChanged;
|
||||
public event IOCMembersChangedHandler? IOCMembersChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 节点需要定位
|
||||
/// </summary>
|
||||
public event NodeLocatedHandler? OnNodeLocated;
|
||||
|
||||
/// <summary>
|
||||
/// 节点移动了(远程插件)
|
||||
/// </summary>
|
||||
public event NodeMovedHandler? OnNodeMoved;
|
||||
public event NodeLocatedHandler? NodeLocated;
|
||||
|
||||
/// <summary>
|
||||
/// 运行环境输出
|
||||
/// </summary>
|
||||
public event EnvOutHandler? OnEnvOut;
|
||||
public event EnvOutHandler? EnvOutput;
|
||||
|
||||
/// <summary>
|
||||
/// 本地环境添加了画布
|
||||
/// </summary>
|
||||
public event CanvasCreateHandler OnCanvasCreate;
|
||||
public event CanvasCreateHandler CanvasCreated;
|
||||
|
||||
/// <summary>
|
||||
/// 本地环境移除了画布
|
||||
/// </summary>
|
||||
public event CanvasRemoveHandler OnCanvasRemove;
|
||||
|
||||
public event CanvasRemoveHandler CanvasRemoved;
|
||||
*/
|
||||
#endregion
|
||||
|
||||
#region 属性
|
||||
@@ -227,7 +238,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <summary>
|
||||
/// 流程事件
|
||||
/// </summary>
|
||||
public IFlowEnvironmentEvent Event { get => this; }
|
||||
public IFlowEnvironmentEvent Event { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// UI线程操作类
|
||||
@@ -242,7 +253,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <summary>
|
||||
/// 信息输出等级
|
||||
/// </summary>
|
||||
public InfoClass InfoClass { get ; set ; } = InfoClass.Trivial;
|
||||
public InfoClass InfoClass { get; set; } = InfoClass.Trivial;
|
||||
|
||||
/// <summary>
|
||||
/// 如果没有全局触发器,且没有循环分支,流程执行完成后自动为 Completion 。
|
||||
@@ -282,7 +293,7 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
get
|
||||
{
|
||||
if(ioc is null)
|
||||
if (ioc is null)
|
||||
{
|
||||
ioc = new SereinIOC();
|
||||
}
|
||||
@@ -350,10 +361,10 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
if (@class >= this.InfoClass)
|
||||
{
|
||||
OnEnvOut?.Invoke(type, message);
|
||||
Event.OnEnvOutput(type, message);
|
||||
}
|
||||
//Console.WriteLine($"{DateTime.UtcNow} [{type}] : {message}{Environment.NewLine}");
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -378,7 +389,7 @@ namespace Serein.NodeFlow.Env
|
||||
isBreak = true;
|
||||
}
|
||||
var count = NodeModels.Values.Count(n => n.CanvasDetails.Guid.Equals(canvasGuid));
|
||||
if(count == 0)
|
||||
if (count == 0)
|
||||
{
|
||||
SereinEnv.WriteLine(InfoType.WARN, $"画布没有节点,停止运行。{canvasGuid}");
|
||||
isBreak = true;
|
||||
@@ -417,7 +428,7 @@ namespace Serein.NodeFlow.Env
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
IOC.Reset();
|
||||
IOC.Register<IScriptFlowApi, ScriptFlowApi>(); // 注册脚本接口
|
||||
@@ -428,7 +439,7 @@ namespace Serein.NodeFlow.Env
|
||||
Flows = flowTasks,
|
||||
FlowContextPool = new ObjectPool<IDynamicContext>(() => new DynamicContext(this)), // 上下文对象池
|
||||
AutoRegisterTypes = this.FlowLibraryManagement.GetaAutoRegisterType(), // 需要自动实例化的类型
|
||||
InitMds = this.FlowLibraryManagement.GetMdsOnFlowStart(NodeType.Init),
|
||||
InitMds = this.FlowLibraryManagement.GetMdsOnFlowStart(NodeType.Init),
|
||||
LoadMds = this.FlowLibraryManagement.GetMdsOnFlowStart(NodeType.Loading),
|
||||
ExitMds = this.FlowLibraryManagement.GetMdsOnFlowStart(NodeType.Exit),
|
||||
};
|
||||
@@ -447,16 +458,16 @@ namespace Serein.NodeFlow.Env
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
|
||||
SereinEnv.WriteLine(InfoType.INFO, $"流程运行完毕{Environment.NewLine}"); ;
|
||||
}
|
||||
flowTaskOptions = null;
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 从选定节点开始运行
|
||||
/// </summary>
|
||||
@@ -472,8 +483,8 @@ namespace Serein.NodeFlow.Env
|
||||
}
|
||||
if (true || FlowState == RunState.Running || FlipFlopState == RunState.Running)
|
||||
{
|
||||
|
||||
if (!TryGetNodeModel(startNodeGuid,out var nodeModel) || nodeModel is SingleFlipflopNode)
|
||||
|
||||
if (!TryGetNodeModel(startNodeGuid, out var nodeModel) || nodeModel is SingleFlipflopNode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -509,7 +520,7 @@ namespace Serein.NodeFlow.Env
|
||||
public Task<bool> ExitFlowAsync()
|
||||
{
|
||||
flowTaskManagement?.Exit();
|
||||
UIContextOperation?.Invoke(() => OnFlowRunComplete?.Invoke(new FlowEventArgs()));
|
||||
UIContextOperation?.Invoke(() => Event.OnFlowRunComplete(new FlowEventArgs()));
|
||||
IOC.Reset();
|
||||
flowTaskManagement = null;
|
||||
GC.Collect();
|
||||
@@ -522,7 +533,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <param name="nodeGuid"></param>
|
||||
public void ActivateFlipflopNode(string nodeGuid)
|
||||
{
|
||||
if(!TryGetNodeModel(nodeGuid, out var nodeModel))
|
||||
if (!TryGetNodeModel(nodeGuid, out var nodeModel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -544,7 +555,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <param name="nodeGuid"></param>
|
||||
public void TerminateFlipflopNode(string nodeGuid)
|
||||
{
|
||||
if(!TryGetNodeModel(nodeGuid, out var nodeModel))
|
||||
if (!TryGetNodeModel(nodeGuid, out var nodeModel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -579,8 +590,8 @@ namespace Serein.NodeFlow.Env
|
||||
/// </summary>
|
||||
public void SaveProject()
|
||||
{
|
||||
var project = GetProjectInfoAsync().GetAwaiter().GetResult();
|
||||
OnProjectSaving?.Invoke(new ProjectSavingEventArgs(project));
|
||||
var project = GetProjectInfoAsync().GetAwaiter().GetResult();
|
||||
Event.OnProjectSaving(new ProjectSavingEventArgs(project));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -605,10 +616,10 @@ namespace Serein.NodeFlow.Env
|
||||
LoadLibrary(dllFilePath); // 加载项目文件时加载对应的程序集
|
||||
}
|
||||
|
||||
|
||||
|
||||
_ = Task.Run( async () =>
|
||||
{
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
// 加载画布
|
||||
foreach (var canvasInfo in projectData.Canvass)
|
||||
{
|
||||
@@ -695,7 +706,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <returns></returns>
|
||||
public void LoadLibrary(string dllPath)
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
#region 检查是否已经加载本地依赖
|
||||
@@ -703,16 +714,16 @@ namespace Serein.NodeFlow.Env
|
||||
var thisAssemblyName = thisAssembly.GetName().Name;
|
||||
if (!string.IsNullOrEmpty(thisAssemblyName) && FlowLibraryManagement.GetLibraryMdsOfAssmbly(thisAssemblyName).Count == 0)
|
||||
{
|
||||
var tmp = FlowLibraryManagement.LoadLibraryOfPath(thisAssembly.Location);
|
||||
UIContextOperation?.Invoke(() => OnDllLoad?.Invoke(new LoadDllEventArgs(tmp.Item1, tmp.Item2))); // 通知UI创建dll面板显示
|
||||
var tmp = FlowLibraryManagement.LoadLibraryOfPath(thisAssembly.Location);
|
||||
UIContextOperation?.Invoke(() => Event.OnDllLoad(new LoadDllEventArgs(tmp.Item1, tmp.Item2))); // 通知UI创建dll面板显示
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
(var libraryInfo, var mdInfos) = FlowLibraryManagement.LoadLibraryOfPath(dllPath);
|
||||
if (mdInfos.Count > 0)
|
||||
{
|
||||
UIContextOperation?.Invoke(() => OnDllLoad?.Invoke(new LoadDllEventArgs(libraryInfo, mdInfos))); // 通知UI创建dll面板显示
|
||||
UIContextOperation?.Invoke(() => Event.OnDllLoad(new LoadDllEventArgs(libraryInfo, mdInfos))); // 通知UI创建dll面板显示
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -732,7 +743,7 @@ namespace Serein.NodeFlow.Env
|
||||
(var libraryInfo, var mdInfos) = FlowLibraryManagement.LoadLibraryOfPath(flowLibrary);
|
||||
if (mdInfos.Count > 0)
|
||||
{
|
||||
UIContextOperation?.Invoke(() => OnDllLoad?.Invoke(new LoadDllEventArgs(libraryInfo, mdInfos))); // 通知UI创建dll面板显示
|
||||
UIContextOperation?.Invoke(() => Event.OnDllLoad(new LoadDllEventArgs(libraryInfo, mdInfos))); // 通知UI创建dll面板显示
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -774,14 +785,14 @@ namespace Serein.NodeFlow.Env
|
||||
//var mds = FlowLibraryManagement.GetLibraryMdsOfAssmbly(assemblyName);
|
||||
//if(mds.Count > 0)
|
||||
//{
|
||||
|
||||
|
||||
|
||||
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return true;
|
||||
//}
|
||||
|
||||
|
||||
//var library = LibraryInfos.Values.FirstOrDefault(nl => assemblyName.Equals(nl.AssemblyName));
|
||||
//if (library is null)
|
||||
//{
|
||||
@@ -860,7 +871,7 @@ namespace Serein.NodeFlow.Env
|
||||
FlowCanvass.Add(model.Guid, model);
|
||||
UIContextOperation?.Invoke(() =>
|
||||
{
|
||||
OnCanvasCreate.Invoke(new CanvasCreateEventArgs(model));
|
||||
Event.OnCanvasCreated(new CanvasCreateEventArgs(model));
|
||||
});
|
||||
return model;
|
||||
}
|
||||
@@ -878,7 +889,7 @@ namespace Serein.NodeFlow.Env
|
||||
return false;
|
||||
}
|
||||
var count = NodeModels.Values.Count(node => node.CanvasDetails.Guid.Equals(canvasGuid));
|
||||
if(count > 0)
|
||||
if (count > 0)
|
||||
{
|
||||
SereinEnv.WriteLine(InfoType.WARN, "无法删除具有节点的画布");
|
||||
return false;
|
||||
@@ -887,11 +898,11 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
UIContextOperation?.Invoke(() =>
|
||||
{
|
||||
OnCanvasRemove.Invoke(new CanvasRemoveEventArgs(canvasGuid));
|
||||
Event.OnCanvasRemoved(new CanvasRemoveEventArgs(canvasGuid));
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -910,7 +921,7 @@ namespace Serein.NodeFlow.Env
|
||||
List<NodeInfo> flowCallNodeInfos = [];
|
||||
foreach (NodeInfo? nodeInfo in nodeInfos)
|
||||
{
|
||||
if(nodeInfo.Type == nameof(NodeControlType.FlowCall))
|
||||
if (nodeInfo.Type == nameof(NodeControlType.FlowCall))
|
||||
{
|
||||
flowCallNodeInfos.Add(nodeInfo);
|
||||
}
|
||||
@@ -956,10 +967,10 @@ namespace Serein.NodeFlow.Env
|
||||
var result = nodeContainer.PlaceNode(nodeModel);
|
||||
if (result)
|
||||
{
|
||||
UIContextOperation?.Invoke(() => OnNodePlace?.Invoke(
|
||||
new NodePlaceEventArgs(nodeInfo.CanvasGuid, nodeModel.Guid, containerNode.Guid)));
|
||||
UIContextOperation?.Invoke(() => Event.OnNodePlace(
|
||||
new NodePlaceEventArgs(nodeInfo.CanvasGuid, nodeModel.Guid, containerNode.Guid)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -987,10 +998,12 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (toNodeModel is null) {
|
||||
if (toNodeModel is null)
|
||||
{
|
||||
// 防御性代码,加载正常保存的项目文件不会进入这里
|
||||
continue;
|
||||
};
|
||||
}
|
||||
;
|
||||
var isSuccessful = ConnectInvokeOfNode(canvasGuid, fromNodeModel, toNodeModel, item.connectionType); // 加载时确定节点间的连接关系
|
||||
}
|
||||
}
|
||||
@@ -1042,7 +1055,7 @@ namespace Serein.NodeFlow.Env
|
||||
|
||||
UIContextOperation?.Invoke(() =>
|
||||
{
|
||||
OnProjectLoaded?.Invoke(new ProjectLoadedEventArgs());
|
||||
Event.OnProjectLoaded(new ProjectLoadedEventArgs());
|
||||
});
|
||||
|
||||
return;
|
||||
@@ -1055,17 +1068,17 @@ namespace Serein.NodeFlow.Env
|
||||
/// <param name="nodeControlType">所属类型</param>
|
||||
/// <param name="position">所处位置</param>
|
||||
/// <param name="methodDetailsInfo">如果是表达式节点条件节点,该项为null</param>
|
||||
public Task<NodeInfo> CreateNodeAsync(string canvasGuid,
|
||||
NodeControlType nodeControlType,
|
||||
public Task<NodeInfo> CreateNodeAsync(string canvasGuid,
|
||||
NodeControlType nodeControlType,
|
||||
PositionOfUI position,
|
||||
MethodDetailsInfo? methodDetailsInfo = null)
|
||||
{
|
||||
if (!TryGetCanvasModel(canvasGuid,out var canvasModel))
|
||||
if (!TryGetCanvasModel(canvasGuid, out var canvasModel))
|
||||
{
|
||||
return Task.FromResult<NodeInfo>(null);
|
||||
}
|
||||
IFlowNode? nodeModel;
|
||||
if (methodDetailsInfo is null
|
||||
if (methodDetailsInfo is null
|
||||
|| string.IsNullOrEmpty(methodDetailsInfo.AssemblyName)
|
||||
|| string.IsNullOrEmpty(methodDetailsInfo.MethodName))
|
||||
{
|
||||
@@ -1074,7 +1087,7 @@ namespace Serein.NodeFlow.Env
|
||||
else
|
||||
{
|
||||
if (FlowLibraryManagement.TryGetMethodDetails(methodDetailsInfo.AssemblyName, // 创建节点
|
||||
methodDetailsInfo.MethodName,
|
||||
methodDetailsInfo.MethodName,
|
||||
out var methodDetails))
|
||||
{
|
||||
nodeModel = FlowNodeExtension.CreateNode(this, nodeControlType, methodDetails); // 一般的加载节点方法
|
||||
@@ -1090,12 +1103,12 @@ namespace Serein.NodeFlow.Env
|
||||
nodeModel.Position = position; // 设置位置
|
||||
|
||||
// 通知UI更改
|
||||
UIContextOperation?.Invoke(() => OnNodeCreate?.Invoke(new NodeCreateEventArgs(canvasGuid, nodeModel, position)));
|
||||
UIContextOperation?.Invoke(() => Event.OnNodeCreated(new NodeCreateEventArgs(canvasGuid, nodeModel, position)));
|
||||
var nodeInfo = nodeModel.ToInfo();
|
||||
return Task.FromResult(nodeInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 将节点放置在容器中
|
||||
/// </summary>
|
||||
@@ -1115,7 +1128,7 @@ namespace Serein.NodeFlow.Env
|
||||
if (nodeModel.ContainerNode is INodeContainer tmpContainer)
|
||||
{
|
||||
SereinEnv.WriteLine(InfoType.WARN, $"节点放置失败,节点[{nodeGuid}]已经放置于容器节点[{((IFlowNode)tmpContainer).Guid}]");
|
||||
return Task.FromResult(false);
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
|
||||
if (!TryGetNodeModel(containerNodeGuid, out var containerNode))
|
||||
@@ -1129,7 +1142,7 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
UIContextOperation?.Invoke(() =>
|
||||
{
|
||||
OnNodePlace?.Invoke(new NodePlaceEventArgs(canvasGuid, nodeGuid, containerNodeGuid)); // 通知UI更改节点放置位置
|
||||
Event.OnNodePlace(new NodePlaceEventArgs(canvasGuid, nodeGuid, containerNodeGuid)); // 通知UI更改节点放置位置
|
||||
});
|
||||
}
|
||||
return Task.FromResult(result);
|
||||
@@ -1161,7 +1174,7 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
UIContextOperation?.Invoke(() =>
|
||||
{
|
||||
OnNodeTakeOut?.Invoke(new NodeTakeOutEventArgs(canvasGuid, nodeGuid)); // 重新放置在画布上
|
||||
Event.OnNodeTakeOut(new NodeTakeOutEventArgs(canvasGuid, nodeGuid)); // 重新放置在画布上
|
||||
});
|
||||
}
|
||||
return Task.FromResult(result);
|
||||
@@ -1178,7 +1191,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<bool> RemoveNodeAsync(string canvasGuid, string nodeGuid)
|
||||
{
|
||||
if (!TryGetCanvasModel(canvasGuid,out var canvasModel))
|
||||
if (!TryGetCanvasModel(canvasGuid, out var canvasModel))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1203,7 +1216,7 @@ namespace Serein.NodeFlow.Env
|
||||
IFlowNode? pNode = pnc.Value[i];
|
||||
pNode.SuccessorNodes[pCType].Remove(remoteNode);
|
||||
|
||||
UIContextOperation?.Invoke(() => OnNodeConnectChange?.Invoke(new NodeConnectChangeEventArgs(
|
||||
UIContextOperation?.Invoke(() => Event.OnNodeConnectChanged(new NodeConnectChangeEventArgs(
|
||||
canvasGuid,
|
||||
pNode.Guid,
|
||||
remoteNode.Guid,
|
||||
@@ -1215,7 +1228,7 @@ namespace Serein.NodeFlow.Env
|
||||
}
|
||||
|
||||
|
||||
if(remoteNode.ControlType == NodeControlType.FlowCall)
|
||||
if (remoteNode.ControlType == NodeControlType.FlowCall)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1242,7 +1255,7 @@ namespace Serein.NodeFlow.Env
|
||||
NodeModels.Remove(nodeGuid);
|
||||
UIContextOperation?.Invoke(() => canvasModel.Nodes.Remove(remoteNode));
|
||||
|
||||
UIContextOperation?.Invoke(() => OnNodeRemove?.Invoke(new NodeRemoveEventArgs(canvasGuid, nodeGuid)));
|
||||
UIContextOperation?.Invoke(() => Event.OnNodeRemoved(new NodeRemoveEventArgs(canvasGuid, nodeGuid)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1261,7 +1274,7 @@ namespace Serein.NodeFlow.Env
|
||||
JunctionType toNodeJunctionType,
|
||||
ConnectionInvokeType invokeType)
|
||||
{
|
||||
|
||||
|
||||
// 获取起始节点与目标节点
|
||||
if (!FlowCanvass.ContainsKey(canvasGuid) || !TryGetNodeModel(fromNodeGuid, out var fromNode) || !TryGetNodeModel(toNodeGuid, out var toNode))
|
||||
{
|
||||
@@ -1276,9 +1289,9 @@ namespace Serein.NodeFlow.Env
|
||||
return Task.FromResult(false); // 出现不符预期的连接行为,忽略此次连接行为
|
||||
}
|
||||
|
||||
if(type == JunctionOfConnectionType.Invoke)
|
||||
if (type == JunctionOfConnectionType.Invoke)
|
||||
{
|
||||
if (fromNodeJunctionType == JunctionType.Execute)
|
||||
if (fromNodeJunctionType == JunctionType.Execute)
|
||||
{
|
||||
// 如果 起始控制点 是“方法调用”,需要反转 from to 节点
|
||||
(fromNode, toNode) = (toNode, fromNode);
|
||||
@@ -1286,7 +1299,7 @@ namespace Serein.NodeFlow.Env
|
||||
// 从起始节点“下一个方法”控制点,连接到目标节点“方法调用”控制点
|
||||
state = ConnectInvokeOfNode(canvasGuid, fromNode, toNode, invokeType); // 本地环境进行连接
|
||||
}
|
||||
return Task.FromResult(state);
|
||||
return Task.FromResult(state);
|
||||
|
||||
}
|
||||
|
||||
@@ -1306,7 +1319,7 @@ namespace Serein.NodeFlow.Env
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
if (fromNode is null || toNode is null) return Task.FromResult(false);
|
||||
if ( fromNode.SuccessorNodes.TryGetValue(connectionType, out var nodes))
|
||||
if (fromNode.SuccessorNodes.TryGetValue(connectionType, out var nodes))
|
||||
{
|
||||
var idx = nodes.IndexOf(toNode);
|
||||
if (idx > -1)
|
||||
@@ -1349,7 +1362,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <param name="argIndex">目标节点的第几个参数</param>
|
||||
/// <param name="connectionArgSourceType">调用目标节点对应方法时,对应参数来源类型</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ConnectArgSourceNodeAsync(string canvasGuid,
|
||||
public async Task<bool> ConnectArgSourceNodeAsync(string canvasGuid,
|
||||
string fromNodeGuid,
|
||||
string toNodeGuid,
|
||||
JunctionType fromNodeJunctionType,
|
||||
@@ -1447,12 +1460,12 @@ namespace Serein.NodeFlow.Env
|
||||
/// <param name="uiContextOperation"></param>
|
||||
public void SetUIContextOperation(UIContextOperation uiContextOperation)
|
||||
{
|
||||
if(uiContextOperation is not null)
|
||||
if (uiContextOperation is not null)
|
||||
{
|
||||
this.UIContextOperation = uiContextOperation;
|
||||
PersistennceInstance[typeof(UIContextOperation)] = uiContextOperation; // 缓存封装好的UI线程上下文
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1463,23 +1476,6 @@ namespace Serein.NodeFlow.Env
|
||||
this.ioc = ioc; // 设置IOC容器
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移动了某个节点(远程插件使用)
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid"></param>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
public void MoveNode(string canvasGuid, string nodeGuid, double x, double y)
|
||||
{
|
||||
if (!FlowCanvass.ContainsKey(canvasGuid) || !TryGetNodeModel(nodeGuid, out var nodeModel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
nodeModel.Position.X = x;
|
||||
nodeModel.Position.Y = y;
|
||||
UIContextOperation?.Invoke(() => OnNodeMoved?.Invoke(new NodeMovedEventArgs(nodeGuid, x, y)));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置起点控件
|
||||
@@ -1504,7 +1500,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <param name="sourceType"></param>
|
||||
public void MonitorObjectNotification(string nodeGuid, object monitorData, MonitorObjectEventArgs.ObjSourceType sourceType)
|
||||
{
|
||||
OnMonitorObjectChange?.Invoke(new MonitorObjectEventArgs(nodeGuid, monitorData, sourceType));
|
||||
Event.OnMonitorObjectChanged(new MonitorObjectEventArgs(nodeGuid, monitorData, sourceType));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1515,7 +1511,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <param name="type">类型,0用户主动的中断,1表达式中断</param>
|
||||
public void TriggerInterrupt(string nodeGuid, string expression, InterruptTriggerEventArgs.InterruptTriggerType type)
|
||||
{
|
||||
OnInterruptTrigger?.Invoke(new InterruptTriggerEventArgs(nodeGuid, expression, type));
|
||||
Event.OnInterruptTriggered(new InterruptTriggerEventArgs(nodeGuid, expression, type));
|
||||
}
|
||||
|
||||
|
||||
@@ -1631,7 +1627,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <param name="nodeGuid">节点Guid</param>
|
||||
/// <returns>节点Model</returns>
|
||||
/// <exception cref="ArgumentNullException">无法获取节点、Guid/节点为null时报错</exception>
|
||||
public bool TryGetNodeModel(string nodeGuid,out IFlowNode nodeModel)
|
||||
public bool TryGetNodeModel(string nodeGuid, out IFlowNode nodeModel)
|
||||
{
|
||||
if (string.IsNullOrEmpty(nodeGuid))
|
||||
{
|
||||
@@ -1654,7 +1650,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <returns></returns>
|
||||
public bool LoadNativeLibraryOfRuning(string file)
|
||||
{
|
||||
|
||||
|
||||
return NativeDllHelper.LoadDll(file);
|
||||
}
|
||||
|
||||
@@ -1773,7 +1769,7 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
// 加载基础节点
|
||||
methodDetails = new MethodDetails();
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1807,7 +1803,7 @@ namespace Serein.NodeFlow.Env
|
||||
}
|
||||
|
||||
UIContextOperation?.Invoke(() =>
|
||||
OnNodeCreate?.Invoke(new NodeCreateEventArgs(nodeInfo.CanvasGuid, nodeModel, nodeInfo.Position))); // 添加到UI上
|
||||
Event.OnNodeCreated(new NodeCreateEventArgs(nodeInfo.CanvasGuid, nodeModel, nodeInfo.Position))); // 添加到UI上
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1831,7 +1827,7 @@ namespace Serein.NodeFlow.Env
|
||||
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
UIContextOperation?.Invoke(() => OnNodeConnectChange?.Invoke(
|
||||
UIContextOperation?.Invoke(() => Event.OnNodeConnectChanged(
|
||||
new NodeConnectChangeEventArgs(
|
||||
canvasGuid,
|
||||
fromNode.Guid,
|
||||
@@ -1839,10 +1835,10 @@ namespace Serein.NodeFlow.Env
|
||||
JunctionOfConnectionType.Invoke,
|
||||
connectionType,
|
||||
NodeConnectChangeEventArgs.ConnectChangeType.Remove)));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 移除连接关系
|
||||
/// </summary>
|
||||
/// <param name="fromNodeGuid">起始节点Model</param>
|
||||
@@ -1864,16 +1860,16 @@ namespace Serein.NodeFlow.Env
|
||||
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
UIContextOperation?.Invoke(() => OnNodeConnectChange?.Invoke(
|
||||
UIContextOperation?.Invoke(() => Event.OnNodeConnectChanged(
|
||||
new NodeConnectChangeEventArgs(
|
||||
canvasGuid,
|
||||
canvasGuid,
|
||||
fromNode.Guid,
|
||||
toNode.Guid,
|
||||
JunctionOfConnectionType.Arg,
|
||||
argIndex,
|
||||
ConnectionArgSourceType.GetPreviousNodeData,
|
||||
NodeConnectChangeEventArgs.ConnectChangeType.Remove)));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1886,7 +1882,7 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
nodeModel.Guid ??= Guid.NewGuid().ToString();
|
||||
NodeModels.TryAdd(nodeModel.Guid, nodeModel);
|
||||
|
||||
|
||||
|
||||
// 如果是触发器,则需要添加到专属集合中
|
||||
if (nodeModel is SingleFlipflopNode flipflopNode)
|
||||
@@ -1908,8 +1904,8 @@ namespace Serein.NodeFlow.Env
|
||||
/// <param name="fromNodeJunctionType">发起连接节点的控制点类型</param>
|
||||
/// <param name="toNodeJunctionType">被连接节点的控制点类型</param>
|
||||
/// <returns></returns>
|
||||
public static (JunctionOfConnectionType,bool) CheckConnect(IFlowNode fromNode,
|
||||
IFlowNode toNode,
|
||||
public static (JunctionOfConnectionType, bool) CheckConnect(IFlowNode fromNode,
|
||||
IFlowNode toNode,
|
||||
JunctionType fromNodeJunctionType,
|
||||
JunctionType toNodeJunctionType)
|
||||
{
|
||||
@@ -1947,7 +1943,7 @@ namespace Serein.NodeFlow.Env
|
||||
// type = JunctionOfConnectionType.Arg;
|
||||
// state = true;
|
||||
//}
|
||||
if(toNodeJunctionType == JunctionType.ReturnData && !fromNode.Guid.Equals(toNode.Guid))
|
||||
if (toNodeJunctionType == JunctionType.ReturnData && !fromNode.Guid.Equals(toNode.Guid))
|
||||
{
|
||||
// “”控制点拖拽到“方法返回值”控制点,且不是同一个节点,添加获取参数关系,生成参数时从目标节点获取flowdata
|
||||
type = JunctionOfConnectionType.Arg;
|
||||
@@ -1964,7 +1960,7 @@ namespace Serein.NodeFlow.Env
|
||||
}
|
||||
}
|
||||
// 剩下的情况都是不符预期的连接行为,忽略。
|
||||
return (type,state);
|
||||
return (type, state);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1975,7 +1971,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <param name="invokeType">连接关系</param>
|
||||
private bool ConnectInvokeOfNode(string canvasGuid, IFlowNode fromNode, IFlowNode toNode, ConnectionInvokeType invokeType)
|
||||
{
|
||||
if (fromNode.ControlType == NodeControlType.FlowCall)
|
||||
if (fromNode.ControlType == NodeControlType.FlowCall)
|
||||
{
|
||||
SereinEnv.WriteLine(InfoType.ERROR, $"流程接口节点不可调用下一个节点。" +
|
||||
$"{Environment.NewLine}流程节点:{fromNode.Guid}");
|
||||
@@ -2012,7 +2008,7 @@ namespace Serein.NodeFlow.Env
|
||||
FromExistInTo = ToOnF.Length > 0;
|
||||
if (ToExistOnFrom && FromExistInTo)
|
||||
{
|
||||
if(ctType == invokeType)
|
||||
if (ctType == invokeType)
|
||||
{
|
||||
SereinEnv.WriteLine(InfoType.WARN, $"起始节点已与目标节点存在连接。" +
|
||||
$"{Environment.NewLine}起始节点:{fromNode.Guid}" +
|
||||
@@ -2039,7 +2035,7 @@ namespace Serein.NodeFlow.Env
|
||||
$"{Environment.NewLine}起始节点:{fromNode.Guid}" +
|
||||
$"{Environment.NewLine}目标节点:{toNode.Guid}" +
|
||||
$"");
|
||||
isPass = false;
|
||||
isPass = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2059,13 +2055,13 @@ namespace Serein.NodeFlow.Env
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
|
||||
UIContextOperation?.Invoke(() =>
|
||||
OnNodeConnectChange?.Invoke(
|
||||
UIContextOperation?.Invoke(() =>
|
||||
Event.OnNodeConnectChanged(
|
||||
new NodeConnectChangeEventArgs(
|
||||
canvasGuid,
|
||||
fromNode.Guid, // 从哪个节点开始
|
||||
toNode.Guid, // 连接到那个节点
|
||||
JunctionOfConnectionType.Invoke,
|
||||
JunctionOfConnectionType.Invoke,
|
||||
invokeType, // 连接线的样式类型
|
||||
NodeConnectChangeEventArgs.ConnectChangeType.Create // 是创建连接还是删除连接
|
||||
))); // 通知UI
|
||||
@@ -2103,7 +2099,7 @@ namespace Serein.NodeFlow.Env
|
||||
|
||||
var toNodeArgSourceGuid = toNode.MethodDetails.ParameterDetailss[argIndex].ArgDataSourceNodeGuid;
|
||||
var toNodeArgSourceType = toNode.MethodDetails.ParameterDetailss[argIndex].ArgDataSourceType;
|
||||
if(fromNode.Guid == toNodeArgSourceGuid && toNodeArgSourceType == connectionArgSourceType)
|
||||
if (fromNode.Guid == toNodeArgSourceGuid && toNodeArgSourceType == connectionArgSourceType)
|
||||
{
|
||||
SereinEnv.WriteLine(InfoType.INFO, $"节点之间已建立过连接关系,此次操作将不会执行" +
|
||||
$"起始节点:{fromNode.Guid}" +
|
||||
@@ -2111,7 +2107,7 @@ namespace Serein.NodeFlow.Env
|
||||
$"参数索引:{argIndex}" +
|
||||
$"参数类型:{connectionArgSourceType}");
|
||||
UIContextOperation?.Invoke(() =>
|
||||
OnNodeConnectChange?.Invoke(
|
||||
Event.OnNodeConnectChanged(
|
||||
new NodeConnectChangeEventArgs(
|
||||
canvasGuid,
|
||||
fromNode.Guid, // 从哪个节点开始
|
||||
@@ -2125,7 +2121,7 @@ namespace Serein.NodeFlow.Env
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(toNodeArgSourceGuid) )
|
||||
if (!string.IsNullOrEmpty(toNodeArgSourceGuid))
|
||||
{
|
||||
await RemoteConnectAsync(canvasGuid, fromNode, toNode, argIndex);
|
||||
}
|
||||
@@ -2134,7 +2130,7 @@ namespace Serein.NodeFlow.Env
|
||||
toNode.MethodDetails.ParameterDetailss[argIndex].ArgDataSourceType = connectionArgSourceType;
|
||||
|
||||
UIContextOperation?.Invoke(() =>
|
||||
OnNodeConnectChange?.Invoke(
|
||||
Event.OnNodeConnectChanged(
|
||||
new NodeConnectChangeEventArgs(
|
||||
canvasGuid,
|
||||
fromNode.Guid, // 从哪个节点开始
|
||||
@@ -2162,7 +2158,7 @@ namespace Serein.NodeFlow.Env
|
||||
}*/
|
||||
cavnasModel.StartNode = newStartNode;
|
||||
//newStartNode.IsStart = true;
|
||||
UIContextOperation?.Invoke(() => OnStartNodeChange?.Invoke(new StartNodeChangeEventArgs(cavnasModel.Guid, oldNodeGuid, cavnasModel.StartNode.Guid)));
|
||||
UIContextOperation?.Invoke(() => Event.OnStartNodeChanged(new StartNodeChangeEventArgs(cavnasModel.Guid, oldNodeGuid, cavnasModel.StartNode.Guid)));
|
||||
|
||||
}
|
||||
|
||||
@@ -2176,7 +2172,7 @@ namespace Serein.NodeFlow.Env
|
||||
foreach (var kvp in PersistennceInstance)
|
||||
{
|
||||
IOC.Register(kvp.Key, () => kvp.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2188,31 +2184,19 @@ namespace Serein.NodeFlow.Env
|
||||
/// 定位节点
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid"></param>
|
||||
public void NodeLocated(string nodeGuid)
|
||||
public void NodeLocate(string nodeGuid)
|
||||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
UIContextOperation?.Invoke(() => OnNodeLocated?.Invoke(new NodeLocatedEventArgs(nodeGuid)));
|
||||
UIContextOperation?.Invoke(() => Event.OnNodeLocated(new NodeLocatedEventArgs(nodeGuid)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -554,17 +554,7 @@ namespace Serein.NodeFlow.Env
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移动了某个节点(远程插件使用)
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid"></param>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
[AutoSocketHandle(ThemeValue = EnvMsgTheme.MoveNode)]
|
||||
public void MoveNode(string canvasGuid, string nodeGuid, double x, double y)
|
||||
{
|
||||
environment.MoveNode(canvasGuid, nodeGuid, x, y);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置起点控件
|
||||
|
||||
@@ -15,16 +15,19 @@ namespace Serein.NodeFlow.Env
|
||||
/// <summary>
|
||||
/// 远程流程环境
|
||||
/// </summary>
|
||||
public class RemoteFlowEnvironment : ChannelFlowTrigger<string>, IFlowEnvironment , IFlowEnvironmentEvent
|
||||
public class RemoteFlowEnvironment : ChannelFlowTrigger<string>, IFlowEnvironment
|
||||
{
|
||||
/// <summary>
|
||||
/// 连接到远程环境后切换到的环境接口实现
|
||||
/// </summary>
|
||||
/// <param name="remoteMsgUtil">连接到远程环境后,本地环境自动切换到对应的环境实体</param>
|
||||
/// <param name="uIContextOperation">远程环境下需要操作UI线程时,所提供的线程上下文封装工具</param>
|
||||
public RemoteFlowEnvironment(RemoteMsgUtil remoteMsgUtil, UIContextOperation uIContextOperation)
|
||||
public RemoteFlowEnvironment(RemoteMsgUtil remoteMsgUtil,
|
||||
IFlowEnvironmentEvent flowEnvironmentEvent,
|
||||
UIContextOperation uIContextOperation)
|
||||
{
|
||||
this.UIContextOperation = uIContextOperation;
|
||||
this.Event = flowEnvironmentEvent;
|
||||
RemoteMsgUtil = remoteMsgUtil;
|
||||
msgClient = new MsgControllerOfClient(this, remoteMsgUtil.SendAsync); // 这里提供的是主动发送消息的方法
|
||||
remoteMsgUtil.EnvClient.MsgHandleHelper.AddModule(msgClient, (ex, send) =>
|
||||
@@ -43,32 +46,13 @@ namespace Serein.NodeFlow.Env
|
||||
/// </summary>
|
||||
private Dictionary<string, IFlowNode> NodeModels { get; } = [];
|
||||
|
||||
public event LoadDllHandler OnDllLoad;
|
||||
public event ProjectLoadedHandler OnProjectLoaded;
|
||||
public event ProjectSavingHandler OnProjectSaving;
|
||||
public event CanvasCreateHandler OnCanvasCreate;
|
||||
public event CanvasRemoveHandler OnCanvasRemove;
|
||||
public event NodeConnectChangeHandler OnNodeConnectChange;
|
||||
public event NodeCreateHandler OnNodeCreate;
|
||||
public event NodeRemoveHandler OnNodeRemove;
|
||||
public event NodePlaceHandler OnNodePlace;
|
||||
public event NodeTakeOutHandler OnNodeTakeOut;
|
||||
public event StartNodeChangeHandler OnStartNodeChange;
|
||||
public event FlowRunCompleteHandler OnFlowRunComplete;
|
||||
public event MonitorObjectChangeHandler OnMonitorObjectChange;
|
||||
public event NodeInterruptStateChangeHandler OnNodeInterruptStateChange;
|
||||
public event ExpInterruptTriggerHandler OnInterruptTrigger;
|
||||
public event IOCMembersChangedHandler OnIOCMembersChanged;
|
||||
public event NodeLocatedHandler OnNodeLocated;
|
||||
public event NodeMovedHandler OnNodeMoved;
|
||||
public event EnvOutHandler OnEnvOut;
|
||||
|
||||
public ISereinIOC IOC => throw new NotImplementedException();
|
||||
|
||||
/// <summary>
|
||||
/// 流程事件
|
||||
/// </summary>
|
||||
public IFlowEnvironmentEvent Event { get => this; }
|
||||
public IFlowEnvironmentEvent Event { get; private set; }
|
||||
public string EnvName => LocalFlowEnvironment.SpaceName;
|
||||
|
||||
/// <summary>
|
||||
@@ -116,7 +100,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// <param name="class">日志级别</param>
|
||||
public void WriteLine(InfoType type, string message, InfoClass @class = InfoClass.Trivial)
|
||||
{
|
||||
OnEnvOut?.Invoke(type, message);
|
||||
Event.OnEnvOutput(type, message);
|
||||
}
|
||||
|
||||
public async Task StartRemoteServerAsync(int port = 7525)
|
||||
@@ -151,7 +135,7 @@ namespace Serein.NodeFlow.Env
|
||||
var result = await msgClient.SendAndWaitDataAsync<SereinProjectData>(EnvMsgTheme.SaveProject);
|
||||
if (result is not null)
|
||||
{
|
||||
OnProjectSaving?.Invoke(new ProjectSavingEventArgs(result));
|
||||
Event.OnProjectSaving(new ProjectSavingEventArgs(result));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -186,7 +170,7 @@ namespace Serein.NodeFlow.Env
|
||||
FileName = "Remote",
|
||||
};
|
||||
var mdInfos = lib.Mds.ToList();
|
||||
UIContextOperation?.Invoke(() => OnDllLoad?.Invoke(new LoadDllEventArgs(nodeLibraryInfo, mdInfos))); // 通知UI创建dll面板显示
|
||||
UIContextOperation?.Invoke(() => Event.OnDllLoad(new LoadDllEventArgs(nodeLibraryInfo, mdInfos))); // 通知UI创建dll面板显示
|
||||
foreach (var mdInfo in mdInfos)
|
||||
{
|
||||
MethodDetailss.TryAdd(mdInfo.MethodName, new MethodDetails(mdInfo)); // 从DLL读取时生成元数据
|
||||
@@ -200,7 +184,7 @@ namespace Serein.NodeFlow.Env
|
||||
var canvasModel = new FlowCanvasDetails(this);
|
||||
canvasModel.LoadInfo(info);
|
||||
var e = new CanvasCreateEventArgs(canvasModel);
|
||||
OnCanvasCreate?.Invoke(e);
|
||||
Event.OnCanvasCreated(e);
|
||||
}
|
||||
|
||||
// 加载节点
|
||||
@@ -216,7 +200,7 @@ namespace Serein.NodeFlow.Env
|
||||
|
||||
UIContextOperation?.Invoke(() =>
|
||||
{
|
||||
OnProjectLoaded?.Invoke(new ProjectLoadedEventArgs()); // 加载完成
|
||||
Event.OnProjectLoaded(new ProjectLoadedEventArgs()); // 加载完成
|
||||
});
|
||||
IsLoadingProject = false;
|
||||
|
||||
@@ -488,7 +472,7 @@ namespace Serein.NodeFlow.Env
|
||||
Width = info.Width,
|
||||
};
|
||||
UIContextOperation?.Invoke(() =>
|
||||
OnCanvasCreate?.Invoke(new CanvasCreateEventArgs(model)));
|
||||
Event.OnCanvasCreated(new CanvasCreateEventArgs(model)));
|
||||
|
||||
return info;
|
||||
}
|
||||
@@ -510,40 +494,14 @@ namespace Serein.NodeFlow.Env
|
||||
if (result)
|
||||
{
|
||||
UIContextOperation?.Invoke(() =>
|
||||
OnCanvasRemove?.Invoke(new CanvasRemoveEventArgs(canvasGuid)));
|
||||
Event.OnCanvasRemoved(new CanvasRemoveEventArgs(canvasGuid)));
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 移动节点,通知远程环境也一起移动,保持相对位置一致
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid"></param>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
public void MoveNode(string cavnasGuid, string nodeGuid, double x, double y)
|
||||
{
|
||||
//UIContextOperation?.Invoke(() =>
|
||||
//{
|
||||
// OnNodeMoved?.Invoke(new NodeMovedEventArgs(nodeGuid, x, y));
|
||||
//});
|
||||
_ = msgClient.SendAsync(EnvMsgTheme.MoveNode,
|
||||
new
|
||||
{
|
||||
cavnasGuid,
|
||||
nodeGuid,
|
||||
x,
|
||||
y
|
||||
});
|
||||
|
||||
if(NodeModels.TryGetValue(nodeGuid, out var nodeModel))
|
||||
{
|
||||
nodeModel.Position.X = x;
|
||||
nodeModel.Position.Y = y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -561,7 +519,7 @@ namespace Serein.NodeFlow.Env
|
||||
});
|
||||
if (NodeModels.TryGetValue(newNodeGuid, out var nodeModel)) // 存在节点
|
||||
{
|
||||
UIContextOperation?.Invoke(() => OnStartNodeChange?.Invoke(new StartNodeChangeEventArgs(canvasGuid, nodeGuid, newNodeGuid)));
|
||||
UIContextOperation?.Invoke(() => Event.OnStartNodeChanged(new StartNodeChangeEventArgs(canvasGuid, nodeGuid, newNodeGuid)));
|
||||
}
|
||||
return newNodeGuid;
|
||||
}
|
||||
@@ -622,7 +580,7 @@ namespace Serein.NodeFlow.Env
|
||||
var result = await msgClient.SendAndWaitDataAsync<bool>(EnvMsgTheme.ConnectInvokeNode, sendObj);
|
||||
if (result)
|
||||
{
|
||||
OnNodeConnectChange?.Invoke(new NodeConnectChangeEventArgs(canvasGuid,
|
||||
Event.OnNodeConnectChanged(new NodeConnectChangeEventArgs(canvasGuid,
|
||||
fromNodeGuid,
|
||||
toNodeGuid,
|
||||
JunctionOfConnectionType.Invoke,
|
||||
@@ -697,7 +655,7 @@ namespace Serein.NodeFlow.Env
|
||||
var result = await msgClient.SendAndWaitDataAsync<bool>(EnvMsgTheme.ConnectArgSourceNode, sendObj);
|
||||
if (result)
|
||||
{
|
||||
OnNodeConnectChange?.Invoke(new NodeConnectChangeEventArgs(canvasGuid,
|
||||
Event.OnNodeConnectChanged(new NodeConnectChangeEventArgs(canvasGuid,
|
||||
fromNodeGuid,
|
||||
toNodeGuid,
|
||||
JunctionOfConnectionType.Arg,
|
||||
@@ -739,7 +697,7 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
UIContextOperation.Invoke(() =>
|
||||
{
|
||||
OnNodeConnectChange?.Invoke(new NodeConnectChangeEventArgs(canvasGuid,
|
||||
Event.OnNodeConnectChanged(new NodeConnectChangeEventArgs(canvasGuid,
|
||||
fromNodeGuid,
|
||||
toNodeGuid,
|
||||
JunctionOfConnectionType.Invoke,
|
||||
@@ -768,7 +726,7 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
UIContextOperation.Invoke(() =>
|
||||
{
|
||||
OnNodeConnectChange?.Invoke(new NodeConnectChangeEventArgs(canvasGuid,
|
||||
Event.OnNodeConnectChanged(new NodeConnectChangeEventArgs(canvasGuid,
|
||||
fromNodeGuid,
|
||||
toNodeGuid,
|
||||
JunctionOfConnectionType.Arg,
|
||||
@@ -914,7 +872,7 @@ namespace Serein.NodeFlow.Env
|
||||
// 通知UI更改
|
||||
UIContextOperation.Invoke(() =>
|
||||
{
|
||||
OnNodeCreate?.Invoke(new NodeCreateEventArgs(canvasGuid, nodeModel, position));
|
||||
Event.OnNodeCreated(new NodeCreateEventArgs(canvasGuid, nodeModel, position));
|
||||
});
|
||||
return nodeInfo;
|
||||
}
|
||||
@@ -945,7 +903,7 @@ namespace Serein.NodeFlow.Env
|
||||
// 通知UI更改
|
||||
UIContextOperation.Invoke(() =>
|
||||
{
|
||||
OnNodePlace?.Invoke(new NodePlaceEventArgs(canvasGuid, nodeGuid, containerNodeGuid)); // 通知UI更改节点放置位置
|
||||
Event.OnNodePlace(new NodePlaceEventArgs(canvasGuid, nodeGuid, containerNodeGuid)); // 通知UI更改节点放置位置
|
||||
});
|
||||
}
|
||||
return result;
|
||||
@@ -977,7 +935,7 @@ namespace Serein.NodeFlow.Env
|
||||
// 通知UI更改
|
||||
UIContextOperation.Invoke(() =>
|
||||
{
|
||||
OnNodeTakeOut?.Invoke(new NodeTakeOutEventArgs(canvasGuid, nodeGuid)); // 重新放置在画布上
|
||||
Event.OnNodeTakeOut(new NodeTakeOutEventArgs(canvasGuid, nodeGuid)); // 重新放置在画布上
|
||||
});
|
||||
}
|
||||
return result;
|
||||
@@ -1002,7 +960,7 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
UIContextOperation.Invoke(() =>
|
||||
{
|
||||
OnNodeRemove?.Invoke(new NodeRemoveEventArgs(canvasGuid, nodeGuid));
|
||||
Event.OnNodeRemoved(new NodeRemoveEventArgs(canvasGuid, nodeGuid));
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -1102,9 +1060,9 @@ namespace Serein.NodeFlow.Env
|
||||
/// 需要定位某个节点
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid"></param>
|
||||
public void NodeLocated(string nodeGuid)
|
||||
public void NodeLocate(string nodeGuid)
|
||||
{
|
||||
UIContextOperation?.Invoke(() => OnNodeLocated?.Invoke(new NodeLocatedEventArgs(nodeGuid)));
|
||||
UIContextOperation?.Invoke(() => Event.OnNodeLocated(new NodeLocatedEventArgs(nodeGuid)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1236,7 +1194,7 @@ namespace Serein.NodeFlow.Env
|
||||
TryAddNode(nodeModel); // 加载项目时将节点加载到环境中
|
||||
|
||||
UIContextOperation?.Invoke(() =>
|
||||
OnNodeCreate?.Invoke(new NodeCreateEventArgs(canvasGuid, nodeModel, nodeInfo.Position))); // 添加到UI上
|
||||
Event.OnNodeCreated(new NodeCreateEventArgs(canvasGuid, nodeModel, nodeInfo.Position))); // 添加到UI上
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1258,8 +1216,8 @@ namespace Serein.NodeFlow.Env
|
||||
var canvasGuid = nodeInfo.CanvasGuid;
|
||||
childNode.ContainerNode = parentNode;
|
||||
parentNode.ChildrenNode.Add(childNode);
|
||||
UIContextOperation?.Invoke(() =>
|
||||
OnNodePlace?.Invoke(new NodePlaceEventArgs(canvasGuid,nodeInfo.Guid, nodeInfo.ParentNodeGuid)) // 通知UI更改节点放置位置
|
||||
UIContextOperation?.Invoke(() =>
|
||||
Event.OnNodePlace(new NodePlaceEventArgs(canvasGuid,nodeInfo.Guid, nodeInfo.ParentNodeGuid)) // 通知UI更改节点放置位置
|
||||
);
|
||||
|
||||
}
|
||||
@@ -1294,7 +1252,7 @@ namespace Serein.NodeFlow.Env
|
||||
// 遍历当前类型分支的节点(确认连接关系)
|
||||
foreach (var toNode in item.toNodes)
|
||||
{
|
||||
UIContextOperation?.Invoke(() => OnNodeConnectChange?.Invoke(new NodeConnectChangeEventArgs(canvasGuid,
|
||||
UIContextOperation?.Invoke(() => Event.OnNodeConnectChanged(new NodeConnectChangeEventArgs(canvasGuid,
|
||||
fromNode.Guid,
|
||||
toNode.Guid,
|
||||
JunctionOfConnectionType.Invoke,
|
||||
@@ -1320,7 +1278,7 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
var canvasGuid = toNode.CanvasDetails.Guid;
|
||||
UIContextOperation?.Invoke(() =>
|
||||
OnNodeConnectChange?.Invoke(
|
||||
Event.OnNodeConnectChanged(
|
||||
new NodeConnectChangeEventArgs(
|
||||
canvasGuid,
|
||||
fromNode.Guid, // 从哪个节点开始
|
||||
@@ -1335,7 +1293,7 @@ namespace Serein.NodeFlow.Env
|
||||
}
|
||||
#endregion
|
||||
});
|
||||
UIContextOperation?.Invoke(() => OnProjectLoaded?.Invoke(new ProjectLoadedEventArgs()));
|
||||
UIContextOperation?.Invoke(() => Event.OnProjectLoaded(new ProjectLoadedEventArgs()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
92
NodeFlow/Model/Operation/OperationBase.cs
Normal file
92
NodeFlow/Model/Operation/OperationBase.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.NodeFlow.Model.Operation
|
||||
{
|
||||
|
||||
class Test {
|
||||
|
||||
/// <summary>
|
||||
/// 撤销栈
|
||||
/// </summary>
|
||||
private Stack<IOperation> undoStack = [];
|
||||
/// <summary>
|
||||
/// 重做栈
|
||||
/// </summary>
|
||||
private Stack<IOperation> redoStack = [];
|
||||
|
||||
|
||||
/*
|
||||
// 执行新命令时,将命令推入撤销栈,并清空重做栈
|
||||
undoStack.Push(operation);
|
||||
redoStack.Clear();
|
||||
*/
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 撤销
|
||||
/// </summary>
|
||||
public void Undo()
|
||||
{
|
||||
if (undoStack.Count > 0)
|
||||
{
|
||||
var command = undoStack.Pop();
|
||||
command.Undo(); // 执行撤销
|
||||
redoStack.Push(command); // 将撤销的命令推入重做栈
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重做
|
||||
/// </summary>
|
||||
public void Redo()
|
||||
{
|
||||
if (redoStack.Count > 0)
|
||||
{
|
||||
var command = redoStack.Pop();
|
||||
command.Execute();
|
||||
undoStack.Push(command); // 将重做的命令推入撤销栈
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
internal class OperationInfo
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal abstract class OperationBase : IOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作的主题
|
||||
/// </summary>
|
||||
public required string Theme { get; set; }
|
||||
|
||||
public abstract void Execute();
|
||||
public abstract void Undo();
|
||||
public abstract void ToInfo();
|
||||
|
||||
protected OperationBase()
|
||||
{
|
||||
|
||||
}
|
||||
protected OperationBase(OperationInfo info)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal interface IOperation
|
||||
{
|
||||
void Execute(); // 执行操作
|
||||
void Undo(); // 撤销操作
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -227,12 +227,12 @@ namespace Serein.NodeFlow.Model
|
||||
};
|
||||
|
||||
var envEvent = (IFlowEnvironmentEvent)context.Env;
|
||||
envEvent.OnFlowRunComplete += onFlowStop; // 防止运行后台流程
|
||||
envEvent.FlowRunComplete += onFlowStop; // 防止运行后台流程
|
||||
|
||||
if (token.IsCancellationRequested) return null;
|
||||
|
||||
var result = await ScriptInterpreter.InterpretAsync(scriptContext, mainNode); // 从入口节点执行
|
||||
envEvent.OnFlowRunComplete -= onFlowStop;
|
||||
envEvent.FlowRunComplete -= onFlowStop;
|
||||
return new FlowResult(this, context, result);
|
||||
}
|
||||
|
||||
|
||||
12
NodeFlow/Services/NodeService.cs
Normal file
12
NodeFlow/Services/NodeService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.NodeFlow.Services
|
||||
{
|
||||
internal class NodeService
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -78,8 +78,8 @@ namespace Serein.Workbench.Node.ViewModel
|
||||
|
||||
private void InitEvent()
|
||||
{
|
||||
flowEEForwardingService.OnCanvasCreate += (e) => RershCanvass(); // 画布创建了
|
||||
flowEEForwardingService.OnCanvasRemove += (e) => RershCanvass(); // 画布移除了
|
||||
flowEEForwardingService.CanvasCreated += (e) => RershCanvass(); // 画布创建了
|
||||
flowEEForwardingService.CanvasRemoved += (e) => RershCanvass(); // 画布移除了
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Serein.Workbench
|
||||
flowEnvironment.SetUIContextOperation(uIContextOperation);
|
||||
collection.AddSingleton<UIContextOperation>(uIContextOperation); // 注册UI线程操作上下文
|
||||
collection.AddSingleton<IFlowEnvironment>(flowEnvironment); // 注册运行环境
|
||||
collection.AddSingleton<IFlowEnvironmentEvent>(flowEnvironment); // 注册运行环境事件
|
||||
collection.AddSingleton<IFlowEnvironmentEvent>(flowEnvironment.Event); // 注册运行环境事件
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -49,79 +49,75 @@ namespace Serein.Workbench.Services
|
||||
/// <summary>
|
||||
/// 加载了依赖文件事件
|
||||
/// </summary>
|
||||
public event LoadDllHandler? OnDllLoad;
|
||||
public event LoadDllHandler? DllLoad;
|
||||
/// <summary>
|
||||
/// 项目加载完成事件
|
||||
/// </summary>
|
||||
public event ProjectLoadedHandler? OnProjectLoaded;
|
||||
public event ProjectLoadedHandler? ProjectLoaded;
|
||||
/// <summary>
|
||||
/// 项目保存中事件
|
||||
/// </summary>
|
||||
public event ProjectSavingHandler? OnProjectSaving;
|
||||
public event ProjectSavingHandler? ProjectSaving;
|
||||
/// <summary>
|
||||
/// 节点连接改变事件
|
||||
/// </summary>
|
||||
public event NodeConnectChangeHandler? OnNodeConnectChange;
|
||||
public event NodeConnectChangeHandler? NodeConnectChanged;
|
||||
/// <summary>
|
||||
/// 节点创建事件
|
||||
/// </summary>
|
||||
public event NodeCreateHandler? OnNodeCreate;
|
||||
public event NodeCreateHandler? NodeCreated;
|
||||
/// <summary>
|
||||
/// 节点移除事件
|
||||
/// </summary>
|
||||
public event NodeRemoveHandler? OnNodeRemove;
|
||||
public event NodeRemoveHandler? NodeRemoved;
|
||||
/// <summary>
|
||||
/// 节点放置容器事件
|
||||
/// </summary>
|
||||
public event NodePlaceHandler? OnNodePlace;
|
||||
public event NodePlaceHandler? NodePlace;
|
||||
/// <summary>
|
||||
/// 节点取出事件
|
||||
/// </summary>
|
||||
public event NodeTakeOutHandler? OnNodeTakeOut;
|
||||
public event NodeTakeOutHandler? NodeTakeOut;
|
||||
/// <summary>
|
||||
/// 流程起始节点改变事件
|
||||
/// </summary>
|
||||
public event StartNodeChangeHandler? OnStartNodeChange;
|
||||
public event StartNodeChangeHandler? StartNodeChanged;
|
||||
/// <summary>
|
||||
/// 流程运行完毕事件
|
||||
/// </summary>
|
||||
public event FlowRunCompleteHandler? OnFlowRunComplete;
|
||||
public event FlowRunCompleteHandler? FlowRunComplete;
|
||||
/// <summary>
|
||||
/// 被监视的对象数据改变事件
|
||||
/// </summary>
|
||||
public event MonitorObjectChangeHandler? OnMonitorObjectChange;
|
||||
public event MonitorObjectChangeHandler? MonitorObjectChanged;
|
||||
/// <summary>
|
||||
/// 节点中断状态改变事件
|
||||
/// </summary>
|
||||
public event NodeInterruptStateChangeHandler? OnNodeInterruptStateChange;
|
||||
public event NodeInterruptStateChangeHandler? NodeInterruptStateChanged;
|
||||
/// <summary>
|
||||
/// 表达式中断触发事件
|
||||
/// </summary>
|
||||
public event ExpInterruptTriggerHandler? OnInterruptTrigger;
|
||||
public event ExpInterruptTriggerHandler? InterruptTriggered;
|
||||
/// <summary>
|
||||
/// 容器对象改变事件
|
||||
/// </summary>
|
||||
public event IOCMembersChangedHandler? OnIOCMembersChanged;
|
||||
public event IOCMembersChangedHandler? IOCMembersChanged;
|
||||
/// <summary>
|
||||
/// 节点定位事件
|
||||
/// </summary>
|
||||
public event NodeLocatedHandler? OnNodeLocated;
|
||||
/// <summary>
|
||||
/// 节点移动事件
|
||||
/// </summary>
|
||||
public event NodeMovedHandler? OnNodeMoved;
|
||||
public event NodeLocatedHandler? NodeLocated;
|
||||
/// <summary>
|
||||
/// 运行环境输出事件
|
||||
/// </summary>
|
||||
public event EnvOutHandler? OnEnvOut;
|
||||
public event EnvOutHandler? EnvOutput;
|
||||
/// <summary>
|
||||
/// 添加画布事件
|
||||
/// </summary>
|
||||
public event CanvasCreateHandler OnCanvasCreate;
|
||||
public event CanvasCreateHandler CanvasCreated;
|
||||
/// <summary>
|
||||
/// 移除了画布事件
|
||||
/// </summary>
|
||||
public event CanvasRemoveHandler OnCanvasRemove;
|
||||
public event CanvasRemoveHandler CanvasRemoved;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -129,55 +125,53 @@ namespace Serein.Workbench.Services
|
||||
|
||||
private void InitFlowEnvironmentEvent()
|
||||
{
|
||||
flowEnvironmentEvent.OnDllLoad += FlowEnvironment_DllLoadEvent;
|
||||
flowEnvironmentEvent.OnProjectSaving += FlowEnvironment_OnProjectSaving;
|
||||
flowEnvironmentEvent.OnProjectLoaded += FlowEnvironment_OnProjectLoaded;
|
||||
flowEnvironmentEvent.OnCanvasCreate += FlowEnvironmentEvent_OnCanvasCreate;
|
||||
flowEnvironmentEvent.OnCanvasRemove += FlowEnvironmentEvent_OnCanvasRemove;
|
||||
flowEnvironmentEvent.OnStartNodeChange += FlowEnvironment_StartNodeChangeEvent;
|
||||
flowEnvironmentEvent.OnNodeConnectChange += FlowEnvironment_NodeConnectChangeEvemt;
|
||||
flowEnvironmentEvent.OnNodeCreate += FlowEnvironment_NodeCreateEvent;
|
||||
flowEnvironmentEvent.OnNodeRemove += FlowEnvironment_NodeRemoveEvent;
|
||||
flowEnvironmentEvent.OnNodePlace += FlowEnvironment_OnNodePlaceEvent;
|
||||
flowEnvironmentEvent.OnNodeTakeOut += FlowEnvironment_OnNodeTakeOutEvent;
|
||||
flowEnvironmentEvent.OnFlowRunComplete += FlowEnvironment_OnFlowRunCompleteEvent;
|
||||
flowEnvironmentEvent.DllLoad += FlowEnvironment_DllLoadEvent;
|
||||
flowEnvironmentEvent.ProjectSaving += FlowEnvironment_OnProjectSaving;
|
||||
flowEnvironmentEvent.ProjectLoaded += FlowEnvironment_OnProjectLoaded;
|
||||
flowEnvironmentEvent.CanvasCreated += FlowEnvironmentEvent_OnCanvasCreate;
|
||||
flowEnvironmentEvent.CanvasRemoved += FlowEnvironmentEvent_OnCanvasRemove;
|
||||
flowEnvironmentEvent.StartNodeChanged += FlowEnvironment_StartNodeChangeEvent;
|
||||
flowEnvironmentEvent.NodeConnectChanged += FlowEnvironment_NodeConnectChangeEvemt;
|
||||
flowEnvironmentEvent.NodeCreated += FlowEnvironment_NodeCreateEvent;
|
||||
flowEnvironmentEvent.NodeRemoved += FlowEnvironment_NodeRemoveEvent;
|
||||
flowEnvironmentEvent.NodePlace += FlowEnvironment_OnNodePlaceEvent;
|
||||
flowEnvironmentEvent.NodeTakeOut += FlowEnvironment_OnNodeTakeOutEvent;
|
||||
flowEnvironmentEvent.FlowRunComplete += FlowEnvironment_OnFlowRunCompleteEvent;
|
||||
|
||||
flowEnvironmentEvent.OnMonitorObjectChange += FlowEnvironment_OnMonitorObjectChangeEvent;
|
||||
flowEnvironmentEvent.OnNodeInterruptStateChange += FlowEnvironment_OnNodeInterruptStateChangeEvent;
|
||||
flowEnvironmentEvent.OnInterruptTrigger += FlowEnvironment_OnInterruptTriggerEvent;
|
||||
flowEnvironmentEvent.MonitorObjectChanged += FlowEnvironment_OnMonitorObjectChangeEvent;
|
||||
flowEnvironmentEvent.NodeInterruptStateChanged += FlowEnvironment_OnNodeInterruptStateChangeEvent;
|
||||
flowEnvironmentEvent.InterruptTriggered += FlowEnvironment_OnInterruptTriggerEvent;
|
||||
|
||||
flowEnvironmentEvent.OnIOCMembersChanged += FlowEnvironment_OnIOCMembersChangedEvent;
|
||||
flowEnvironmentEvent.IOCMembersChanged += FlowEnvironment_OnIOCMembersChangedEvent;
|
||||
|
||||
flowEnvironmentEvent.OnNodeLocated += FlowEnvironment_OnNodeLocateEvent;
|
||||
flowEnvironmentEvent.OnNodeMoved += FlowEnvironment_OnNodeMovedEvent;
|
||||
flowEnvironmentEvent.NodeLocated += FlowEnvironment_OnNodeLocateEvent;;
|
||||
|
||||
flowEnvironmentEvent.OnEnvOut += FlowEnvironment_OnEnvOutEvent;
|
||||
flowEnvironmentEvent.EnvOutput += FlowEnvironment_OnEnvOutEvent;
|
||||
}
|
||||
|
||||
|
||||
private void ResetFlowEnvironmentEvent()
|
||||
{
|
||||
flowEnvironmentEvent.OnDllLoad -= FlowEnvironment_DllLoadEvent;
|
||||
flowEnvironmentEvent.OnProjectSaving -= FlowEnvironment_OnProjectSaving;
|
||||
flowEnvironmentEvent.OnProjectLoaded -= FlowEnvironment_OnProjectLoaded;
|
||||
flowEnvironmentEvent.OnStartNodeChange -= FlowEnvironment_StartNodeChangeEvent;
|
||||
flowEnvironmentEvent.OnNodeConnectChange -= FlowEnvironment_NodeConnectChangeEvemt;
|
||||
flowEnvironmentEvent.OnNodeCreate -= FlowEnvironment_NodeCreateEvent;
|
||||
flowEnvironmentEvent.OnNodeRemove -= FlowEnvironment_NodeRemoveEvent;
|
||||
flowEnvironmentEvent.OnNodePlace -= FlowEnvironment_OnNodePlaceEvent;
|
||||
flowEnvironmentEvent.OnNodeTakeOut -= FlowEnvironment_OnNodeTakeOutEvent;
|
||||
flowEnvironmentEvent.OnFlowRunComplete -= FlowEnvironment_OnFlowRunCompleteEvent;
|
||||
flowEnvironmentEvent.DllLoad -= FlowEnvironment_DllLoadEvent;
|
||||
flowEnvironmentEvent.ProjectSaving -= FlowEnvironment_OnProjectSaving;
|
||||
flowEnvironmentEvent.ProjectLoaded -= FlowEnvironment_OnProjectLoaded;
|
||||
flowEnvironmentEvent.StartNodeChanged -= FlowEnvironment_StartNodeChangeEvent;
|
||||
flowEnvironmentEvent.NodeConnectChanged -= FlowEnvironment_NodeConnectChangeEvemt;
|
||||
flowEnvironmentEvent.NodeCreated -= FlowEnvironment_NodeCreateEvent;
|
||||
flowEnvironmentEvent.NodeRemoved -= FlowEnvironment_NodeRemoveEvent;
|
||||
flowEnvironmentEvent.NodePlace -= FlowEnvironment_OnNodePlaceEvent;
|
||||
flowEnvironmentEvent.NodeTakeOut -= FlowEnvironment_OnNodeTakeOutEvent;
|
||||
flowEnvironmentEvent.FlowRunComplete -= FlowEnvironment_OnFlowRunCompleteEvent;
|
||||
|
||||
|
||||
flowEnvironmentEvent.OnMonitorObjectChange -= FlowEnvironment_OnMonitorObjectChangeEvent;
|
||||
flowEnvironmentEvent.OnNodeInterruptStateChange -= FlowEnvironment_OnNodeInterruptStateChangeEvent;
|
||||
flowEnvironmentEvent.OnInterruptTrigger -= FlowEnvironment_OnInterruptTriggerEvent;
|
||||
flowEnvironmentEvent.MonitorObjectChanged -= FlowEnvironment_OnMonitorObjectChangeEvent;
|
||||
flowEnvironmentEvent.NodeInterruptStateChanged -= FlowEnvironment_OnNodeInterruptStateChangeEvent;
|
||||
flowEnvironmentEvent.InterruptTriggered -= FlowEnvironment_OnInterruptTriggerEvent;
|
||||
|
||||
flowEnvironmentEvent.OnIOCMembersChanged -= FlowEnvironment_OnIOCMembersChangedEvent;
|
||||
flowEnvironmentEvent.OnNodeLocated -= FlowEnvironment_OnNodeLocateEvent;
|
||||
flowEnvironmentEvent.OnNodeMoved -= FlowEnvironment_OnNodeMovedEvent;
|
||||
flowEnvironmentEvent.IOCMembersChanged -= FlowEnvironment_OnIOCMembersChangedEvent;
|
||||
flowEnvironmentEvent.NodeLocated -= FlowEnvironment_OnNodeLocateEvent;
|
||||
|
||||
flowEnvironmentEvent.OnEnvOut -= FlowEnvironment_OnEnvOutEvent;
|
||||
flowEnvironmentEvent.EnvOutput -= FlowEnvironment_OnEnvOutEvent;
|
||||
|
||||
}
|
||||
|
||||
@@ -192,7 +186,7 @@ namespace Serein.Workbench.Services
|
||||
{
|
||||
uIContextOperation.Invoke(() =>
|
||||
{
|
||||
OnEnvOut?.Invoke(type, value);
|
||||
EnvOutput?.Invoke(type, value);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -203,7 +197,7 @@ namespace Serein.Workbench.Services
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void FlowEnvironment_OnProjectSaving(ProjectSavingEventArgs eventArgs)
|
||||
{
|
||||
OnProjectSaving?.Invoke(eventArgs);
|
||||
ProjectSaving?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -212,7 +206,7 @@ namespace Serein.Workbench.Services
|
||||
/// <param name="eventArgs"></param>
|
||||
private void FlowEnvironment_OnProjectLoaded(ProjectLoadedEventArgs eventArgs)
|
||||
{
|
||||
OnProjectLoaded?.Invoke(eventArgs);
|
||||
ProjectLoaded?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -223,7 +217,7 @@ namespace Serein.Workbench.Services
|
||||
private void FlowEnvironment_OnFlowRunCompleteEvent(FlowEventArgs eventArgs)
|
||||
{
|
||||
SereinEnv.WriteLine(InfoType.INFO, "-------运行完成---------\r\n");
|
||||
OnFlowRunComplete?.Invoke(eventArgs);
|
||||
FlowRunComplete?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -231,7 +225,7 @@ namespace Serein.Workbench.Services
|
||||
/// </summary>
|
||||
private void FlowEnvironment_DllLoadEvent(LoadDllEventArgs eventArgs)
|
||||
{
|
||||
OnDllLoad?.Invoke(eventArgs);
|
||||
DllLoad?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -240,7 +234,7 @@ namespace Serein.Workbench.Services
|
||||
/// <param name="eventArgs"></param>
|
||||
private void FlowEnvironment_NodeConnectChangeEvemt(NodeConnectChangeEventArgs eventArgs)
|
||||
{
|
||||
OnNodeConnectChange?.Invoke(eventArgs);
|
||||
NodeConnectChanged?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
|
||||
@@ -251,7 +245,7 @@ namespace Serein.Workbench.Services
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void FlowEnvironmentEvent_OnCanvasCreate(CanvasCreateEventArgs eventArgs)
|
||||
{
|
||||
OnCanvasCreate?.Invoke(eventArgs);
|
||||
CanvasCreated?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -261,7 +255,7 @@ namespace Serein.Workbench.Services
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void FlowEnvironmentEvent_OnCanvasRemove(CanvasRemoveEventArgs eventArgs)
|
||||
{
|
||||
OnCanvasRemove?.Invoke(eventArgs);
|
||||
CanvasRemoved?.Invoke(eventArgs);
|
||||
|
||||
}
|
||||
|
||||
@@ -271,7 +265,7 @@ namespace Serein.Workbench.Services
|
||||
/// <param name="eventArgs"></param>
|
||||
private void FlowEnvironment_NodeRemoveEvent(NodeRemoveEventArgs eventArgs)
|
||||
{
|
||||
OnNodeRemove?.Invoke(eventArgs);
|
||||
NodeRemoved?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -281,7 +275,7 @@ namespace Serein.Workbench.Services
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void FlowEnvironment_NodeCreateEvent(NodeCreateEventArgs eventArgs)
|
||||
{
|
||||
OnNodeCreate?.Invoke(eventArgs);
|
||||
NodeCreated?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -291,7 +285,7 @@ namespace Serein.Workbench.Services
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void FlowEnvironment_OnNodePlaceEvent(NodePlaceEventArgs eventArgs)
|
||||
{
|
||||
OnNodePlace?.Invoke(eventArgs);
|
||||
NodePlace?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -300,7 +294,7 @@ namespace Serein.Workbench.Services
|
||||
/// <param name="eventArgs"></param>
|
||||
private void FlowEnvironment_OnNodeTakeOutEvent(NodeTakeOutEventArgs eventArgs)
|
||||
{
|
||||
OnNodeTakeOut?.Invoke(eventArgs);
|
||||
NodeTakeOut?.Invoke(eventArgs);
|
||||
|
||||
}
|
||||
|
||||
@@ -312,7 +306,7 @@ namespace Serein.Workbench.Services
|
||||
private void FlowEnvironment_StartNodeChangeEvent(StartNodeChangeEventArgs eventArgs)
|
||||
{
|
||||
|
||||
OnStartNodeChange?.Invoke(eventArgs);
|
||||
StartNodeChanged?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -321,7 +315,7 @@ namespace Serein.Workbench.Services
|
||||
/// <param name="eventArgs"></param>
|
||||
private void FlowEnvironment_OnMonitorObjectChangeEvent(MonitorObjectEventArgs eventArgs)
|
||||
{
|
||||
OnMonitorObjectChange?.Invoke(eventArgs);
|
||||
MonitorObjectChanged?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -330,7 +324,7 @@ namespace Serein.Workbench.Services
|
||||
/// <param name="eventArgs"></param>
|
||||
private void FlowEnvironment_OnNodeInterruptStateChangeEvent(NodeInterruptStateChangeEventArgs eventArgs)
|
||||
{
|
||||
OnNodeInterruptStateChange?.Invoke(eventArgs);
|
||||
NodeInterruptStateChanged?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -340,7 +334,7 @@ namespace Serein.Workbench.Services
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void FlowEnvironment_OnInterruptTriggerEvent(InterruptTriggerEventArgs eventArgs)
|
||||
{
|
||||
OnInterruptTrigger?.Invoke(eventArgs);
|
||||
InterruptTriggered?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -350,7 +344,7 @@ namespace Serein.Workbench.Services
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void FlowEnvironment_OnIOCMembersChangedEvent(IOCMembersChangedEventArgs eventArgs)
|
||||
{
|
||||
OnIOCMembersChanged?.Invoke(eventArgs);
|
||||
IOCMembersChanged?.Invoke(eventArgs);
|
||||
|
||||
}
|
||||
|
||||
@@ -361,25 +355,110 @@ namespace Serein.Workbench.Services
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void FlowEnvironment_OnNodeLocateEvent(NodeLocatedEventArgs eventArgs)
|
||||
{
|
||||
OnNodeLocated?.Invoke(eventArgs);
|
||||
NodeLocated?.Invoke(eventArgs);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 节点移动
|
||||
/// </summary>
|
||||
/// <param name="eventArgs"></param>
|
||||
private void FlowEnvironment_OnNodeMovedEvent(NodeMovedEventArgs eventArgs)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 主动触发运行环境事件
|
||||
public void OnDllLoad(LoadDllEventArgs eventArgs)
|
||||
{
|
||||
OnNodeMoved?.Invoke(eventArgs);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnProjectLoaded(ProjectLoadedEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnProjectSaving(ProjectSavingEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnNodeConnectChanged(NodeConnectChangeEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnCanvasCreated(CanvasCreateEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnCanvasRemoved(CanvasRemoveEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnNodeCreated(NodeCreateEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnNodeRemoved(NodeRemoveEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnNodePlace(NodePlaceEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnNodeTakeOut(NodeTakeOutEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnStartNodeChanged(StartNodeChangeEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnFlowRunComplete(FlowEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnMonitorObjectChanged(MonitorObjectEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnNodeInterruptStateChanged(NodeInterruptStateChangeEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnInterruptTriggered(InterruptTriggerEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnIOCMembersChanged(IOCMembersChangedEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnNodeLocated(NodeLocatedEventArgs eventArgs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnEnvOutput(InfoType type, string value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,17 +190,17 @@ namespace Serein.Workbench.Services
|
||||
/// </summary>
|
||||
private void InitFlowEvent()
|
||||
{
|
||||
flowEEForwardingService.OnCanvasCreate += FlowEEForwardingService_OnCanvasCreate; // 创建了画布
|
||||
flowEEForwardingService.OnCanvasRemove += FlowEEForwardingService_OnCanvasRemove; // 移除了画布
|
||||
flowEEForwardingService.OnNodeCreate += FlowEEForwardingService_OnNodeCreate; // 创建了节点
|
||||
flowEEForwardingService.OnNodeRemove += FlowEEForwardingService_OnNodeRemove; // 移除了节点
|
||||
flowEEForwardingService.CanvasCreated += FlowEEForwardingService_OnCanvasCreate; // 创建了画布
|
||||
flowEEForwardingService.CanvasRemoved += FlowEEForwardingService_OnCanvasRemove; // 移除了画布
|
||||
flowEEForwardingService.NodeCreated += FlowEEForwardingService_OnNodeCreate; // 创建了节点
|
||||
flowEEForwardingService.NodeRemoved += FlowEEForwardingService_OnNodeRemove; // 移除了节点
|
||||
|
||||
flowEEForwardingService.OnNodePlace += FlowEEForwardingService_OnNodePlace; // 节点放置在容器中
|
||||
flowEEForwardingService.OnNodeTakeOut += FlowEEForwardingService_OnNodeTakeOut; ; // 节点从容器中取出
|
||||
flowEEForwardingService.NodePlace += FlowEEForwardingService_OnNodePlace; // 节点放置在容器中
|
||||
flowEEForwardingService.NodeTakeOut += FlowEEForwardingService_OnNodeTakeOut; ; // 节点从容器中取出
|
||||
|
||||
flowEEForwardingService.OnNodeConnectChange += FlowEEForwardingService_OnNodeConnectChange; // 节点连接状态改变事件
|
||||
flowEEForwardingService.NodeConnectChanged += FlowEEForwardingService_OnNodeConnectChange; // 节点连接状态改变事件
|
||||
|
||||
flowEEForwardingService.OnStartNodeChange += FlowEEForwardingService_OnStartNodeChange; // 画布起始节点改变
|
||||
flowEEForwardingService.StartNodeChanged += FlowEEForwardingService_OnStartNodeChange; // 画布起始节点改变
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ namespace Serein.Workbench.Services
|
||||
|
||||
private void InitEvents()
|
||||
{
|
||||
flowEEForwardingService.OnProjectLoaded += FlowEEForwardingService_OnProjectLoaded;
|
||||
flowEEForwardingService.OnProjectSaving += SaveProjectToLocalFile;
|
||||
flowEEForwardingService.OnEnvOut += FlowEEForwardingService_OnEnvOut;
|
||||
flowEEForwardingService.ProjectLoaded += FlowEEForwardingService_OnProjectLoaded;
|
||||
flowEEForwardingService.ProjectSaving += SaveProjectToLocalFile;
|
||||
flowEEForwardingService.EnvOutput += FlowEEForwardingService_OnEnvOut;
|
||||
keyEventService.OnKeyDown += KeyEventService_OnKeyDown; ;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Serein.Workbench.Themes
|
||||
return;
|
||||
}
|
||||
}));
|
||||
contextMenu.Items.Add(WpfFuncTool.CreateMenuItem("定位", (s, e) => flowEnvironment.NodeLocated(tmpNodeTreeModel.RootNode.Guid)));
|
||||
contextMenu.Items.Add(WpfFuncTool.CreateMenuItem("定位", (s, e) => flowEnvironment.NodeLocate(tmpNodeTreeModel.RootNode.Guid)));
|
||||
|
||||
treeViewItem.ContextMenu = contextMenu;
|
||||
treeViewItem.Margin = new Thickness(-20, 0, 0, 0);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Serein.Workbench.ViewModels
|
||||
this.flowEEForwardingService = flowEEForwardingService;
|
||||
this.flowEnvironment = flowEnvironment;
|
||||
FlowLibraryInfos = new ObservableCollection<FlowLibraryInfo>();
|
||||
flowEEForwardingService.OnDllLoad += FlowEEForwardingService_OnDllLoad;
|
||||
flowEEForwardingService.DllLoad += FlowEEForwardingService_OnDllLoad;
|
||||
}
|
||||
/// <summary>
|
||||
/// 加载文件依赖
|
||||
|
||||
@@ -41,6 +41,7 @@ using UserControl = System.Windows.Controls.UserControl;
|
||||
using Clipboard = System.Windows.Clipboard;
|
||||
using TextDataFormat = System.Windows.TextDataFormat;
|
||||
using System.Windows.Media.Animation;
|
||||
using Serein.NodeFlow.Model;
|
||||
|
||||
namespace Serein.Workbench.Views
|
||||
{
|
||||
@@ -174,7 +175,7 @@ namespace Serein.Workbench.Views
|
||||
private void InitEvent()
|
||||
{
|
||||
keyEventService.OnKeyDown += KeyEventService_OnKeyDown;
|
||||
flowEEForwardingService.OnNodeLocated += FlowEEForwardingService_OnNodeLocated;
|
||||
flowEEForwardingService.NodeLocated += FlowEEForwardingService_OnNodeLocated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1348,9 +1349,9 @@ namespace Serein.Workbench.Views
|
||||
var actualDeltaX = newLeft - oldLeft;
|
||||
var actualDeltaY = newTop - oldTop;
|
||||
|
||||
List<(string Guid, double NewLeft, double NewTop, double MaxWidth, double MaxHeight)> moveSizes =
|
||||
List<(IFlowNode Node, double NewLeft, double NewTop, double MaxWidth, double MaxHeight)> moveSizes =
|
||||
selectNodeControls.Select(control =>
|
||||
(control.ViewModel.NodeModel.Guid,
|
||||
(control.ViewModel.NodeModel,
|
||||
Canvas.GetLeft(control) + actualDeltaX,
|
||||
Canvas.GetTop(control) + actualDeltaY,
|
||||
control.FlowCanvas.Model.Width - control.ActualWidth - 10,
|
||||
@@ -1363,7 +1364,10 @@ namespace Serein.Workbench.Views
|
||||
}
|
||||
foreach (var item in moveSizes)
|
||||
{
|
||||
this.flowEnvironment.MoveNode(this.Guid, item.Guid, item.NewLeft, item.NewTop); // 移动节点
|
||||
item.Node.Position.X = item.NewLeft;
|
||||
item.Node.Position.Y = item.NewTop;
|
||||
|
||||
//this.flowEnvironment.MoveNode(this.Guid, item.Guid, item.NewLeft, item.NewTop); // 移动节点
|
||||
}
|
||||
|
||||
// 更新节点之间线的连接位置
|
||||
@@ -1390,7 +1394,11 @@ namespace Serein.Workbench.Views
|
||||
newLeft = newLeft < 5 ? 5 : newLeft > canvasWidth ? canvasWidth : newLeft;
|
||||
newTop = newTop < 5 ? 5 : newTop > canvasHeight ? canvasHeight : newTop;
|
||||
|
||||
this.flowEnvironment.MoveNode(Guid, nodeControl.ViewModel.NodeModel.Guid, newLeft, newTop); // 移动节点
|
||||
var node = nodeControl.ViewModel.NodeModel;
|
||||
node.Position.X = newLeft;
|
||||
node.Position.Y = newTop;
|
||||
|
||||
//this.flowEnvironment.MoveNode(Guid, nodeControl.ViewModel.NodeModel.Guid, newLeft, newTop); // 移动节点
|
||||
nodeControl.UpdateLocationConnections();
|
||||
}
|
||||
startControlDragPoint = currentPosition; // 更新起始点位置
|
||||
|
||||
@@ -109,6 +109,14 @@
|
||||
<TextBlock Text="预览位置Y" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.ViewY, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="缩放比例X" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.ScaleX, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="缩放比例Y" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding Model.ScaleY, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Serein.Workbench.Views
|
||||
if (sender is Grid grid && grid.DataContext is IFlowNode nodeModel)
|
||||
{
|
||||
NodeInfoViewModel.ViewNodeModel = nodeModel;
|
||||
App.GetService<IFlowEnvironment>().NodeLocated(nodeModel.Guid);
|
||||
App.GetService<IFlowEnvironment>().NodeLocate(nodeModel.Guid);
|
||||
}
|
||||
|
||||
// 定位节点
|
||||
|
||||
@@ -41,6 +41,14 @@
|
||||
<TextBlock Text="节点名称" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding ViewNodeModel.DisplayName, Mode=TwoWay}" Style="{StaticResource InfoValueTextBox}" IsReadOnly="True"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="X轴位置" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding ViewNodeModel.Position.X, Mode=TwoWay}" Style="{StaticResource InfoValueTextBox}" IsReadOnly="True"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="1" Orientation="Horizontal">
|
||||
<TextBlock Text="Y轴位置" Style="{StaticResource InfoTipsTextBlock}" />
|
||||
<TextBox Text="{Binding ViewNodeModel.Position.Y, Mode=TwoWay}" Style="{StaticResource InfoValueTextBox}" IsReadOnly="True"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</UserControl>
|
||||
|
||||
Reference in New Issue
Block a user