mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-11 18:36:34 +08:00
更改了拖入的DLL显示名称
尝试添加了web自动化测试(基于Selenium)
This commit is contained in:
@@ -17,12 +17,16 @@ namespace Serein.WorkBench
|
||||
{
|
||||
public class TestObject
|
||||
{
|
||||
|
||||
public NestedObject Data { get; set; }
|
||||
|
||||
public class NestedObject
|
||||
{
|
||||
public int Code { get; set; }
|
||||
public int Code2 { get; set; }
|
||||
|
||||
public string Tips { get; set; }
|
||||
|
||||
}
|
||||
public string ToUpper(string input)
|
||||
{
|
||||
|
||||
@@ -202,7 +202,9 @@ namespace Serein.WorkBench
|
||||
|
||||
|
||||
|
||||
|
||||
public MainWindow()
|
||||
|
||||
{
|
||||
InitializeComponent();
|
||||
logWindow = new LogWindow();
|
||||
@@ -231,8 +233,8 @@ namespace Serein.WorkBench
|
||||
if (nf != null)
|
||||
{
|
||||
InitializeCanvas(nf.basic.canvas.width, nf.basic.canvas.lenght);
|
||||
LoadDll(nf);
|
||||
LoadNodes(nf);
|
||||
LoadDll(nf); // 加载DLL
|
||||
LoadNodeControls(nf); // 加载节点
|
||||
|
||||
var startNode = nodeControls.FirstOrDefault(item => item.Node.Guid.Equals(nf.startNode));
|
||||
if (startNode != null)
|
||||
@@ -242,7 +244,7 @@ namespace Serein.WorkBench
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 设置画布宽度高度
|
||||
private void InitializeCanvas(double width, double height)
|
||||
{
|
||||
FlowChartCanvas.Width = width;
|
||||
@@ -267,7 +269,7 @@ namespace Serein.WorkBench
|
||||
/// 加载配置文件时加载节点/区域
|
||||
/// </summary>
|
||||
/// <param name="nf"></param>
|
||||
private void LoadNodes(SereinOutputFileData nf)
|
||||
private void LoadNodeControls(SereinOutputFileData nf)
|
||||
{
|
||||
var nodeControls = new Dictionary<string, NodeControlBase>();
|
||||
var regionControls = new Dictionary<string, NodeControlBase>();
|
||||
@@ -413,25 +415,28 @@ namespace Serein.WorkBench
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载配置文件时配置节点
|
||||
/// 配置节点(加载配置文件时)
|
||||
/// </summary>
|
||||
/// <param name="nodeConfig">节点配置数据</param>
|
||||
/// <param name="nodeInfo">节点配置数据</param>
|
||||
/// <param name="nodeControl">需要配置的节点</param>
|
||||
/// <param name="nodeControls">节点列表</param>
|
||||
/// <param name="regionControls">区域列表</param>
|
||||
private void ConfigureNodeControl(NodeInfo nodeConfig, NodeControlBase nodeControl, Dictionary<string, NodeControlBase> nodeControls, Dictionary<string, NodeControlBase> regionControls)
|
||||
private void ConfigureNodeControl(NodeInfo nodeInfo,
|
||||
NodeControlBase nodeControl,
|
||||
Dictionary<string, NodeControlBase> nodeControls,
|
||||
Dictionary<string, NodeControlBase> regionControls)
|
||||
{
|
||||
FlowChartCanvas.Dispatcher.Invoke(() =>
|
||||
{
|
||||
FlowChartCanvas.Children.Add(nodeControl);
|
||||
Canvas.SetLeft(nodeControl, nodeConfig.position.x);
|
||||
Canvas.SetTop(nodeControl, nodeConfig.position.y);
|
||||
nodeControls[nodeConfig.guid] = nodeControl;
|
||||
Canvas.SetLeft(nodeControl, nodeInfo.position.x);
|
||||
Canvas.SetTop(nodeControl, nodeInfo.position.y);
|
||||
nodeControls[nodeInfo.guid] = nodeControl;
|
||||
this.nodeControls.Add(nodeControl);
|
||||
|
||||
if (nodeControl is ActionRegionControl || nodeControl is ConditionRegionControl)//如果是区域,则需要创建区域
|
||||
{
|
||||
regionControls[nodeConfig.guid] = nodeControl;
|
||||
regionControls[nodeInfo.guid] = nodeControl;
|
||||
}
|
||||
|
||||
ConfigureContextMenu(nodeControl); // 创建区域
|
||||
@@ -440,7 +445,7 @@ namespace Serein.WorkBench
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载配置文件时创建控件
|
||||
/// 创建控件并配置节点数据(加载配置文件时)
|
||||
/// </summary>
|
||||
/// <param name="nodeInfo"></param>
|
||||
/// <returns></returns>
|
||||
@@ -449,9 +454,10 @@ namespace Serein.WorkBench
|
||||
if (!DllMethodDetails.TryGetValue(nodeInfo.name, out var md))
|
||||
{
|
||||
WriteLog($"目标节点不存在方法信息: {nodeInfo.name}\r\n");
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
NodeControlBase control = nodeInfo.type switch
|
||||
{
|
||||
$"{NodeSpaceName}.{nameof(SingleActionNode)}" => CreateNodeControl<SingleActionNode, ActionNodeControl>(md),
|
||||
@@ -471,11 +477,20 @@ namespace Serein.WorkBench
|
||||
flipflopNodes.Add(flipflopNode);
|
||||
}
|
||||
}
|
||||
return control;// DNF文件加载时创建
|
||||
|
||||
var node = control.Node;
|
||||
if (node != null)
|
||||
{
|
||||
for (int i = 0; i < nodeInfo.parameterData.Length; i++)
|
||||
{
|
||||
Parameterdata? pd = nodeInfo.parameterData[i];
|
||||
node.MethodDetails.ExplicitDatas[i].IsExplicitData = pd.state;
|
||||
node.MethodDetails.ExplicitDatas[i].DataValue = pd.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return control;// DNF文件加载时创建
|
||||
/* NodeControl? nodeControl = nodeInfo.type switch
|
||||
{
|
||||
$"{NodeSpaceName}.{nameof(SingleActionNode)}" => CreateActionNodeControl(md),
|
||||
@@ -490,7 +505,7 @@ namespace Serein.WorkBench
|
||||
|
||||
#region 节点控件的创建
|
||||
|
||||
private static TControl CreateNodeControl<TNode, TControl>(MethodDetails? md = null)
|
||||
private static TControl CreateNodeControl<TNode, TControl>(MethodDetails? methodDetails = null)
|
||||
where TNode : NodeBase
|
||||
where TControl : NodeControlBase
|
||||
{
|
||||
@@ -502,10 +517,12 @@ namespace Serein.WorkBench
|
||||
}
|
||||
|
||||
nodeBase.Guid = Guid.NewGuid().ToString();
|
||||
if (md != null)
|
||||
|
||||
if (methodDetails != null)
|
||||
{
|
||||
var md = methodDetails.Clone();
|
||||
nodeBase.DelegateName = md.MethodName;
|
||||
nodeBase.DisplayName = md.MethodName;
|
||||
nodeBase.DisplayName = md.MethodTips;
|
||||
nodeBase.MethodDetails = md;
|
||||
}
|
||||
|
||||
@@ -618,7 +635,7 @@ namespace Serein.WorkBench
|
||||
/// </summary>
|
||||
// private static ConcurrentDictionary<string, Delegate> globalDicDelegates = new ConcurrentDictionary<string, Delegate>();
|
||||
|
||||
private static readonly ConcurrentDictionary<string, MethodDetails> DllMethodDetails = [];
|
||||
private static ConcurrentDictionary<string, MethodDetails> DllMethodDetails { get; } = [];
|
||||
/// <summary>
|
||||
/// 加载指定路径的DLL文件
|
||||
/// </summary>
|
||||
@@ -767,18 +784,14 @@ namespace Serein.WorkBench
|
||||
Header = "DLL name : " + assembly.GetName().Name // 设置控件标题为程序集名称
|
||||
};
|
||||
|
||||
foreach (var item in conditionTypes)
|
||||
{
|
||||
dllControl.AddCondition(item); // 添加动作类型到控件
|
||||
}
|
||||
|
||||
foreach (var item in actionTypes)
|
||||
{
|
||||
dllControl.AddAction(item); // 添加状态类型到控件
|
||||
dllControl.AddAction(item.Clone()); // 添加动作类型到控件
|
||||
}
|
||||
foreach (var item in flipflopMethods)
|
||||
{
|
||||
dllControl.AddFlipflop(item); // 添加触发器方法到控件
|
||||
dllControl.AddFlipflop(item.Clone()); // 添加触发器方法到控件
|
||||
}
|
||||
|
||||
/*foreach (var item in stateTypes)
|
||||
@@ -996,6 +1009,7 @@ namespace Serein.WorkBench
|
||||
{
|
||||
var data = e.Data.GetData(MouseNodeType.BaseNodeType);
|
||||
|
||||
|
||||
if (data == typeof(ConditionNodeControl))
|
||||
{
|
||||
|
||||
@@ -1010,6 +1024,7 @@ namespace Serein.WorkBench
|
||||
|
||||
}
|
||||
|
||||
|
||||
//if (e.Data.GetData(MouseNodeType.DllNodeType) is MethodDetails methodDetails)
|
||||
//{
|
||||
// if (methodDetails.MethodDynamicType == DynamicNodeType.Condition)
|
||||
@@ -1070,11 +1085,15 @@ namespace Serein.WorkBench
|
||||
{
|
||||
if (element is T)
|
||||
{
|
||||
|
||||
return element as T;
|
||||
|
||||
}
|
||||
element = VisualTreeHelper.GetParent(element);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1787,6 +1806,27 @@ namespace Serein.WorkBench
|
||||
var trueNodes = item.Node.TrueBranch.Select(item => item.Guid).ToArray();
|
||||
var falseNodes = item.Node.FalseBranch.Select(item => item.Guid).ToArray();
|
||||
|
||||
IEnumerable<object?>? parameterData = [];
|
||||
if (node?.MethodDetails?.ExplicitDatas is not null)
|
||||
{
|
||||
parameterData = node?.MethodDetails.ExplicitDatas.Select(it => {
|
||||
|
||||
if (it != null)
|
||||
{
|
||||
return new
|
||||
{
|
||||
state = it.IsExplicitData,
|
||||
value = it.DataValue,
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return new
|
||||
{
|
||||
guid = node.Guid,
|
||||
@@ -1800,7 +1840,9 @@ namespace Serein.WorkBench
|
||||
},
|
||||
trueNodes = trueNodes,
|
||||
falseNodes = falseNodes,
|
||||
parameterData = parameterData,
|
||||
};
|
||||
|
||||
}).ToList();
|
||||
|
||||
|
||||
@@ -1881,8 +1923,12 @@ namespace Serein.WorkBench
|
||||
var dlls = loadedAssemblies.Select(assembly =>
|
||||
{
|
||||
var temp = assembly.GetName();
|
||||
|
||||
string codeBasePath = assembly.CodeBase;
|
||||
|
||||
|
||||
string filePath = new Uri(codeBasePath).LocalPath;
|
||||
|
||||
string relativePath;
|
||||
if (string.IsNullOrEmpty(App.FileDataPath))
|
||||
{
|
||||
@@ -1932,11 +1978,15 @@ namespace Serein.WorkBench
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string targetPath = System.IO.Path.Combine(savePath, System.IO.Path.GetFileName(dll.CodeBase));
|
||||
|
||||
|
||||
// 确保目标目录存在
|
||||
Directory.CreateDirectory(savePath);
|
||||
|
||||
var sourceFile = new Uri(dll.CodeBase).LocalPath;
|
||||
|
||||
// 复制文件到目标目录
|
||||
File.Copy(sourceFile, targetPath, true);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
>
|
||||
<Grid>
|
||||
<Grid.ToolTip>
|
||||
<ToolTip Background="LightYellow" Foreground="Black" Content="{Binding MethodDetails.MethodTips, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<ToolTip Background="LightYellow" Foreground="Black" Content="{Binding MethodDetails.MethodName, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</Grid.ToolTip>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
@@ -20,7 +20,7 @@
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border Grid.Row="0" Background="#FFCFDF" BorderBrush="#FFCFDF" BorderThickness="1">
|
||||
<TextBlock Text="{Binding MethodDetails.MethodName, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding MethodDetails.MethodTips, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<themes:MethodDetailsControl Grid.Row="1" MethodDetails="{Binding MethodDetails}" />
|
||||
<Grid Grid.Row="2" >
|
||||
|
||||
@@ -15,7 +15,9 @@ namespace Serein.WorkBench.Node.View
|
||||
private Point _dragStartPoint;
|
||||
|
||||
private new readonly CompositeActionNode Node;
|
||||
|
||||
public ActionRegionControl() : base()
|
||||
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
@@ -41,16 +41,6 @@ namespace Serein.WorkBench.Node.View
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 向条件面板添加类型的文本块
|
||||
/// </summary>
|
||||
/// <param name="type">要添加的类型</param>
|
||||
public void AddCondition(MethodDetails md)
|
||||
{
|
||||
AddTypeToListBox(md, ConditionsListBox);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向动作面板添加类型的文本块
|
||||
/// </summary>
|
||||
@@ -61,7 +51,7 @@ namespace Serein.WorkBench.Node.View
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向状态面板添加类型的文本块
|
||||
/// 向触发器面板添加类型的文本块
|
||||
/// </summary>
|
||||
/// <param name="type">要添加的类型</param>
|
||||
public void AddFlipflop(MethodDetails md)
|
||||
@@ -79,7 +69,7 @@ namespace Serein.WorkBench.Node.View
|
||||
// 创建一个新的 TextBlock 并设置其属性
|
||||
TextBlock typeText = new TextBlock
|
||||
{
|
||||
Text = $"{md.MethodName}",
|
||||
Text = $"{md.MethodTips}",
|
||||
Margin = new Thickness(10, 2, 0, 0),
|
||||
Tag = md
|
||||
};
|
||||
@@ -125,7 +115,9 @@ namespace Serein.WorkBench.Node.View
|
||||
Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
|
||||
{
|
||||
// 获取触发事件的 TextBlock
|
||||
|
||||
TextBlock typeText = sender as TextBlock;
|
||||
|
||||
if (typeText != null)
|
||||
{
|
||||
// 创建一个 DataObject 用于拖拽操作,并设置拖拽效果
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<Grid>
|
||||
<Grid.ToolTip>
|
||||
<ToolTip Background="LightYellow" Foreground="Black" Content="{Binding MethodDetails.MethodTips, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<ToolTip Background="LightYellow" Foreground="Black" Content="{Binding MethodDetails.MethodName, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</Grid.ToolTip>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
@@ -25,7 +25,7 @@
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border Grid.Row="0" Background="#FFFFD2" BorderBrush="Black" BorderThickness="1">
|
||||
<TextBlock Text="{Binding MethodDetails.MethodName, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding MethodDetails.MethodTips, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<!--<themes:ExplicitDataControl Grid.Row="1" ExplicitDatas="{Binding ExplicitDatas}" />-->
|
||||
<themes:MethodDetailsControl Grid.Row="1" MethodDetails="{Binding MethodDetails}" />
|
||||
|
||||
@@ -17,12 +17,15 @@ namespace Serein.WorkBench.Node.View
|
||||
public abstract class NodeControlBase : UserControl, IDynamicFlowNode
|
||||
{
|
||||
public NodeBase Node { get; set; }
|
||||
|
||||
protected NodeControlBase()
|
||||
|
||||
{
|
||||
this.Background = Brushes.Transparent;
|
||||
}
|
||||
protected NodeControlBase(NodeBase node)
|
||||
{
|
||||
this.Background = Brushes.Transparent;
|
||||
Node = node;
|
||||
}
|
||||
}
|
||||
@@ -32,8 +35,10 @@ namespace Serein.WorkBench.Node.View
|
||||
public abstract class NodeControlViewModel : INotifyPropertyChanged
|
||||
{
|
||||
|
||||
|
||||
public MethodDetails methodDetails;
|
||||
|
||||
|
||||
public MethodDetails MethodDetails
|
||||
{
|
||||
get => methodDetails;
|
||||
@@ -44,9 +49,15 @@ namespace Serein.WorkBench.Node.View
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
|
||||
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
@@ -13,8 +13,6 @@ namespace Serein.WorkBench.Node.ViewModel
|
||||
public ActionNodeControlViewModel(SingleActionNode node)
|
||||
{
|
||||
this.node = node;
|
||||
|
||||
|
||||
MethodDetails = node.MethodDetails;
|
||||
//if (node.MethodDetails.ExplicitDatas.Length == 0)
|
||||
//{
|
||||
|
||||
@@ -12,23 +12,33 @@ namespace Serein.WorkBench
|
||||
/// <summary>
|
||||
/// 基础
|
||||
/// </summary>
|
||||
|
||||
public Basic basic { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的DLL
|
||||
/// </summary>
|
||||
|
||||
public Library[] library { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 起始节点GUID
|
||||
/// </summary>
|
||||
|
||||
public string startNode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 节点信息集合
|
||||
/// </summary>
|
||||
|
||||
public NodeInfo[] nodes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 区域集合
|
||||
/// </summary>
|
||||
|
||||
public Region[] regions { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -39,11 +49,15 @@ namespace Serein.WorkBench
|
||||
/// <summary>
|
||||
/// 画布
|
||||
/// </summary>
|
||||
|
||||
public FlowCanvas canvas { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 版本
|
||||
/// </summary>
|
||||
|
||||
public string versions { get; set; }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 画布
|
||||
@@ -68,15 +82,21 @@ namespace Serein.WorkBench
|
||||
/// <summary>
|
||||
/// DLL名称
|
||||
/// </summary>
|
||||
|
||||
public string name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 路径
|
||||
/// </summary>
|
||||
|
||||
public string path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 提示
|
||||
/// </summary>
|
||||
|
||||
public string tips { get; set; }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 节点
|
||||
@@ -86,32 +106,60 @@ namespace Serein.WorkBench
|
||||
/// <summary>
|
||||
/// GUID
|
||||
/// </summary>
|
||||
|
||||
public string guid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
|
||||
public string name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 显示标签
|
||||
/// </summary>
|
||||
|
||||
public string label { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类型
|
||||
/// </summary>
|
||||
|
||||
public string type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 于画布中的位置
|
||||
/// </summary>
|
||||
|
||||
public Position position { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 真分支节点GUID
|
||||
/// </summary>
|
||||
|
||||
public string[] trueNodes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 假分支节点
|
||||
/// </summary>
|
||||
|
||||
public string[] falseNodes { get; set; }
|
||||
|
||||
|
||||
|
||||
public Parameterdata[] parameterData { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class Parameterdata
|
||||
{
|
||||
public bool state { get; set; }
|
||||
|
||||
public string value { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 节点于画布中的位置
|
||||
/// </summary>
|
||||
@@ -127,7 +175,11 @@ namespace Serein.WorkBench
|
||||
/// </summary>
|
||||
public class Region
|
||||
{
|
||||
|
||||
public string guid { get; set; }
|
||||
|
||||
|
||||
public NodeInfo[] childNodes { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,9 @@ namespace Serein.WorkBench.Themes
|
||||
/// </summary>
|
||||
public partial class TypeViewerWindow : Window
|
||||
{
|
||||
|
||||
public TypeViewerWindow()
|
||||
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user