解决了接口节点的参数共享,UI控件的Menu菜单事件穿透问题,同时优化了工作台画布流程相关事件的部分代码

This commit is contained in:
fengjiayi
2025-05-30 01:02:25 +08:00
parent bbf7f045b0
commit a112d0287f
23 changed files with 635 additions and 457 deletions

View File

@@ -1,5 +1,7 @@
using Serein.NodeFlow.Model;
using Serein.Library;
using Serein.NodeFlow.Model;
using Serein.Workbench.Node.ViewModel;
using Serein.Workbench.Themes;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
@@ -42,35 +44,7 @@ namespace Serein.Workbench.Node.View
/// <summary>
/// 方法入参控制点(可能有,可能没)
/// </summary>
JunctionControlBase[] INodeJunction.ArgDataJunction => GetArgJunction();
private JunctionControlBase[] GetArgJunction()
{
// 获取 MethodDetailsControl 实例
var methodDetailsControl = this.MethodDetailsControl;
var itemsControl = FindVisualChild<ItemsControl>(methodDetailsControl); // 查找 ItemsControl
if (itemsControl != null)
{
var argDataJunction = new JunctionControlBase[base.ViewModel.NodeModel.MethodDetails.ParameterDetailss.Length];
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 实例
}
}
}
return argDataJunction = controls.ToArray();
}
return [];
}
JunctionControlBase[] INodeJunction.ArgDataJunction => GetArgJunction(this, MethodDetailsControl);
}
}

View File

@@ -196,7 +196,7 @@ namespace Serein.Workbench.Node.View
{
leftCenterOfEndLocation = Start.MyCenterPoint;
rightCenterOfStartLocation = End.MyCenterPoint;
(Point startPoint, Point endPoint) = RefreshPoint(Canvas, Start, End);
var connectionType = Start.JunctionType.ToConnectyionType();
bool isDotted;
@@ -214,7 +214,7 @@ namespace Serein.Workbench.Node.View
BezierLine = new ConnectionLineShape(LineType, startPoint, endPoint, brush, isDotted);
Grid.SetZIndex(BezierLine, -9999999); // 置底
Canvas.Children.Add(BezierLine);
ConfigureLineContextMenu(); //配置右键菜单
}

View File

@@ -43,6 +43,7 @@ namespace Serein.Workbench.Node.View
/// 方法入参控制点(可能有,可能没)
/// </summary>
private JunctionControlBase[] argDataJunction;
/// <summary>
/// 方法入参控制点(可能有,可能没)
/// </summary>

View File

@@ -34,34 +34,7 @@ namespace Serein.Workbench.Node.View
/// <summary>
/// 方法入参控制点(可能有,可能没)
/// </summary>
JunctionControlBase[] INodeJunction.ArgDataJunction => GetArgJunction();
private JunctionControlBase[] GetArgJunction()
{
// 获取 MethodDetailsControl 实例
var methodDetailsControl = this.MethodDetailsControl;
var itemsControl = FindVisualChild<ItemsControl>(methodDetailsControl); // 查找 ItemsControl
if (itemsControl != null)
{
var argDataJunction = new JunctionControlBase[base.ViewModel.NodeModel.MethodDetails.ParameterDetailss.Length];
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 实例
}
}
}
return argDataJunction = controls.ToArray();
}
return [];
}
JunctionControlBase[] INodeJunction.ArgDataJunction => GetArgJunction(this, MethodDetailsControl);
}
}

View File

@@ -55,36 +55,9 @@ namespace Serein.Workbench.Node.View
/// <summary>
/// 方法入参控制点(可能有,可能没)
/// </summary>
JunctionControlBase[] INodeJunction.ArgDataJunction => GetArgJunction();
private JunctionControlBase[] GetArgJunction()
{
// 获取 MethodDetailsControl 实例
//var methodDetailsControl = ViewModel.NodeModel.IsShareParam ? this.SelectMethodDetailsControl : this.MyMethodDetailsControl;
var methodDetailsControl = this.MethodDetailsControl;
var itemsControl = FindVisualChild<ItemsControl>(methodDetailsControl); // 查找 ItemsControl
if (itemsControl != null)
{
var argDataJunction = new JunctionControlBase[base.ViewModel.NodeModel.MethodDetails.ParameterDetailss.Length];
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 实例
}
}
}
return argDataJunction = controls.ToArray();
}
return [];
}
JunctionControlBase[] INodeJunction.ArgDataJunction => GetArgJunction(this,MethodDetailsControl);
}
}

View File

@@ -32,8 +32,9 @@
</Grid>
<Border Grid.Row="1" x:Name="EmbedContainer" BorderBrush="Black" BorderThickness="1"
Width="500" Height="400"/>
<Border x:Name="EmbedContainer" Width="200" Height="200" Grid.Row="1" BorderBrush="Black" BorderThickness="1">
<!--<ContentControl />-->
</Border>
</Grid>

View File

@@ -22,6 +22,7 @@ namespace Serein.Workbench.Node.View
/// </summary>
public partial class UINodeControl : NodeControlBase, INodeJunction
{
private new UINodeControlViewModel ViewModel { get; }
public UINodeControl()
{
base.ViewModel.IsEnabledOnView = true;
@@ -30,6 +31,7 @@ namespace Serein.Workbench.Node.View
public UINodeControl(UINodeControlViewModel viewModel) : base(viewModel)
{
ViewModel = viewModel;
DataContext = viewModel;
InitializeComponent();
@@ -49,8 +51,8 @@ namespace Serein.Workbench.Node.View
private void NodeControlBase_Loaded(object sender, RoutedEventArgs e)
{
UINodeControlViewModel vm = (UINodeControlViewModel)DataContext;
vm.InitAdapter(userControl => {
//ViewModel.InitAdapter();
ViewModel.InitAdapter(userControl => {
EmbedContainer.Child = userControl;
});