using Serein.NodeFlow.Model;
using Serein.Workbench.Node.ViewModel;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace Serein.Workbench.Node.View
{
///
/// ActionNode.xaml 的交互逻辑
///
public partial class ActionNodeControl : NodeControlBase, INodeJunction
{
public ActionNodeControl(ActionNodeControlViewModel viewModel) : base(viewModel)
{
DataContext = viewModel;
InitializeComponent();
ExecuteJunctionControl.MyNode.Guid = viewModel.NodeModel.Guid;
}
///
/// 入参控制点(可能有,可能没)
///
JunctionControlBase INodeJunction.ExecuteJunction => this.ExecuteJunctionControl;
///
/// 下一个调用方法控制点(可能有,可能没)
///
JunctionControlBase INodeJunction.NextStepJunction => this.NextStepJunctionControl;
///
/// 返回值控制点(可能有,可能没)
///
JunctionControlBase INodeJunction.ReturnDataJunction => this.ResultJunctionControl;
///
/// 方法入参控制点(可能有,可能没)
///
private JunctionControlBase[] argDataJunction;
///
/// 方法入参控制点(可能有,可能没)
///
JunctionControlBase[] INodeJunction.ArgDataJunction { get {
if(argDataJunction == null)
{
// 获取 MethodDetailsControl 实例
var methodDetailsControl = this.MethodDetailsControl;
argDataJunction = new JunctionControlBase[base.ViewModel.NodeModel.MethodDetails.ParameterDetailss.Length];
var itemsControl = FindVisualChild(methodDetailsControl); // 查找 ItemsControl
if (itemsControl != null)
{
var controls = new List();
for (int i = 0; i < itemsControl.Items.Count; i++)
{
var container = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as FrameworkElement;
if (container != null)
{
var argControl = FindVisualChild(container);
if (argControl != null)
{
controls.Add(argControl); // 收集 ArgJunctionControl 实例
}
}
}
argDataJunction = controls.ToArray();
}
}
return argDataJunction;
} }
}
}