FlowTabItem.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using TeamAAS.FlowEditor;
  7. using TeamAAS.FlowEditor.Models;
  8. namespace TeamAAS.FlowEngine.Execution
  9. {
  10. [System.Serializable]
  11. /// <summary>
  12. /// 流程 Tab 项
  13. /// </summary>
  14. public class FlowTabItem : TeamAAS.BindableBase
  15. {
  16. private string _name;
  17. [System.ComponentModel.DisplayName("1.流程名称")]
  18. [System.ComponentModel.Category("I.基本信息")]
  19. [System.ComponentModel.Description("流程的显示名称")]
  20. public string Name
  21. {
  22. get => _name;
  23. set => SetProperty(ref _name, value);
  24. }
  25. private bool _isActive;
  26. [System.ComponentModel.Browsable(false)]
  27. public bool IsActive
  28. {
  29. get => _isActive;
  30. set => SetProperty(ref _isActive, value);
  31. }
  32. [System.ComponentModel.Browsable(false)]
  33. [field: NonSerialized]
  34. public FlowGraph Graph { get; set; }
  35. [System.ComponentModel.Browsable(false)]
  36. [field: NonSerialized]
  37. public FlowEditorViewModel EditorVm { get; set; }
  38. private int _loopCount = 1;
  39. [System.ComponentModel.DisplayName("2.循环次数")]
  40. [System.ComponentModel.Category("I.基本信息")]
  41. [System.ComponentModel.Description("循环次数。-1=无限循环, 0=跳过不执行, 其他=按次数执行")]
  42. public int LoopCount
  43. {
  44. get => _loopCount;
  45. set => SetProperty(ref _loopCount, value);
  46. }
  47. private TriggerType _triggerType = TriggerType.MainFlow;
  48. [System.ComponentModel.DisplayName("3.触发类型")]
  49. [System.ComponentModel.Category("I.基本信息")]
  50. [System.ComponentModel.Description("主流程触发:随主流程自动执行。事件触发:需外部事件触发。")]
  51. public TriggerType TriggerType
  52. {
  53. get => _triggerType;
  54. set => SetProperty(ref _triggerType, value);
  55. }
  56. private int _loopIntervalMs = 10;
  57. [System.ComponentModel.DisplayName("4.循环间隔(ms)")]
  58. [System.ComponentModel.Category("I.基本信息")]
  59. [System.ComponentModel.Description("循环运行模式下,单轮流程结束后等待多少毫秒再开始下一轮。最小1ms,防止空流程卡CPU。")]
  60. public int LoopIntervalMs
  61. {
  62. get => _loopIntervalMs;
  63. set => SetProperty(ref _loopIntervalMs, value < 1 ? 1 : value);
  64. }
  65. [System.ComponentModel.Browsable(false)]
  66. [field: NonSerialized]
  67. public Dictionary<string, string> ModuleOutputs { get; set; } = new Dictionary<string, string>();
  68. private double _canvasWidth = 5000;
  69. [System.ComponentModel.DisplayName("1.画布宽度")]
  70. [System.ComponentModel.Category("II.画布设置")]
  71. [System.ComponentModel.Description("画布的宽度(像素)")]
  72. public double CanvasWidth
  73. {
  74. get => _canvasWidth;
  75. set
  76. {
  77. if (SetProperty(ref _canvasWidth, value))
  78. EditorVm.CanvasWidth = value;
  79. }
  80. }
  81. private double _canvasHeight = 3500;
  82. [System.ComponentModel.DisplayName("2.画布高度")]
  83. [System.ComponentModel.Category("II.画布设置")]
  84. [System.ComponentModel.Description("画布的高度(像素)")]
  85. public double CanvasHeight
  86. {
  87. get => _canvasHeight;
  88. set
  89. {
  90. if (SetProperty(ref _canvasHeight, value))
  91. EditorVm.CanvasHeight = value;
  92. }
  93. }
  94. public FlowTabItem(string name)
  95. {
  96. _name = name;
  97. Graph = new FlowGraph { GraphName = name };
  98. EditorVm = new FlowEditorViewModel(Graph);
  99. EditorVm.CanvasWidth = _canvasWidth;
  100. EditorVm.CanvasHeight = _canvasHeight;
  101. }
  102. }
  103. }