FlowChartUtility.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. using Microsoft.AspNetCore.Components;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Dynamic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace wispro.sp.share.Utility
  9. {
  10. public class shapeNode
  11. {
  12. public int InCount { get; set; }
  13. public int OutCount { get; set; }
  14. public double x { get; set; }
  15. public double y { get; set; }
  16. public double width { get; set; }
  17. public double height { get; set; }
  18. /// <summary>
  19. /// 形状类型
  20. /// 0:圆
  21. /// 1:矩形
  22. /// 3: 虚拟
  23. /// </summary>
  24. public int Type { get; set; }
  25. public int Level { get; set; } = 1;
  26. public dynamic NodeObject { get; set; }
  27. public List<shapeNode> Childrens { get; set; }
  28. public List<shapeNode> Parents { get; set; }
  29. public string FillColor { get; set; } = "white";
  30. }
  31. public class FlowChartUtility
  32. {
  33. public double TitleHeight { get; set; } = 100;
  34. public double ChartWidth { get; set; } = 1200;
  35. public double ChartHeight { get; set; } = 900;
  36. public double rectWidth { get; set; } = 150;
  37. public double rectHeight { get; set; } = 60;
  38. public double initRadius { get; set; } = 20;
  39. public double EndRadius { get; set; } = 20;
  40. public double hSeparation { get; set; } = 40;
  41. public string StepShapeColor { get; set; } = "green";
  42. public string EndShapColor { get; set; } = "gray";
  43. int rectFontSize { get; set; } = 18;
  44. public List<entity.workflowDefine.Step> Steps { get; set; }
  45. public List<entity.workflowDefine.TrasferCondition> Transfers { get; set; }
  46. public List<entity.workflowDefine.Action> Actions { get; set; }
  47. public entity.workflowDefine.Workflow workflow { get; set; }
  48. private List<shapeNode> shapeTrees = null;
  49. private shapeNode FindNode(int stepId, out int Level, List<shapeNode> lstNodes)
  50. {
  51. Level = 1;
  52. foreach (var sNode in lstNodes)
  53. {
  54. if (sNode.NodeObject is entity.workflowDefine.Step && sNode.NodeObject.Id == stepId)
  55. {
  56. return sNode;
  57. }
  58. else
  59. {
  60. if (sNode.Childrens != null)
  61. {
  62. Level += 1;
  63. var retObj = FindNode(stepId, out Level, sNode.Childrens);
  64. if (retObj != null)
  65. {
  66. return retObj;
  67. }
  68. }
  69. }
  70. }
  71. return null;
  72. }
  73. private void GetShapeLevelNodes(Dictionary<int, List<shapeNode>> levelNodes, List<shapeNode> TreeNodes)
  74. {
  75. if (TreeNodes != null)
  76. {
  77. foreach (var sNode in TreeNodes)
  78. {
  79. List<shapeNode> nodes = new List<shapeNode>();
  80. if (levelNodes.ContainsKey(sNode.Level))
  81. {
  82. nodes = levelNodes[sNode.Level];
  83. nodes.Add(sNode);
  84. }
  85. else
  86. {
  87. nodes.Add(sNode);
  88. levelNodes.Add(sNode.Level, nodes);
  89. }
  90. GetShapeLevelNodes(levelNodes, sNode.Childrens);
  91. }
  92. }
  93. }
  94. public shapeNode startNode;
  95. public shapeNode InitShape;
  96. public shapeNode endNode;
  97. public Dictionary<int, List<shapeNode>> LevelNodes = new Dictionary<int, List<shapeNode>>();
  98. private void initShapeTree()
  99. {
  100. shapeTrees = new List<shapeNode>();
  101. LevelNodes = new Dictionary<int, List<shapeNode>>();
  102. #region 添加开始节点
  103. startNode = new shapeNode()
  104. {
  105. //NodeObject = workflow.InitAction,
  106. InCount = 0,
  107. OutCount = 0,
  108. width = 2 * initRadius,
  109. height = 2 * initRadius,
  110. Level = 0
  111. };
  112. #endregion
  113. #region 添加初始化Action节点
  114. InitShape = new shapeNode()
  115. {
  116. NodeObject = workflow.InitAction,
  117. InCount = 0,
  118. OutCount = 0,
  119. Type = 1,
  120. Level = 1,
  121. FillColor = StepShapeColor
  122. };
  123. startNode.Childrens = new List<shapeNode>();
  124. startNode.Childrens.Add(InitShape);
  125. InitShape.Parents = new List<shapeNode>();
  126. InitShape.Parents.Add(startNode);
  127. shapeTrees.Add(startNode);
  128. #endregion
  129. #region 将步骤对象生成形状Node并添加到列表中
  130. if (Steps != null)
  131. {
  132. foreach (var step in Steps)
  133. {
  134. var temNode = new shapeNode() { NodeObject = step, InCount = 0, OutCount = 0, Type = 1, FillColor = StepShapeColor };
  135. if (workflow.EndStepId == step.Id)
  136. {
  137. endNode = new shapeNode()
  138. {
  139. NodeObject = step,
  140. InCount = 0,
  141. OutCount = 0,
  142. height = 2 * EndRadius,
  143. width = 2 * EndRadius,
  144. FillColor = EndShapColor
  145. };
  146. temNode = endNode;
  147. }
  148. shapeTrees.Add(temNode);
  149. }
  150. }
  151. #endregion
  152. #region 遍历转移条件,生成流程树
  153. if (Transfers != null && Transfers.Count > 0)
  154. {
  155. foreach (var transfer in Transfers)
  156. {
  157. var FromNode = InitShape;
  158. int FromLevel = 0;
  159. if (transfer.StepId != null)
  160. {
  161. FromNode = FindNode(transfer.StepId.Value, out FromLevel, shapeTrees);
  162. }
  163. int ToLevel = 0;
  164. var ToNode = FindNode(transfer.nextStepId, out ToLevel, shapeTrees);
  165. if (FromNode.Childrens == null)
  166. {
  167. FromNode.Childrens = new List<shapeNode>();
  168. }
  169. FromNode.Childrens.Add(ToNode);
  170. if (ToNode.Parents == null)
  171. {
  172. ToNode.Parents = new List<shapeNode>();
  173. }
  174. ToNode.Parents.Add(FromNode);
  175. FromNode.OutCount += 1;
  176. ToNode.InCount += 1;
  177. if (FromNode.Level >= ToLevel)
  178. {
  179. ToNode.Level = FromNode.Level + 1;
  180. }
  181. if (shapeTrees.Contains(ToNode))
  182. {
  183. shapeTrees.Remove(ToNode);
  184. }
  185. }
  186. if (endNode.Parents != null && endNode.Parents[0].NodeObject is entity.workflowDefine.Step)
  187. {
  188. endNode.Level = endNode.Parents[0].Level + 1;
  189. }
  190. }
  191. else
  192. {
  193. InitShape.Childrens = new List<shapeNode>();
  194. InitShape.Childrens.Add(endNode);
  195. InitShape.OutCount += 1;
  196. endNode.Parents = new List<shapeNode>();
  197. endNode.Parents.Add(InitShape);
  198. endNode.InCount += 1;
  199. endNode.Level = InitShape.Level + 1;
  200. //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(endNode));
  201. }
  202. #endregion
  203. GetShapeLevelNodes(LevelNodes, shapeTrees);
  204. #region 添加跨层连接的中间层的虚拟节点
  205. List<dynamic> AddNodes = new List<dynamic>();
  206. foreach (int level in LevelNodes.Keys)
  207. {
  208. foreach (var temNode in LevelNodes[level])
  209. {
  210. if (temNode.Childrens != null)
  211. {
  212. foreach (var temChildrenNode in temNode.Childrens)
  213. {
  214. if ((temChildrenNode.Level - temNode.Level) > 1)
  215. {
  216. dynamic temAddInfo = new ExpandoObject();
  217. temAddInfo.Parent = temNode;
  218. temAddInfo.Children = temChildrenNode;
  219. temAddInfo.Start = temNode.Level;
  220. temAddInfo.End = temChildrenNode.Level;
  221. AddNodes.Add(temAddInfo);
  222. }
  223. }
  224. }
  225. }
  226. }
  227. foreach (dynamic dynObj in AddNodes)
  228. {
  229. shapeNode parentNode = dynObj.Parent;
  230. shapeNode endNode = dynObj.Children;
  231. for (int i = dynObj.Start + 1; i < dynObj.End; i++)
  232. {
  233. var xnNode = new shapeNode() { Type = 3, Parents = new List<shapeNode>(), Childrens = new List<shapeNode>(), Level = i };
  234. parentNode.Childrens.Add(xnNode);
  235. xnNode.Parents.Add(parentNode);
  236. parentNode.Childrens.Remove(endNode);
  237. parentNode.Childrens.Add(xnNode);
  238. endNode.Parents.Remove(parentNode);
  239. endNode.Parents.Add(xnNode);
  240. parentNode = xnNode;
  241. LevelNodes[xnNode.Level].Add(xnNode);
  242. }
  243. }
  244. #endregion
  245. int MaxNodeLevel = 0;
  246. int NodeCount = 0;
  247. foreach (int level in LevelNodes.Keys)
  248. {
  249. if (level > 1)
  250. {
  251. int temLevelCount = 0;
  252. foreach (var temNode in LevelNodes[level])
  253. {
  254. int graterInOrOut = (temNode.OutCount > temNode.InCount) ? temNode.OutCount : temNode.InCount;
  255. if (graterInOrOut <= 1)
  256. {
  257. temLevelCount += 1;
  258. }
  259. else
  260. {
  261. temLevelCount += graterInOrOut;
  262. }
  263. }
  264. if (temLevelCount > MaxNodeLevel)
  265. {
  266. MaxNodeLevel = level;
  267. NodeCount = temLevelCount;
  268. }
  269. }
  270. }
  271. #region 每层节点排序
  272. for (var i = 1; i < LevelNodes.Count; ++i)
  273. {
  274. var top_layer = LevelNodes[i - 1];
  275. LevelNodes[i] = LevelNodes[i].OrderBy(node =>
  276. {
  277. if (node.Parents == null)
  278. {
  279. return 0;
  280. }
  281. var connected_nodes = node.Parents
  282. .Where(l => l.Level == (i - 1)).ToList();
  283. if (!connected_nodes.Any())
  284. {
  285. return 0;
  286. }
  287. var average_index = connected_nodes.Select(cn => { var i = top_layer.IndexOf(cn); return i; }).Average();
  288. return average_index;
  289. }).ToList();
  290. }
  291. if (LevelNodes.Count > 1)
  292. {
  293. LevelNodes[0] = LevelNodes[0].OrderBy(node =>
  294. {
  295. var connected_nodes = node.Childrens
  296. .Where(l => l.Level == 1)
  297. .ToList();
  298. if (!connected_nodes.Any())
  299. {
  300. return 0;
  301. }
  302. var average_index = connected_nodes.Select(cn => { var i = LevelNodes[1].IndexOf(cn); return i; }).Average();
  303. return average_index;
  304. }).ToList();
  305. }
  306. #endregion
  307. ArrangeNodesInRows(LevelNodes);
  308. }
  309. private void ArrangeNodesInRows(Dictionary<int, List<shapeNode>> LevelNodes)
  310. {
  311. double preBotton = TitleHeight;
  312. for (int iLevel = 0; iLevel < LevelNodes.Count; iLevel++)
  313. {
  314. int iCount = 0;
  315. foreach (var node in LevelNodes[iLevel])
  316. {
  317. int max = (node.InCount > node.OutCount) ? node.InCount : node.OutCount;
  318. if (max == 0)
  319. {
  320. max = 1;
  321. }
  322. iCount += max;
  323. }
  324. double onNodeWidth = ChartWidth / (iCount + 1);
  325. iCount = 0;
  326. double maxHeight = 0;
  327. foreach (var node in LevelNodes[iLevel])
  328. {
  329. int max = (node.InCount > node.OutCount) ? node.InCount : node.OutCount;
  330. if (max == 0)
  331. {
  332. max = 1;
  333. }
  334. node.x = onNodeWidth * (iCount + 1) + (max - 1) * onNodeWidth / 2;
  335. if (node.Type == 0)
  336. {
  337. node.width = 2 * initRadius;
  338. node.height = 2 * initRadius;
  339. }
  340. else
  341. {
  342. node.width = rectWidth;
  343. node.height = rectHeight;
  344. }
  345. iCount += max;
  346. if (node.height > maxHeight)
  347. {
  348. maxHeight = node.height;
  349. }
  350. }
  351. foreach (var node in LevelNodes[iLevel])
  352. {
  353. node.y = preBotton + hSeparation + maxHeight / 2;
  354. }
  355. preBotton = preBotton + hSeparation + maxHeight;
  356. }
  357. }
  358. public dynamic GetLineParater(entity.workflowDefine.TrasferCondition trasferCondition)
  359. {
  360. int level = 0;
  361. var startNode = InitShape;
  362. if (trasferCondition.StepId != null)
  363. {
  364. startNode = FindNode(trasferCondition.StepId.Value, out level, shapeTrees);
  365. }
  366. var endNode = FindNode(trasferCondition.nextStepId, out level, shapeTrees);
  367. dynamic ret = new ExpandoObject();
  368. ret.x1 = startNode.x;
  369. ret.y1 = startNode.y + startNode.height / 2;
  370. ret.x2 = endNode.x;
  371. ret.y2 = endNode.y - endNode.height / 2;
  372. double x3 = 0.0;
  373. double y3 = 0.0;
  374. GetArrorEndPoint(ret, out x3, out y3);
  375. ret.x2 = x3;
  376. ret.y2 = y3;
  377. return ret;
  378. }
  379. public void GetArrorEndPoint(dynamic ret, out double x3, out double y3)
  380. {
  381. if (ret.x1 == ret.x2)
  382. {
  383. x3 = ret.x1;
  384. if (ret.y2 > ret.y1)
  385. {
  386. y3 = ret.y2 - 8;
  387. }
  388. else
  389. {
  390. y3 = ret.y2 + 8;
  391. }
  392. }
  393. else
  394. {
  395. if (ret.y1 == ret.y2)
  396. {
  397. y3 = ret.y1;
  398. if (ret.x1 < ret.x2)
  399. {
  400. x3 = ret.x2 - 8;
  401. }
  402. else
  403. {
  404. x3 = ret.x2 + 8;
  405. }
  406. }
  407. else
  408. {
  409. double k = (ret.y1 - ret.y2) / (ret.x1 - ret.x2);
  410. double b = ret.y2 - k * ret.x2;
  411. double a = k * k + 1;
  412. double B = 2 * k * (b - ret.y2) - 2 * ret.x2;
  413. double c = (b - ret.y2) * (b - ret.y2) + ret.x2 * ret.x2 - 100;
  414. double x3_1 = (Math.Sqrt(B * B - 4 * a * c) - B) / (2 * a);
  415. double x3_2 = ((Math.Sqrt(B * B - 4 * a * c) + B) / (2 * a)) * -1;
  416. if (ret.x1 < ret.x2)
  417. {
  418. x3 = (x3_1 < x3_2) ? x3_1 : x3_2;
  419. }
  420. else
  421. {
  422. x3 = (x3_1 < x3_2) ? x3_2 : x3_1;
  423. }
  424. y3 = k * x3 + b;
  425. }
  426. }
  427. }
  428. public dynamic GetEndStepLine()
  429. {
  430. var startNode = InitShape;
  431. if (endNode.Parents != null)
  432. {
  433. startNode = endNode.Parents[0];
  434. }
  435. dynamic ret = new ExpandoObject();
  436. ret.x1 = startNode.x;
  437. ret.y1 = startNode.y + startNode.height / 2;
  438. ret.x2 = endNode.x;
  439. ret.y2 = endNode.y - endNode.height / 2;
  440. double x3 = 0.0;
  441. double y3 = 0.0;
  442. GetArrorEndPoint(ret, out x3, out y3);
  443. ret.x2 = x3;
  444. ret.y2 = y3;
  445. return ret;
  446. }
  447. public dynamic GetStartInitLine()
  448. {
  449. dynamic ret = new ExpandoObject();
  450. ret.x1 = this.startNode.x;
  451. ret.y1 = this.startNode.y + startNode.height / 2;
  452. ret.x2 = InitShape.x;
  453. ret.y2 = InitShape.y - InitShape.height / 2;
  454. double x3 = 0.0;
  455. double y3 = 0.0;
  456. GetArrorEndPoint(ret, out x3, out y3);
  457. ret.x2 = x3;
  458. ret.y2 = y3;
  459. return ret;
  460. }
  461. public void Refresh()
  462. {
  463. //System.Text.Json.JsonSerializer.Serialize(Actions);
  464. initShapeTree();
  465. }
  466. void InitAction()
  467. {
  468. }
  469. #region 单击/双击事件
  470. public EventCallback<entity.workflowDefine.Step> OnClickStep { get; set; }
  471. public EventCallback<entity.workflowDefine.Action> OnClickAction { get; set; }
  472. public EventCallback<entity.workflowDefine.TrasferCondition> OnClickTransfer { get; set; }
  473. public EventCallback<entity.workflowDefine.Step> OnDoubleClickStep { get; set; }
  474. [Parameter]
  475. public EventCallback<entity.workflowDefine.Action> OnDoubleClickAction { get; set; }
  476. [Parameter]
  477. public EventCallback<entity.workflowDefine.TrasferCondition> OnDoubleClickTransfer { get; set; }
  478. public shapeNode SelectedShape { get; set; }
  479. void ClickNode(shapeNode node)
  480. {
  481. SelectedShape = node;
  482. if (node.NodeObject is entity.workflowDefine.Step)
  483. {
  484. if (OnClickStep.HasDelegate)
  485. {
  486. OnClickStep.InvokeAsync((entity.workflowDefine.Step)node.NodeObject);
  487. }
  488. }
  489. if (node.NodeObject is entity.workflowDefine.Action)
  490. {
  491. if (OnClickAction.HasDelegate)
  492. {
  493. OnClickAction.InvokeAsync((entity.workflowDefine.Action)node.NodeObject);
  494. }
  495. }
  496. }
  497. void DoubleClickNode(shapeNode node)
  498. {
  499. SelectedShape = node;
  500. if (node.NodeObject is entity.workflowDefine.Step)
  501. {
  502. if (OnDoubleClickStep.HasDelegate)
  503. {
  504. OnDoubleClickStep.InvokeAsync((entity.workflowDefine.Step)node.NodeObject);
  505. }
  506. }
  507. if (node.NodeObject is entity.workflowDefine.Action)
  508. {
  509. if (OnDoubleClickAction.HasDelegate)
  510. {
  511. OnDoubleClickAction.InvokeAsync((entity.workflowDefine.Action)node.NodeObject);
  512. }
  513. }
  514. }
  515. void ClickTrasfer(entity.workflowDefine.TrasferCondition trasferCondition)
  516. {
  517. SelectedShape = null;
  518. if (OnClickTransfer.HasDelegate)
  519. {
  520. OnClickTransfer.InvokeAsync(trasferCondition);
  521. }
  522. }
  523. void DoubleClickTrasfer(entity.workflowDefine.TrasferCondition trasferCondition)
  524. {
  525. SelectedShape = null;
  526. if (OnDoubleClickTransfer.HasDelegate)
  527. {
  528. OnDoubleClickTransfer.InvokeAsync(trasferCondition);
  529. }
  530. }
  531. #endregion
  532. public string GetSvgString()
  533. {
  534. initShapeTree();
  535. string strReturn = $"<svg width =\"{ChartWidth}\" height = \"{ChartHeight}\" id = \"FlowChartContainer\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">";
  536. strReturn = strReturn +
  537. "<defs>\r\n" +
  538. "\t<marker id =\"idArrow\" viewBox=\"0 0 20 20\" refX = \"0\" refY = \"10\" markerUnits = \"strokeWidth\" markerWidth = \"5\" markerHeight = \"10\" orient=\"auto\">\r\n" +
  539. "\t\t<path d =\"M 0 0 L 20 10 L 0 20 z\" fill=\"black\" stroke = \"black\" />\r\n" +
  540. "</marker>" +
  541. "</defs>";
  542. if (shapeTrees != null)
  543. {
  544. strReturn += $"<text x=\"{ChartWidth / 2}\" y=\"{TitleHeight / 2}\" fill=\"black\" alignment-baseline=\"middle\" text-anchor=\"middle\" font-size=\"{30}\" font-weight=\"800\">{workflow.Name}</text>\r\n";
  545. dynamic startLine = GetStartInitLine();
  546. strReturn += $"<line x1=\"{startLine.x1}\" y1=\"{startLine.y1}\" x2 =\"{startLine.x2}\" y2=\"{startLine.y2}\" stroke=\"black\" stroke-width=\"2\" marker-end=\"url(#idArrow)\"/>\r\n";
  547. for (int iLevel = 0; iLevel < LevelNodes.Count; iLevel++)
  548. {
  549. foreach (var node in LevelNodes[iLevel])
  550. {
  551. if (node.Type == 0)
  552. {
  553. strReturn += $"<circle cx =\"{node.x}\" cy=\"{node.y}\" r=\"{node.width / 2}\" stroke=\"black\" stroke-width=\"2\" fill=\"{node.FillColor}\"/>\r\n";
  554. strReturn += "<a>" +
  555. $"<text x =\"{node.x}\" y=\"{node.y}\" fill=\"black\" alignment-baseline=\"middle\" text-anchor=\"middle\" font-size=\"14\">\r\n";
  556. if (node == startNode)
  557. {
  558. strReturn += "开始";
  559. }
  560. else
  561. {
  562. if (node == endNode)
  563. {
  564. strReturn += "结束";
  565. }
  566. else
  567. {
  568. if (node.NodeObject is entity.workflowDefine.Step)
  569. {
  570. strReturn += ((entity.workflowDefine.Step)node.NodeObject).Name;
  571. }
  572. }
  573. }
  574. strReturn += "</text>\r\n</a>\r\n";
  575. }
  576. if (node.Type == 1)
  577. {
  578. strReturn += $"<rect x =\"{(node.x-node.width/2)}\" y=\"{(node.y-node.height/2)}\" rx=\"10\" ry=\"10\" width=\"{node.width}\" height=\"{node.height}\" style=\"fill:{node.FillColor};stroke:black;stroke-width:3;opacity:0.5\"/>\r\n";
  579. strReturn += $"<a ondblclick =\"() => DoubleClickNode(node)\" onclick=\"()=>ClickNode(node)\">\r\n";
  580. strReturn += $"<text x =\"{node.x}\" y=\"{node.y}\" fill=\"black\" alignment-baseline=\"middle\" text-anchor=\"middle\" font-size=\"{rectFontSize}\" font-weight=\"700\">\r\n";
  581. if (node.NodeObject is entity.workflowDefine.Action)
  582. {
  583. strReturn += ((workflow.InitAction == null || string.IsNullOrEmpty(workflow.InitAction.Name)) ? $"启动{workflow.Name}" : workflow.InitAction.Name) + "\r\n";
  584. }
  585. else
  586. {
  587. strReturn += (((entity.workflowDefine.Step)node.NodeObject).Name) + "\r\n";
  588. }
  589. strReturn += "</text>\r\n</a>\r\n";
  590. if (SelectedShape == node)
  591. {
  592. strReturn += $"<circle cx =\"{(node.x - node.width / 2)}\" cy=\"{(node.y)}\" r=\"3\" stroke=\"black\" stroke-width=\"1\" fill=\"white\"/>\r\n";
  593. strReturn += $"<circle cx =\"{(node.x + node.width / 2)}\"cy=\"{(node.y)}\" r=\"3\" stroke=\"black\" stroke-width=\"1\" fill=\"white\"/>\r\n";
  594. strReturn += $"<circle cx =\"{(node.x)}\" cy=\"{(node.y - node.height / 2)}\" r=\"3\" stroke=\"black\" stroke-width=\"1\" fill=\"white\"/>\r\n";
  595. strReturn += $"<circle cx =\"{(node.x)}\" cy=\"{(node.y + node.height / 2)}\" r=\"3\" stroke=\"black\" stroke-width=\"1\" fill=\"white\"/>\r\n";
  596. }
  597. }
  598. }
  599. }
  600. foreach (var t in Transfers)
  601. {
  602. dynamic ret = GetLineParater(t);
  603. strReturn += $"<line x1 =\"{ret.x1}\" y1=\"{ret.y1}\" x2=\"{ret.x2}\" y2=\"{ret.y2}\" stroke=\"black\" stroke-width=\"2\" marker-end=\"url(#idArrow)\"/>\r\n";
  604. strReturn += $"<circle cx =\"{((ret.x1 + ret.x2) / 2)}\" cy=\"{((ret.y1 + ret.y2) / 2)}\" r=\"7\" stroke=\"black\" stroke-width=\"1.5\" fill=\"white\"/>\r\n";
  605. strReturn += $"<a ondblclick =\"() => DoubleClickTrasfer(t)\" onclick=\"()=>ClickTrasfer(t)\">\r\n";
  606. strReturn += $"<text x =\"{((ret.x1 + ret.x2) / 2)}\" y=\"{((ret.y1 + ret.y2) / 2)}\" fill=\"black\" alignment-baseline=\"middle\" text-anchor=\"middle\" font-size=\"12\">c</text>\r\n";
  607. strReturn += "</a>";
  608. }
  609. //dynamic endLine = GetEndStepLine();
  610. //strReturn += $"<line x1 =\"{endLine.x1}\" y1=\"{endLine.y1}\" x2=\"{endLine.x2}\" y2=\"{endLine.y2}\" stroke=\"black\" stroke-width=\"2\" marker-end=\"url(#idArrow)\"/>\r\n";
  611. }
  612. return strReturn + "</svg>";
  613. }
  614. }
  615. }