完成mvvm模式下,画布、节点编辑的基本重构

This commit is contained in:
fengjiayi
2025-05-26 23:55:23 +08:00
parent ba74facf7d
commit 7ad6041be6
38 changed files with 2056 additions and 436 deletions

View File

@@ -146,11 +146,11 @@ namespace Serein.Library.Api
/// <summary>
/// 是否完成
/// </summary>
public bool IsSucceed { get; protected set; } = true;
public bool IsSucceed { get;} = true;
/// <summary>
/// 错误提示
/// </summary>
public string ErrorTips { get; protected set; } = string.Empty;
public string ErrorTips { get;} = string.Empty;
}
/// <summary>
@@ -168,9 +168,15 @@ namespace Serein.Library.Api
/// </summary>
public class ProjectSavingEventArgs : FlowEventArgs
{
public ProjectSavingEventArgs()
public ProjectSavingEventArgs(SereinProjectData projectData)
{
ProjectData = projectData;
}
/// <summary>
/// 项目数据
/// </summary>
public SereinProjectData ProjectData { get; }
}
/// <summary>
@@ -186,11 +192,11 @@ namespace Serein.Library.Api
/// <summary>
/// 已加载了的程序集
/// </summary>
public NodeLibraryInfo NodeLibraryInfo { get; protected set; }
public NodeLibraryInfo NodeLibraryInfo { get;}
/// <summary>
/// dll文件中有效的流程方法描述
/// </summary>
public List<MethodDetailsInfo> MethodDetailss { get; protected set; }
public List<MethodDetailsInfo> MethodDetailss { get;}
}
/// <summary>
@@ -279,31 +285,31 @@ namespace Serein.Library.Api
/// <summary>
/// 连接关系中始节点的Guid
/// </summary>
public string FromNodeGuid { get; protected set; }
public string FromNodeGuid { get;}
/// <summary>
/// 连接关系中目标节点的Guid
/// </summary>
public string ToNodeGuid { get; protected set; }
public string ToNodeGuid { get;}
/// <summary>
/// 连接类型
/// </summary>
public ConnectionInvokeType ConnectionInvokeType { get; protected set; }
public ConnectionInvokeType ConnectionInvokeType { get;}
/// <summary>
/// 表示此次需要在两个节点之间创建连接关系,或是移除连接关系
/// </summary>
public ConnectChangeType ChangeType { get; protected set; }
public ConnectChangeType ChangeType { get;}
/// <summary>
/// 指示需要创建什么类型的连接线
/// </summary>
public JunctionOfConnectionType JunctionOfConnectionType { get; protected set; }
public JunctionOfConnectionType JunctionOfConnectionType { get;}
/// <summary>
/// 节点对应的方法入参所需参数来源
/// </summary>
public ConnectionArgSourceType ConnectionArgSourceType { get; protected set; }
public ConnectionArgSourceType ConnectionArgSourceType { get;}
/// <summary>
/// 第几个参数
/// </summary>
public int ArgIndex { get; protected set; }
public int ArgIndex { get;}
}
@@ -313,12 +319,12 @@ namespace Serein.Library.Api
/// </summary>
public class CanvasCreateEventArgs : FlowEventArgs
{
public CanvasCreateEventArgs(FlowCanvasModel model)
public CanvasCreateEventArgs(FlowCanvasDetails model)
{
Model = model;
}
public FlowCanvasModel Model { get; }
public FlowCanvasDetails Model { get; }
}
/// <summary>
@@ -342,6 +348,7 @@ namespace Serein.Library.Api
/// <summary>
/// 节点添加事件参数
/// </summary>
/// <param name="canvasGuid">画布</param>
/// <param name="nodeModel">节点对象</param>
/// <param name="position">位置</param>
public NodeCreateEventArgs(string canvasGuid, NodeModelBase nodeModel, PositionOfUI position)
@@ -350,15 +357,23 @@ namespace Serein.Library.Api
this.NodeModel = nodeModel;
this.Position = position;
}
/// <summary>
/// 所处画布Guid
/// </summary>
public string CanvasGuid { get; }
/// <summary>
/// 节点Model对象
/// </summary>
public NodeModelBase NodeModel { get; private set; }
/// <summary>
/// 在UI上的位置
/// </summary>
public PositionOfUI Position { get; private set; }
public string RegeionGuid { get; private set; }
/// <summary>
/// 容器
/// </summary>
//public string RegeionGuid { get; private set; }
}
/// <summary>
@@ -487,16 +502,16 @@ namespace Serein.Library.Api
/// <summary>
/// 中断的节点Guid
/// </summary>
public string NodeGuid { get; protected set; }
public string NodeGuid { get;}
/// <summary>
/// 监听对象类别
/// </summary>
public ObjSourceType ObjSource { get; protected set; }
public ObjSourceType ObjSource { get;}
/// <summary>
/// 新的数据
/// </summary>
public object NewData { get; protected set; }
public object NewData { get;}
}
/// <summary>
@@ -514,9 +529,9 @@ namespace Serein.Library.Api
/// <summary>
/// 中断的节点Guid
/// </summary>
public string NodeGuid { get; protected set; }
public bool IsInterrupt { get; protected set; }
// public InterruptClass Class { get; protected set; }
public string NodeGuid { get;}
public bool IsInterrupt { get;}
// public InterruptClass Class { get;}
}
/// <summary>
/// 节点触发了中断事件参数
@@ -549,9 +564,9 @@ namespace Serein.Library.Api
/// <summary>
/// 中断的节点Guid
/// </summary>
public string NodeGuid { get; protected set; }
public string Expression { get; protected set; }
public InterruptTriggerType Type { get; protected set; }
public string NodeGuid { get;}
public string Expression { get;}
public InterruptTriggerType Type { get;}
}
@@ -880,7 +895,7 @@ namespace Serein.Library.Api
/// <param name="width">宽度</param>
/// <param name="height">高度</param>
/// <returns></returns>
Task<FlowCanvasInfo> CreateCanvasAsync(string canvasName, int width , int height);
Task<FlowCanvasDetailsInfo> CreateCanvasAsync(string canvasName, int width , int height);
/// <summary>
/// 删除画布

View File

@@ -21,9 +21,9 @@ namespace Serein.Library
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public static FlowCanvasInfo ToInfo(this FlowCanvasModel model)
public static FlowCanvasDetailsInfo ToInfo(this FlowCanvasDetails model)
{
return new FlowCanvasInfo
return new FlowCanvasDetailsInfo
{
Guid = model.Guid,
Height = model.Height,
@@ -33,6 +33,7 @@ namespace Serein.Library
ScaleY = model.ScaleY,
ViewX = model.ViewX,
ViewY = model.ViewY,
StartNode = model.StartNode,
};
}
@@ -41,7 +42,7 @@ namespace Serein.Library
/// </summary>
/// <param name="model"></param>
/// <param name="info"></param>
public static void LoadInfo(this FlowCanvasModel model, FlowCanvasInfo info)
public static void LoadInfo(this FlowCanvasDetails model, FlowCanvasDetailsInfo info)
{
model.Guid = info.Guid;
model.Height = info.Height;
@@ -51,6 +52,7 @@ namespace Serein.Library
model.ScaleY = info.ScaleY;
model.ViewX = info.ViewX;
model.ViewY = info.ViewY;
model.StartNode = info.StartNode;
}
/// <summary>
@@ -102,6 +104,7 @@ namespace Serein.Library
NodeInfo nodeInfo = new NodeInfo
{
Guid = nodeModel.Guid,
CanvasGuid = nodeModel.CanvasGuid,
AssemblyName = nodeModel.MethodDetails.AssemblyName,
MethodName = nodeModel.MethodDetails?.MethodName,
Label = nodeModel.MethodDetails?.MethodAnotherName,

View File

@@ -1,4 +1,5 @@
using Serein.Library.Api;
using Serein.Library.FlowNode;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -8,50 +9,86 @@ using System.Threading.Tasks;
namespace Serein.Library
{
/// <summary>
/// 流程画布
/// </summary>
[NodeProperty(ValuePath = NodeValuePath.Node)]
public partial class FlowCanvasModel
public partial class FlowCanvasDetails
{
public FlowCanvasModel(IFlowEnvironment env)
public FlowCanvasDetails(IFlowEnvironment env)
{
Env = env;
}
public IFlowEnvironment Env { get; }
/// <summary>
/// 标识画布ID
/// </summary>
[PropertyInfo(IsProtection = true)]
private string _guid;
/// <summary>
/// 画布名称
/// </summary>
[PropertyInfo(IsNotification = true)]
private string _name;
/// <summary>
/// 画布宽度
/// </summary>
[PropertyInfo(IsNotification = true)]
private double _width;
/// <summary>
/// 画布高度
/// </summary>
[PropertyInfo(IsNotification = true)]
private double _height;
/// <summary>
/// 预览位置X
/// </summary>
[PropertyInfo]
[PropertyInfo(IsNotification = true)]
private double _viewX ;
/// <summary>
/// 预览位置Y
/// </summary>
[PropertyInfo]
[PropertyInfo(IsNotification = true)]
private double _viewY ;
/// <summary>
/// 缩放比例X
/// </summary>
[PropertyInfo]
private double _scaleX ;
[PropertyInfo(IsNotification = true)]
private double _scaleX = 1;
/// <summary>
/// 缩放比例Y
/// </summary>
[PropertyInfo]
private double _scaleY ;
[PropertyInfo(IsNotification = true)]
private double _scaleY = 1;
/// <summary>
/// 起始节点私有属性
/// </summary>
private string _startNode;
}
public partial class FlowCanvasDetails
{
}
}

View File

@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Serein.Library
{
/// <summary>
/// 画布信息
/// </summary>
public class FlowCanvasDetailsInfo
{
/// <summary>
/// 起始节点Guid
/// </summary>
public string StartNode;
/// <summary>
/// 标识画布ID
/// </summary>
public string Guid;
/// <summary>
/// 画布名称
/// </summary>
public string Name;
/// <summary>
/// 画布宽度
/// </summary>
public double Width;
/// <summary>
/// 画布高度
/// </summary>
public double Height;
/// <summary>
/// 预览位置X
/// </summary>
public double ViewX;
/// <summary>
/// 预览位置Y
/// </summary>
public double ViewY;
/// <summary>
/// 缩放比例X
/// </summary>
public double ScaleX;
/// <summary>
/// 缩放比例Y
/// </summary>
public double ScaleY;
}
}

View File

@@ -48,7 +48,7 @@ namespace Serein.Library
/// <summary>
/// 项目保存文件
/// 项目数据
/// </summary>
public class SereinProjectData
{
@@ -64,16 +64,20 @@ namespace Serein.Library
public NodeLibraryInfo[] Librarys { get; set; }
/// <summary>
/// 起始节点GUID
/// </summary>
///// <summary>
///// 起始节点GUID
///// </summary>
public string StartNode { get; set; }
//public string StartNode { get; set; }
/// <summary>
/// 画布集合
/// </summary>
public FlowCanvasDetailsInfo[] Canvass { get; set; }
/// <summary>
/// 节点集合
/// </summary>
public NodeInfo[] Nodes { get; set; }
}
@@ -83,11 +87,10 @@ namespace Serein.Library
/// </summary>
public class Basic
{
/// <summary>
/// 画布
/// </summary>
public FlowCanvasInfo Canvas { get; set; }
///// <summary>
///// 画布
///// </summary>
//public FlowCanvasInfo Canvas { get; set; }
/// <summary>
/// 版本
@@ -95,7 +98,9 @@ namespace Serein.Library
public string Versions { get; set; }
}
/// <summary>
/* /// <summary>
/// 画布信息,项目文件相关
/// </summary>
public class FlowCanvasInfo
@@ -132,7 +137,7 @@ namespace Serein.Library
/// 缩放比例Y
/// </summary>
public double ScaleY { get; set; }
}
}*/
/// <summary>
/// 项目依赖的程序集,项目文件相关
@@ -187,7 +192,6 @@ namespace Serein.Library
/// </summary>
public string CanvasGuid { get; set; }
/// <summary>
/// 节点的GUID
/// </summary>

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
@@ -91,6 +92,7 @@ namespace Serein.Library.Utils
catch (Exception ex)
{
tcs.SetException(ex);
Debug.WriteLine(ex);
}
}, null);