2024-08-06 16:09:46 +08:00
|
|
|
|
using Serein.NodeFlow.Model;
|
2024-10-15 21:56:09 +08:00
|
|
|
|
using Serein.Workbench.Node.ViewModel;
|
2024-08-07 21:17:19 +08:00
|
|
|
|
using System.Runtime.CompilerServices;
|
2024-10-24 23:32:43 +08:00
|
|
|
|
using System.Windows;
|
2024-08-07 21:17:19 +08:00
|
|
|
|
using System.Windows.Controls;
|
2024-10-24 23:32:43 +08:00
|
|
|
|
using System.Windows.Media;
|
2024-08-05 10:11:58 +08:00
|
|
|
|
|
2024-10-15 21:56:09 +08:00
|
|
|
|
namespace Serein.Workbench.Node.View
|
2024-08-05 10:11:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// ActionNode.xaml 的交互逻辑
|
|
|
|
|
|
/// </summary>
|
2024-10-24 23:32:43 +08:00
|
|
|
|
public partial class ActionNodeControl : NodeControlBase, INodeJunction
|
2024-08-05 10:11:58 +08:00
|
|
|
|
{
|
2024-10-23 19:22:27 +08:00
|
|
|
|
public ActionNodeControl(ActionNodeControlViewModel viewModel) : base(viewModel)
|
2024-08-05 10:11:58 +08:00
|
|
|
|
{
|
2024-09-12 20:32:54 +08:00
|
|
|
|
DataContext = viewModel;
|
2024-08-05 10:11:58 +08:00
|
|
|
|
InitializeComponent();
|
2024-10-24 23:32:43 +08:00
|
|
|
|
ExecuteJunctionControl.MyNode.Guid = viewModel.NodeModel.Guid;
|
2024-08-05 10:11:58 +08:00
|
|
|
|
}
|
2024-10-23 19:22:27 +08:00
|
|
|
|
|
2024-10-24 23:32:43 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 入参控制点(可能有,可能没)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
JunctionControlBase INodeJunction.ExecuteJunction => this.ExecuteJunctionControl;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 下一个调用方法控制点(可能有,可能没)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
|
|
|
|
JunctionControlBase INodeJunction.NextStepJunction => this.NextStepJunctionControl;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 返回值控制点(可能有,可能没)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
JunctionControlBase INodeJunction.ReturnDataJunction => this.ResultJunctionControl;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 方法入参控制点(可能有,可能没)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
JunctionControlBase[] INodeJunction.ArgDataJunction { get {
|
|
|
|
|
|
if(argDataJunction == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 获取 MethodDetailsControl 实例
|
|
|
|
|
|
var methodDetailsControl = this.MethodDetailsControl;
|
|
|
|
|
|
argDataJunction = new JunctionControlBase[base.ViewModel.NodeModel.MethodDetails.ParameterDetailss.Length];
|
|
|
|
|
|
|
|
|
|
|
|
var itemsControl = FindVisualChild<ItemsControl>(methodDetailsControl); // 查找 ItemsControl
|
|
|
|
|
|
if (itemsControl != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var controls = new List<JunctionControlBase>();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < itemsControl.Items.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var container = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as FrameworkElement;
|
|
|
|
|
|
if (container != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var argControl = FindVisualChild<ArgJunctionControl>(container);
|
|
|
|
|
|
if (argControl != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
controls.Add(argControl); // 收集 ArgJunctionControl 实例
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
argDataJunction = controls.ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return argDataJunction;
|
|
|
|
|
|
} }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 方法入参控制点(可能有,可能没)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private JunctionControlBase[] argDataJunction;
|
|
|
|
|
|
|
|
|
|
|
|
private T FindVisualChild<T>(DependencyObject parent) where T : DependencyObject
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var child = VisualTreeHelper.GetChild(parent, i);
|
|
|
|
|
|
if (child is T typedChild)
|
|
|
|
|
|
{
|
|
|
|
|
|
return typedChild;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var childOfChild = FindVisualChild<T>(child);
|
|
|
|
|
|
if (childOfChild != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return childOfChild;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2024-08-05 10:11:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|