Files
aistudio-wpf-diagram/Extensions/AIStudio.Wpf.Flowchart/Models/FlowchartNode.cs

130 lines
3.5 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2023-03-05 23:22:34 +08:00
using AIStudio.Wpf.DiagramDesigner;
2023-04-16 20:11:40 +08:00
using AIStudio.Wpf.DiagramDesigner.Serializable;
using AIStudio.Wpf.DiagramDesigner.Serializable.ViewModels;
using AIStudio.Wpf.Flowchart.ViewModels;
namespace AIStudio.Wpf.Flowchart.Models
{
/// <summary>
///
/// </summary>
/// <seealso cref="AIStudio.Util.DiagramEntity.DiagramNode" />
public class FlowchartNode : DiagramNode
{
/// <summary>
/// Gets or sets the kind.
/// </summary>
/// <value>
/// The kind.
/// </value>
public NodeKinds Kind
{
get; set;
}
/// <summary>
/// Gets or sets the user ids.
/// </summary>
/// <value>
/// The user ids.
/// </value>
public IEnumerable<string> UserIds
{
get; set;
}
/// <summary>
/// Gets or sets the role ids.
/// </summary>
/// <value>
/// The role ids.
/// </value>
public IEnumerable<string> RoleIds
{
get; set;
}
/// <summary>
/// Gets or sets the type of the act.
/// </summary>
/// <value>
/// The type of the act.
/// </value>
public string ActType
{
get; set;
}
2023-03-10 12:09:13 +08:00
/// <summary>
/// Gets or sets the color.
/// </summary>
/// <value>
/// The color.
/// </value>
public string StatusColor
{
get; set;
}
2023-03-05 23:22:34 +08:00
public override DiagramItemViewModel ToNodel(IDiagramViewModel diagramViewModel)
{
FlowNode flowNode = null;
switch (Kind)
{
case NodeKinds.Start:
{
2023-03-05 23:22:34 +08:00
flowNode = new StartFlowNode(diagramViewModel);
break;
}
case NodeKinds.End:
{
2023-03-05 23:22:34 +08:00
flowNode = new EndFlowNode(diagramViewModel);
break;
}
case NodeKinds.Decide:
{
2023-03-05 23:22:34 +08:00
flowNode = new DecideFlowNode(diagramViewModel);
break;
}
case NodeKinds.COBegin:
{
2023-03-05 23:22:34 +08:00
flowNode = new COBeginFlowNode(diagramViewModel);
break;
}
case NodeKinds.COEnd:
{
2023-03-05 23:22:34 +08:00
flowNode = new COEndFlowNode(diagramViewModel);
break;
}
case NodeKinds.Middle:
{
2023-03-05 23:22:34 +08:00
var flowchartNodelModel = new MiddleFlowNode(diagramViewModel);
flowNode = flowchartNodelModel;
flowchartNodelModel.UserIds = UserIds?.ToList();
flowchartNodelModel.RoleIds = RoleIds?.ToList();
flowchartNodelModel.ActType = ActType;
break;
}
default:
{
2023-03-05 23:22:34 +08:00
var flowNodelModel = new FlowNode(diagramViewModel, NodeKinds.Normal);
flowNode = flowNodelModel;
break;
}
}
2023-03-10 12:09:13 +08:00
flowNode.StatusColor = StatusColor;
flowNode.Kind = Kind;
return flowNode;
}
}
}