2022-12-12 22:33:17 +08:00
|
|
|
|
using System;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel;
|
2022-10-28 22:45:39 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner;
|
2023-01-25 11:11:27 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Models;
|
2022-12-12 22:33:17 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Services;
|
2023-02-28 23:04:16 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramModels;
|
|
|
|
|
|
using AIStudio.Wpf.DiagramModels.ViewModels;
|
2022-12-12 22:33:17 +08:00
|
|
|
|
using AIStudio.Wpf.Flowchart.Models;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2021-07-29 13:55:18 +08:00
|
|
|
|
namespace AIStudio.Wpf.Flowchart.ViewModels
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-02-28 23:04:16 +08:00
|
|
|
|
public class FlowNode : DiagramItemViewModel
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2021-07-27 16:15:30 +08:00
|
|
|
|
protected IUIVisualizerService visualiserService;
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public FlowNode(NodeKinds kind) : this(null, kind)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FlowNode(IDiagramViewModel root, NodeKinds kind) : base(root)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
Kind = kind;
|
2021-07-27 16:15:30 +08:00
|
|
|
|
Text = Kind.GetDescription();
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public FlowNode(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public FlowNode(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 23:10:57 +08:00
|
|
|
|
public override SelectableItemBase GetSerializableObject()
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
return new FlowNodeDesignerItem(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-25 11:59:31 +08:00
|
|
|
|
protected override void Init(IDiagramViewModel root, bool initNew)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-03-25 11:59:31 +08:00
|
|
|
|
base.Init(root, initNew);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
ShowRotate = false;
|
2021-07-27 16:15:30 +08:00
|
|
|
|
ShowText = true;
|
|
|
|
|
|
IsReadOnlyText = true;
|
|
|
|
|
|
|
|
|
|
|
|
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-25 11:59:31 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
base.LoadDesignerItemViewModel(designerbase);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
if (designerbase is FlowNodeDesignerItem designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-03-10 12:09:13 +08:00
|
|
|
|
this.StatusColor = designer.Color;
|
2023-01-24 17:53:04 +08:00
|
|
|
|
this.Kind = designer.Kind;
|
|
|
|
|
|
this.StateImage = designer.StateImage;
|
2023-04-16 12:21:51 +08:00
|
|
|
|
this.Status = designer.Status;
|
|
|
|
|
|
this.Remark = designer.Remark;
|
2023-01-24 17:53:04 +08:00
|
|
|
|
|
|
|
|
|
|
if (this is MiddleFlowNode middle)
|
|
|
|
|
|
{
|
|
|
|
|
|
middle.UserIds = designer.UserIds;
|
|
|
|
|
|
middle.RoleIds = designer.RoleIds;
|
|
|
|
|
|
middle.ActType = designer.ActType;
|
2023-04-16 12:21:51 +08:00
|
|
|
|
middle.SimulateApprove = designer.SimulateApprove;
|
2023-01-24 17:53:04 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-28 23:04:16 +08:00
|
|
|
|
public override DiagramNode ToDiagram()
|
|
|
|
|
|
{
|
|
|
|
|
|
var flowchartNode = new FlowchartNode();
|
|
|
|
|
|
|
2023-03-10 12:09:13 +08:00
|
|
|
|
flowchartNode.StatusColor = StatusColor;
|
2023-02-28 23:04:16 +08:00
|
|
|
|
flowchartNode.Kind = Kind;
|
|
|
|
|
|
if (this is MiddleFlowNode middleflowNode)
|
|
|
|
|
|
{
|
|
|
|
|
|
flowchartNode.UserIds = middleflowNode.UserIds;
|
|
|
|
|
|
flowchartNode.RoleIds = middleflowNode.RoleIds;
|
|
|
|
|
|
flowchartNode.ActType = middleflowNode.ActType;
|
|
|
|
|
|
}
|
|
|
|
|
|
return flowchartNode;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-07 11:32:01 +08:00
|
|
|
|
private string _color = "#1890ff";
|
2021-07-30 18:26:35 +08:00
|
|
|
|
[Browsable(false)]
|
2023-03-10 12:09:13 +08:00
|
|
|
|
public string StatusColor
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
get { return _color; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _color, value);
|
|
|
|
|
|
}
|
2021-07-26 22:37:54 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
|
public NodeKinds Kind { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Browsable(false)]
|
|
|
|
|
|
public string StateImage { get; set; }
|
2021-07-26 22:37:54 +08:00
|
|
|
|
|
2023-04-16 12:21:51 +08:00
|
|
|
|
#region 模拟使用
|
2021-07-26 22:37:54 +08:00
|
|
|
|
private int _status;
|
2023-04-16 12:21:51 +08:00
|
|
|
|
|
2021-07-26 22:37:54 +08:00
|
|
|
|
public int Status
|
|
|
|
|
|
{
|
2023-04-16 12:21:51 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _status;
|
|
|
|
|
|
}
|
2021-07-26 22:37:54 +08:00
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _status, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string _remark;
|
|
|
|
|
|
public string Remark
|
|
|
|
|
|
{
|
2023-04-16 12:21:51 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _remark;
|
|
|
|
|
|
}
|
2021-07-26 22:37:54 +08:00
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _remark, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-04-16 12:21:51 +08:00
|
|
|
|
#endregion
|
2021-07-27 16:15:30 +08:00
|
|
|
|
|
2023-04-16 12:21:51 +08:00
|
|
|
|
#region 没有存起来,仅仅测试使用,实际这些代码应该都在服务端
|
2021-07-27 16:15:30 +08:00
|
|
|
|
public List<string> PreStepId { get; set; }
|
|
|
|
|
|
public string NextStepId { get; set; }
|
|
|
|
|
|
public Dictionary<string, string> SelectNextStep { get; set; } = new Dictionary<string, string>();
|
2021-07-26 22:37:54 +08:00
|
|
|
|
#endregion
|
2022-12-01 23:12:13 +08:00
|
|
|
|
|
|
|
|
|
|
public virtual Dictionary<string, string> PropertiesSetting
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Dictionary<string, string>()
|
2022-12-04 23:07:20 +08:00
|
|
|
|
{
|
|
|
|
|
|
{ "Name","名称" },
|
2022-12-01 23:12:13 +08:00
|
|
|
|
{ "Text","文本" },
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class StartFlowNode : FlowNode
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public StartFlowNode() : this(null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public StartFlowNode(IDiagramViewModel root) : base(root, NodeKinds.Start)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public StartFlowNode(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public StartFlowNode(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class EndFlowNode : FlowNode
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public EndFlowNode() : this(null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public EndFlowNode(IDiagramViewModel root) : base(root, NodeKinds.End)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public EndFlowNode(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public EndFlowNode(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class DecideFlowNode : FlowNode
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public DecideFlowNode() : this(null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DecideFlowNode(IDiagramViewModel root) : base(root, NodeKinds.Decide)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public DecideFlowNode(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public DecideFlowNode(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class COBeginFlowNode : FlowNode
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public COBeginFlowNode() : this(null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public COBeginFlowNode(IDiagramViewModel root) : base(root, NodeKinds.COBegin)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public COBeginFlowNode(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public COBeginFlowNode(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class COEndFlowNode : FlowNode
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public COEndFlowNode() : this(null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public COEndFlowNode(IDiagramViewModel root) : base(root, NodeKinds.COEnd)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public COEndFlowNode(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public COEndFlowNode(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|