mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-11 18:36:34 +08:00
优化了节点连接
This commit is contained in:
@@ -89,14 +89,15 @@
|
||||
<!--<Button Grid.Row="0" Content="卸载清空" Click="UnloadAllButton_Click" HorizontalAlignment="Right" Margin="5,5,5,5"/>--><!--
|
||||
</Grid>-->
|
||||
|
||||
<ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Auto">
|
||||
<!--暂时隐藏基础面板-->
|
||||
<ScrollViewer Grid.Row="0" Visibility="Collapsed" HorizontalScrollBarVisibility="Auto">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<nodeView:ExpOpNodeControl x:Name="ExpOpNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<nodeView:ConditionNodeControl x:Name="ConditionNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<nodeView:ConditionRegionControl x:Name="ConditionRegionControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" MaxHeight="400" Grid.RowSpan="2">
|
||||
<ScrollViewer VerticalAlignment="Top" Grid.Row="1" VerticalScrollBarVisibility="Auto" MaxHeight="400" Grid.RowSpan="2">
|
||||
<StackPanel x:Name="DllStackPanel" Margin="5"/>
|
||||
</ScrollViewer>
|
||||
<!--<GridSplitter Grid.Row="3" Height="5" HorizontalAlignment="Stretch" VerticalAlignment="Center" ResizeBehavior="PreviousAndNext" Background="Gray"/>-->
|
||||
@@ -209,21 +210,21 @@ Canvas.Top="{Binding ActualHeight, ElementName=FlowChartCanvas, Mode=OneWay, Con
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<StackPanel x:Name="CreateNodeInvoke"
|
||||
Margin="14" Width="auto" HorizontalAlignment="Left" Background="White" Opacity="0.7"
|
||||
Margin="14" Width="auto" HorizontalAlignment="Left" Background="White" Opacity="0.8"
|
||||
Visibility="{Binding IsConnectionInvokeNode,
|
||||
Converter={StaticResource InvertedBoolConverter},ConverterParameter=Normal}" >
|
||||
<TextBlock Margin="8,2,8,0" Foreground="#FF2727" FontSize="14" Text="正在设置调用关系"/>
|
||||
<TextBlock Margin="8,2,8,0" Foreground="#FF2727" FontSize="14" Text="正在设置方法调用关系 ( 按 Ecs 退出连线状态 )"/>
|
||||
<TextBlock Margin="8,0,8,0" Foreground="#4A82E4" FontSize="14" Text=" 按 1 切换:上游分支(运行本节点前,优先执行目标节点)"/>
|
||||
<TextBlock Margin="8,0,8,0" Foreground="#04FC10" FontSize="14" Text=" 按 2 切换:Succeed 分支(本节点运行完成,将会运行目标节点)"/>
|
||||
<TextBlock Margin="8,0,8,0" Foreground="#F18905" FontSize="14" Text=" 按 3 切换:Fail 分支(条件节点的false分支)"/>
|
||||
<TextBlock Margin="8,0,8,2" Foreground="#FE1343" FontSize="14" Text=" 按 4 切换:异常分支(本节点运行发生异常时执行目标节点)"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="14" Width="auto" HorizontalAlignment="Left" Background="White" Opacity="0.9"
|
||||
<StackPanel Margin="14" Width="auto" HorizontalAlignment="Left" Background="White" Opacity="0.8"
|
||||
Visibility="{Binding IsConnectionArgSourceNode,
|
||||
Converter={StaticResource InvertedBoolConverter},ConverterParameter=Normal}" >
|
||||
<TextBlock Margin="8,2,8,0" Foreground="#FF2727" FontSize="14" Text="正在设置参数传递关系"/>
|
||||
<TextBlock Margin="8,0,8,0" Foreground="#56CEF6" FontSize="14" Text=" 按 1 切换:入参使用目标节点返回值"/>
|
||||
<TextBlock Margin="8,0,8,2" Foreground="#B06BBB" FontSize="14" Text=" 按 2 切换:立刻调用目标节点,其返回值将作为入参参数"/>
|
||||
<TextBlock Margin="8,2,8,0" Foreground="#FF2727" FontSize="14" Text="正在设置参数传递关系 ( 按 Ecs 退出连线状态 )"/>
|
||||
<TextBlock Margin="8,0,8,0" Foreground="#56CEF6" FontSize="14" Text=" 按 1 切换:使用返回值作为当前上下文的入参参数(当前上下文下如果未曾运行过该节点,将会返回null)"/>
|
||||
<TextBlock Margin="8,0,8,2" Foreground="#B06BBB" FontSize="14" Text=" 按 2 切换:立刻调用节点,取其返回值作为当前上下文的入参参数"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
@@ -368,8 +368,9 @@ namespace Serein.Workbench
|
||||
|
||||
if (eventArgs.JunctionOfConnectionType == JunctionOfConnectionType.Invoke)
|
||||
{
|
||||
#region 创建/删除节点之间的调用关系
|
||||
ConnectionInvokeType connectionType = eventArgs.ConnectionInvokeType;
|
||||
#region 创建/删除节点之间的调用关系
|
||||
#region 创建连接
|
||||
if (eventArgs.ChangeType == NodeConnectChangeEventArgs.ConnectChangeType.Create) // 添加连接
|
||||
{
|
||||
if (fromNodeControl is not INodeJunction IFormJunction || toNodeControl is not INodeJunction IToJunction)
|
||||
@@ -383,10 +384,10 @@ namespace Serein.Workbench
|
||||
|
||||
// 添加连接
|
||||
var connection = new ConnectionControl(
|
||||
FlowChartCanvas,
|
||||
FlowChartCanvas,
|
||||
connectionType,
|
||||
startJunction,
|
||||
endJunction,
|
||||
endJunction,
|
||||
() => EnvDecorator.RemoveConnectInvokeAsync(fromNodeGuid, toNodeGuid, connectionType)
|
||||
);
|
||||
|
||||
@@ -403,11 +404,16 @@ namespace Serein.Workbench
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
#region 移除连接
|
||||
else if (eventArgs.ChangeType == NodeConnectChangeEventArgs.ConnectChangeType.Remote) // 移除连接
|
||||
{
|
||||
// 需要移除连接
|
||||
var removeConnections = Connections.Where(c => c.Start.MyNode.Guid.Equals(fromNodeGuid)
|
||||
&& c.End.MyNode.Guid.Equals(toNodeGuid))
|
||||
var removeConnections = Connections.Where(c =>
|
||||
c.Start.MyNode.Guid.Equals(fromNodeGuid)
|
||||
&& c.End.MyNode.Guid.Equals(toNodeGuid)
|
||||
&& (c.Start.JunctionType.ToConnectyionType() == JunctionOfConnectionType.Invoke
|
||||
|| c.End.JunctionType.ToConnectyionType() == JunctionOfConnectionType.Invoke))
|
||||
.ToList();
|
||||
|
||||
|
||||
@@ -417,18 +423,20 @@ namespace Serein.Workbench
|
||||
Connections.Remove(connection);
|
||||
fromNodeControl.RemoveCnnection(connection);
|
||||
toNodeControl.RemoveCnnection(connection);
|
||||
if(NodeControls.TryGetValue(connection.End.MyNode.Guid, out var control))
|
||||
if (NodeControls.TryGetValue(connection.End.MyNode.Guid, out var control))
|
||||
{
|
||||
JudgmentFlipFlopNode(control); // 连接关系变更时判断
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
#region 创建/删除节点之间的参数传递关系
|
||||
ConnectionArgSourceType connectionArgSourceType = eventArgs.ConnectionArgSourceType;
|
||||
#region 创建/删除节点之间的参数传递关系
|
||||
#region 创建连接
|
||||
if (eventArgs.ChangeType == NodeConnectChangeEventArgs.ConnectChangeType.Create) // 添加连接
|
||||
{
|
||||
if (fromNodeControl is not INodeJunction IFormJunction || toNodeControl is not INodeJunction IToJunction)
|
||||
@@ -471,6 +479,8 @@ namespace Serein.Workbench
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
#region 移除连接
|
||||
else if (eventArgs.ChangeType == NodeConnectChangeEventArgs.ConnectChangeType.Remote) // 移除连接
|
||||
{
|
||||
// 需要移除连接
|
||||
@@ -478,11 +488,11 @@ namespace Serein.Workbench
|
||||
&& c.End.MyNode.Guid.Equals(toNodeGuid))
|
||||
.ToList(); // 获取这两个节点之间的所有连接关系
|
||||
|
||||
|
||||
|
||||
|
||||
foreach (var connection in removeConnections)
|
||||
{
|
||||
if(connection.End is ArgJunctionControl junctionControl && junctionControl.ArgIndex == eventArgs.ArgIndex)
|
||||
if (connection.End is ArgJunctionControl junctionControl && junctionControl.ArgIndex == eventArgs.ArgIndex)
|
||||
{
|
||||
// 找到符合删除条件的连接线
|
||||
connection.DeleteConnection(); // 从UI层面上移除
|
||||
@@ -491,13 +501,14 @@ namespace Serein.Workbench
|
||||
toNodeControl.RemoveCnnection(connection); // 从节点持有的记录移除
|
||||
}
|
||||
|
||||
|
||||
|
||||
//if (NodeControls.TryGetValue(connection.End.MyNode.Guid, out var control))
|
||||
//{
|
||||
// JudgmentFlipFlopNode(control); // 连接关系变更时判断
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<Border BorderBrush="#8DE9FD" BorderThickness="4">
|
||||
<Grid>
|
||||
<Grid.ToolTip>
|
||||
<ToolTip Background="LightYellow" Foreground="#071042" Content="{Binding NodeModel.MethodDetails.MethodTips}" />
|
||||
<ToolTip Background="LightYellow" Foreground="#071042" Content="{Binding NodeModel.MethodDetails}" />
|
||||
</Grid.ToolTip>
|
||||
|
||||
<!--<TextBlock Text="{Binding NodelModel.DebugSetting.IsInterrupt}}"></TextBlock>-->
|
||||
@@ -66,7 +66,7 @@
|
||||
|
||||
<local:ExecuteJunctionControl Grid.Column="0" MyNode="{Binding NodeModel}" x:Name="ExecuteJunctionControl" HorizontalAlignment="Left" Grid.RowSpan="2"/>
|
||||
<StackPanel Grid.Column="1" Grid.RowSpan="2" >
|
||||
<TextBlock Text="{Binding NodeModel.MethodDetails.MethodTips, Mode=TwoWay}" HorizontalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding NodeModel.DisplayName, Mode=TwoWay}" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<local:NextStepJunctionControl Grid.Column="2" MyNode="{Binding NodeModel}" x:Name="NextStepJunctionControl" HorizontalAlignment="Right" Grid.RowSpan="2"/>
|
||||
|
||||
|
||||
@@ -66,14 +66,14 @@ namespace Serein.Workbench.Node.View
|
||||
/// <summary>
|
||||
/// 向指定面板添加类型的文本块
|
||||
/// </summary>
|
||||
/// <param name="type">要添加的类型</param>
|
||||
/// <param name="panel">要添加到的面板</param>
|
||||
/// <param name="mdInfo">要添加的方法信息</param>
|
||||
/// <param name="listBox">要添加到的面板</param>
|
||||
private void AddTypeToListBox(MethodDetailsInfo mdInfo, ListBox listBox)
|
||||
{
|
||||
// 创建一个新的 TextBlock 并设置其属性
|
||||
TextBlock typeText = new TextBlock
|
||||
{
|
||||
Text = $"{mdInfo.MethodTips}",
|
||||
Text = $"{mdInfo.MethodAnotherName} - {mdInfo.MethodName}",
|
||||
Margin = new Thickness(10, 2, 0, 0),
|
||||
Tag = mdInfo
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<Grid>
|
||||
<Grid.ToolTip>
|
||||
<ToolTip Background="LightYellow" Foreground="#071042" Content="{Binding NodeModel.MethodDetails.MethodName, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<ToolTip Background="LightYellow" Foreground="#071042" Content="{Binding NodeModel.MethodDetails, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</Grid.ToolTip>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
<local:ExecuteJunctionControl Grid.Column="0" MyNode="{Binding NodeModel}" x:Name="ExecuteJunctionControl" HorizontalAlignment="Left" Grid.RowSpan="2"/>
|
||||
<StackPanel Grid.Column="1" Grid.RowSpan="2" >
|
||||
<TextBlock Text="{Binding NodeModel.MethodDetails.MethodTips, Mode=TwoWay}" HorizontalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding NodeModel.DisplayName, Mode=TwoWay}" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<local:NextStepJunctionControl Grid.Column="2" MyNode="{Binding NodeModel}" x:Name="NextStepJunctionControl" HorizontalAlignment="Right" Grid.RowSpan="2"/>
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Serein.Workbench.Themes
|
||||
{ConnectionInvokeType.IsError, []},
|
||||
}
|
||||
};
|
||||
string? itemName = rootNodeModel.MethodDetails?.MethodTips;
|
||||
string? itemName = rootNodeModel.MethodDetails?.MethodAnotherName;
|
||||
if (string.IsNullOrEmpty(itemName))
|
||||
{
|
||||
itemName = rootNodeModel.ControlType.ToString();
|
||||
@@ -123,7 +123,7 @@ namespace Serein.Workbench.Themes
|
||||
RootNode = child,
|
||||
ChildNodes = child.SuccessorNodes,
|
||||
};
|
||||
string? itemName = child?.MethodDetails?.MethodTips;
|
||||
string? itemName = child?.MethodDetails?.MethodAnotherName;
|
||||
if (string.IsNullOrEmpty(itemName))
|
||||
{
|
||||
itemName = child?.ControlType.ToString();
|
||||
@@ -186,7 +186,7 @@ namespace Serein.Workbench.Themes
|
||||
ChildNodes = childNodeModel.SuccessorNodes,
|
||||
};
|
||||
|
||||
string? itemName = childNodeModel?.MethodDetails?.MethodTips;
|
||||
string? itemName = childNodeModel?.MethodDetails?.MethodAnotherName;
|
||||
if (string.IsNullOrEmpty(itemName))
|
||||
{
|
||||
itemName = childNodeModel?.ControlType.ToString();
|
||||
|
||||
Reference in New Issue
Block a user