|
@@ -1,6 +1,7 @@
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
+using System.Drawing;
|
|
using System.Dynamic;
|
|
using System.Dynamic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
@@ -13,23 +14,28 @@ namespace wispro.sp.web.Components
|
|
[Parameter]
|
|
[Parameter]
|
|
public double TitleHeight { get; set; } = 100;
|
|
public double TitleHeight { get; set; } = 100;
|
|
|
|
|
|
-
|
|
|
|
[Parameter]
|
|
[Parameter]
|
|
public double ChartWidth { get; set; } = 1200;
|
|
public double ChartWidth { get; set; } = 1200;
|
|
[Parameter]
|
|
[Parameter]
|
|
public double ChartHeight { get; set; } = 900;
|
|
public double ChartHeight { get; set; } = 900;
|
|
[Parameter]
|
|
[Parameter]
|
|
public double rectWidth { get; set; } = 150;
|
|
public double rectWidth { get; set; } = 150;
|
|
-
|
|
|
|
|
|
+
|
|
[Parameter]
|
|
[Parameter]
|
|
public double rectHeight { get; set; } = 60;
|
|
public double rectHeight { get; set; } = 60;
|
|
[Parameter]
|
|
[Parameter]
|
|
- public double initRadius { get; set; } = 25;
|
|
|
|
|
|
+ public double initRadius { get; set; } = 20;
|
|
[Parameter]
|
|
[Parameter]
|
|
- public double EndRadius { get; set; } = 25;
|
|
|
|
|
|
+ public double EndRadius { get; set; } = 20;
|
|
[Parameter]
|
|
[Parameter]
|
|
public double hSeparation { get; set; } = 40;
|
|
public double hSeparation { get; set; } = 40;
|
|
|
|
|
|
|
|
+ [Parameter]
|
|
|
|
+ public string StepShapeColor { get; set; } = "green";
|
|
|
|
+
|
|
|
|
+ [Parameter]
|
|
|
|
+ public string EndShapColor { get; set; } = "gray";
|
|
|
|
+
|
|
int rectFontSize { get; set; } = 18;
|
|
int rectFontSize { get; set; } = 18;
|
|
|
|
|
|
[Parameter]
|
|
[Parameter]
|
|
@@ -73,13 +79,15 @@ namespace wispro.sp.web.Components
|
|
|
|
|
|
public List<shapeNode> Parents { get; set; }
|
|
public List<shapeNode> Parents { get; set; }
|
|
|
|
|
|
|
|
+ public string FillColor { get; set; } = "white";
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
private List<shapeNode> shapeTrees = null;
|
|
private List<shapeNode> shapeTrees = null;
|
|
|
|
|
|
private shapeNode FindNode(int stepId, out int Level, List<shapeNode> lstNodes)
|
|
private shapeNode FindNode(int stepId, out int Level, List<shapeNode> lstNodes)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+
|
|
Level = 1;
|
|
Level = 1;
|
|
foreach (var sNode in lstNodes)
|
|
foreach (var sNode in lstNodes)
|
|
{
|
|
{
|
|
@@ -149,13 +157,16 @@ namespace wispro.sp.web.Components
|
|
height = 2 * initRadius,
|
|
height = 2 * initRadius,
|
|
Level = 0
|
|
Level = 0
|
|
};
|
|
};
|
|
|
|
+
|
|
|
|
+
|
|
InitShape = new shapeNode()
|
|
InitShape = new shapeNode()
|
|
{
|
|
{
|
|
NodeObject = workflow.InitAction,
|
|
NodeObject = workflow.InitAction,
|
|
InCount = 0,
|
|
InCount = 0,
|
|
OutCount = 0,
|
|
OutCount = 0,
|
|
Type = 1,
|
|
Type = 1,
|
|
- Level = 1
|
|
|
|
|
|
+ Level = 1,
|
|
|
|
+ FillColor = StepShapeColor
|
|
};
|
|
};
|
|
|
|
|
|
startNode.Childrens = new List<shapeNode>();
|
|
startNode.Childrens = new List<shapeNode>();
|
|
@@ -169,7 +180,8 @@ namespace wispro.sp.web.Components
|
|
InCount = 0,
|
|
InCount = 0,
|
|
OutCount = 0,
|
|
OutCount = 0,
|
|
height = 2 * EndRadius,
|
|
height = 2 * EndRadius,
|
|
- width = 2 * EndRadius
|
|
|
|
|
|
+ width = 2 * EndRadius,
|
|
|
|
+ FillColor = EndShapColor
|
|
};
|
|
};
|
|
|
|
|
|
shapeTrees.Add(startNode);
|
|
shapeTrees.Add(startNode);
|
|
@@ -177,7 +189,7 @@ namespace wispro.sp.web.Components
|
|
//shapeTrees.Add(endNode);
|
|
//shapeTrees.Add(endNode);
|
|
|
|
|
|
#region 将步骤对象生成形状Node并添加到列表中
|
|
#region 将步骤对象生成形状Node并添加到列表中
|
|
- if (Steps == null || Steps.Count == 0 || Steps.FirstOrDefault(s=>s.Id == workflow.EndStepId) == null)
|
|
|
|
|
|
+ if (Steps == null || Steps.Count == 0 || Steps.FirstOrDefault(s => s.Id == workflow.EndStepId) == null)
|
|
{
|
|
{
|
|
InitShape.Childrens = new List<shapeNode>();
|
|
InitShape.Childrens = new List<shapeNode>();
|
|
InitShape.Childrens.Add(endNode);
|
|
InitShape.Childrens.Add(endNode);
|
|
@@ -192,7 +204,7 @@ namespace wispro.sp.web.Components
|
|
{
|
|
{
|
|
foreach (var step in Steps)
|
|
foreach (var step in Steps)
|
|
{
|
|
{
|
|
- var temNode = new shapeNode() { NodeObject = step, InCount = 0, OutCount = 0, Type = 1 };
|
|
|
|
|
|
+ var temNode = new shapeNode() { NodeObject = step, InCount = 0, OutCount = 0, Type = 1,FillColor = StepShapeColor };
|
|
|
|
|
|
if (workflow.EndStepId == step.Id)
|
|
if (workflow.EndStepId == step.Id)
|
|
{
|
|
{
|
|
@@ -205,7 +217,7 @@ namespace wispro.sp.web.Components
|
|
shapeTrees.Add(temNode);
|
|
shapeTrees.Add(temNode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
#region 遍历转移条件,生成流程树
|
|
#region 遍历转移条件,生成流程树
|
|
@@ -255,7 +267,7 @@ namespace wispro.sp.web.Components
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
GetShapeLevelNodes(LevelNodes, shapeTrees);
|
|
GetShapeLevelNodes(LevelNodes, shapeTrees);
|
|
|
|
|
|
@@ -333,7 +345,7 @@ namespace wispro.sp.web.Components
|
|
LevelNodes[i] = LevelNodes[i].OrderBy(node =>
|
|
LevelNodes[i] = LevelNodes[i].OrderBy(node =>
|
|
{
|
|
{
|
|
// calculate average position based on connected nodes in top layer
|
|
// calculate average position based on connected nodes in top layer
|
|
- if(node.Parents == null)
|
|
|
|
|
|
+ if (node.Parents == null)
|
|
{
|
|
{
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -435,7 +447,7 @@ namespace wispro.sp.web.Components
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public dynamic GetLineParater(entity.workflowDefine.TrasferCondition trasferCondition)
|
|
public dynamic GetLineParater(entity.workflowDefine.TrasferCondition trasferCondition)
|
|
{
|
|
{
|
|
int level = 0;
|
|
int level = 0;
|
|
@@ -453,12 +465,77 @@ namespace wispro.sp.web.Components
|
|
ret.x2 = endNode.x;
|
|
ret.x2 = endNode.x;
|
|
ret.y2 = endNode.y - endNode.height / 2;
|
|
ret.y2 = endNode.y - endNode.height / 2;
|
|
|
|
|
|
|
|
+ double x3 = 0.0;
|
|
|
|
+ double y3 = 0.0;
|
|
|
|
+ GetArrorEndPoint(ret, out x3, out y3);
|
|
|
|
+
|
|
|
|
+ Console.WriteLine($"x1:{ret.x1};y1:{ret.y1}\r\nx2:{ret.x2};y2:{ret.y2}\r\nx3:{x3};y3:{y3}\r\n");
|
|
|
|
+ ret.x2 = x3;
|
|
|
|
+ ret.y2 = y3;
|
|
|
|
+
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void GetArrorEndPoint(dynamic ret, out double x3, out double y3)
|
|
|
|
+ {
|
|
|
|
+ if (ret.x1 == ret.x2)
|
|
|
|
+ {
|
|
|
|
+ x3 = ret.x1;
|
|
|
|
+ if (ret.y2 > ret.y1)
|
|
|
|
+ {
|
|
|
|
+ y3 = ret.y2 - 8;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ y3 = ret.y2 + 8;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (ret.y1 == ret.y2)
|
|
|
|
+ {
|
|
|
|
+ y3 = ret.y1;
|
|
|
|
+
|
|
|
|
+ if (ret.x1 < ret.x2)
|
|
|
|
+ {
|
|
|
|
+ x3 = ret.x2 - 8;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ x3 = ret.x2 + 8;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ double k = (ret.y1 - ret.y2) / (ret.x1 - ret.x2);
|
|
|
|
+ double b = ret.y2 - k * ret.x2;
|
|
|
|
+ Console.WriteLine($"k={k};b={b}");
|
|
|
|
+
|
|
|
|
+ double a = k * k + 1;
|
|
|
|
+ double B = 2 * k * (b - ret.y2) - 2 * ret.x2;
|
|
|
|
+ double c = (b - ret.y2) * (b - ret.y2) + ret.x2 * ret.x2 - 100;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ double x3_1 = (Math.Sqrt(B * B - 4 * a * c) - B) / (2 * a);
|
|
|
|
+ double x3_2 = ((Math.Sqrt(B * B - 4 * a * c) + B) / (2 * a)) * -1;
|
|
|
|
+
|
|
|
|
+ if (ret.x1 < ret.x2)
|
|
|
|
+ {
|
|
|
|
+ x3 = (x3_1 < x3_2) ? x3_1 : x3_2;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ x3 = (x3_1 < x3_2) ? x3_2 : x3_1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ y3 = k * x3 + b;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public dynamic GetEndStepLine()
|
|
public dynamic GetEndStepLine()
|
|
{
|
|
{
|
|
- var startNode =endNode.Parents[0];
|
|
|
|
|
|
+ var startNode = endNode.Parents[0];
|
|
dynamic ret = new ExpandoObject();
|
|
dynamic ret = new ExpandoObject();
|
|
ret.x1 = startNode.x;
|
|
ret.x1 = startNode.x;
|
|
ret.y1 = startNode.y + startNode.height / 2;
|
|
ret.y1 = startNode.y + startNode.height / 2;
|
|
@@ -466,7 +543,34 @@ namespace wispro.sp.web.Components
|
|
ret.x2 = endNode.x;
|
|
ret.x2 = endNode.x;
|
|
ret.y2 = endNode.y - endNode.height / 2;
|
|
ret.y2 = endNode.y - endNode.height / 2;
|
|
|
|
|
|
|
|
+ double x3 = 0.0;
|
|
|
|
+ double y3 = 0.0;
|
|
|
|
+ GetArrorEndPoint(ret, out x3, out y3);
|
|
|
|
+
|
|
|
|
+ ret.x2 = x3;
|
|
|
|
+ ret.y2 = y3;
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public dynamic GetStartInitLine()
|
|
|
|
+ {
|
|
|
|
+ dynamic ret = new ExpandoObject();
|
|
|
|
+ ret.x1 = this.startNode.x;
|
|
|
|
+ ret.y1 = this.startNode.y + startNode.height / 2;
|
|
|
|
+
|
|
|
|
+ ret.x2 = InitShape.x;
|
|
|
|
+ ret.y2 = InitShape.y - InitShape.height / 2;
|
|
|
|
+
|
|
|
|
+ double x3 = 0.0;
|
|
|
|
+ double y3 = 0.0;
|
|
|
|
+ GetArrorEndPoint(ret, out x3, out y3);
|
|
|
|
+
|
|
|
|
+ ret.x2 = x3;
|
|
|
|
+ ret.y2 = y3;
|
|
|
|
+
|
|
return ret;
|
|
return ret;
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
protected override void OnInitialized()
|
|
protected override void OnInitialized()
|