mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-18 23:46:34 +08:00
解决了接口节点的参数共享,UI控件的Menu菜单事件穿透问题,同时优化了工作台画布流程相关事件的部分代码
This commit is contained in:
@@ -60,7 +60,15 @@ namespace Serein.Workbench.Node.View
|
||||
endPoint = end;
|
||||
this.strokeThickness = 4;
|
||||
InitElementPoint(isDotted, isTop);
|
||||
InvalidateVisual(); // 触发重绘
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await App.UIContextOperation.InvokeAsync(() =>
|
||||
{
|
||||
InvalidateVisual(); // 触发重绘
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Serein.Library;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Serein.Library;
|
||||
using Serein.Library.Api;
|
||||
using Serein.Workbench.Api;
|
||||
using Serein.Workbench.Node.ViewModel;
|
||||
using Serein.Workbench.Themes;
|
||||
using Serein.Workbench.Views;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -146,7 +148,7 @@ namespace Serein.Workbench.Node.View
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="parent"></param>
|
||||
/// <returns></returns>
|
||||
protected T FindVisualChild<T>(DependencyObject parent) where T : DependencyObject
|
||||
protected static T FindVisualChild<T>(DependencyObject parent) where T : DependencyObject
|
||||
{
|
||||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
|
||||
{
|
||||
@@ -165,13 +167,58 @@ namespace Serein.Workbench.Node.View
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static JunctionControlBase[] GetArgJunction(NodeControlBase nodeControl, MethodDetailsControl methodDetailsControl)
|
||||
{
|
||||
// 获取 MethodDetailsControl 实例
|
||||
try
|
||||
{
|
||||
var itemsControl = FindVisualChild<ItemsControl>(methodDetailsControl); // 查找 ItemsControl
|
||||
if (itemsControl != null)
|
||||
{
|
||||
var md = nodeControl.ViewModel.NodeModel.MethodDetails;
|
||||
if (md is null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
if(md.ParameterDetailss is null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
var argDataJunction = new JunctionControlBase[md.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 [];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
SereinEnv.WriteLine(InfoType.ERROR,$"节点获取入参控制点时发生异常{Environment.NewLine}节点:{nodeControl.ViewModel.NodeModel.Guid}");
|
||||
SereinEnv.WriteLine(ex);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//public class FLowNodeObObservableCollection<T> : ObservableCollection<T>
|
||||
//{
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(); //配置右键菜单
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace Serein.Workbench.Node.View
|
||||
/// 方法入参控制点(可能有,可能没)
|
||||
/// </summary>
|
||||
private JunctionControlBase[] argDataJunction;
|
||||
|
||||
/// <summary>
|
||||
/// 方法入参控制点(可能有,可能没)
|
||||
/// </summary>
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
@@ -68,10 +68,9 @@ namespace Serein.Workbench.Node.ViewModel
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (targetNodeControl.FlowCanvas is FlowCanvasView view
|
||||
&& view.DataContext is FlowCanvasViewModel viewModel)
|
||||
if (targetNodeControl.FlowCanvas is FlowCanvasView view )
|
||||
{
|
||||
SelectCanvas = viewModel;
|
||||
SelectCanvas = view.ViewModel;
|
||||
SelectNode = targetNodeControl.ViewModel.NodeModel;
|
||||
}
|
||||
}
|
||||
@@ -80,8 +79,10 @@ namespace Serein.Workbench.Node.ViewModel
|
||||
{
|
||||
flowEEForwardingService.OnCanvasCreate += (e) => RershCanvass(); // 画布创建了
|
||||
flowEEForwardingService.OnCanvasRemove += (e) => RershCanvass(); // 画布移除了
|
||||
|
||||
}
|
||||
|
||||
|
||||
partial void OnSelectCanvasChanged(FlowCanvasViewModel value)
|
||||
{
|
||||
FlowCallNode.ResetTargetNode();
|
||||
@@ -89,7 +90,12 @@ namespace Serein.Workbench.Node.ViewModel
|
||||
|
||||
partial void OnSelectNodeChanged(NodeModelBase value)
|
||||
{
|
||||
FlowCallNode.SetTargetNode(value);
|
||||
if(value is null)
|
||||
{
|
||||
FlowCallNode.ResetTargetNode();
|
||||
return;
|
||||
}
|
||||
FlowCallNode.SetTargetNode(value.Guid);
|
||||
}
|
||||
|
||||
private void RershCanvass()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Serein.Library;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Serein.Library;
|
||||
using Serein.Library.Api;
|
||||
using Serein.NodeFlow.Model;
|
||||
using System;
|
||||
@@ -10,17 +11,24 @@ using System.Windows.Controls;
|
||||
|
||||
namespace Serein.Workbench.Node.ViewModel
|
||||
{
|
||||
public class UINodeControlViewModel : NodeControlViewModelBase
|
||||
public partial class UINodeControlViewModel : NodeControlViewModelBase
|
||||
{
|
||||
private SingleUINode NodeModel => (SingleUINode)base.NodeModel;
|
||||
//public IEmbeddedContent Adapter => NodeModel.Adapter;
|
||||
|
||||
/// <summary>
|
||||
/// 节点UI的对应内容
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private UserControl _nodeUIContent;
|
||||
|
||||
|
||||
public UINodeControlViewModel(NodeModelBase nodeModel) : base(nodeModel)
|
||||
{
|
||||
//NodeModel.Adapter.GetWindowHandle();
|
||||
|
||||
}
|
||||
|
||||
public void InitAdapter(Action<UserControl> setUIDisplayHandle)
|
||||
public void InitAdapter()
|
||||
{
|
||||
Task.Factory.StartNew(async () =>
|
||||
{
|
||||
@@ -32,11 +40,32 @@ namespace Serein.Workbench.Node.ViewModel
|
||||
&& NodeModel.Adapter.GetUserControl() is UserControl userControl)
|
||||
{
|
||||
NodeModel.Env.UIContextOperation.Invoke(() =>
|
||||
{
|
||||
NodeUIContent = userControl;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void InitAdapter(Action<UserControl> setUIDisplayHandle)
|
||||
{
|
||||
Task.Factory.StartNew(async () =>
|
||||
{
|
||||
var context = new DynamicContext(NodeModel.Env);
|
||||
var cts = new CancellationTokenSource();
|
||||
var result = await NodeModel.ExecutingAsync(context, cts.Token);
|
||||
cts?.Dispose();
|
||||
if (context.NextOrientation == ConnectionInvokeType.IsSucceed
|
||||
&& NodeModel.Adapter.GetUserControl() is UserControl userControl)
|
||||
{
|
||||
NodeModel.Env.UIContextOperation.Invoke(() =>
|
||||
{
|
||||
setUIDisplayHandle.Invoke(userControl);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user