使用异步重构了节点执行方法,将触发器节点与其他节点统一。使用Channel代替Tcs更改了信号触发,使其符合异步编程的习惯。增加了节点是否启用勾选框、参数遮罩勾选框,节点右键面板增加中断功能(试验)。增加了选择后被选择的节点的视觉效果。更改平移缩放逻辑,使其更加符合一般的使用习惯。

This commit is contained in:
fengjiayi
2024-09-20 10:50:32 +08:00
parent 8335094656
commit f5924aa31e
30 changed files with 1298 additions and 539 deletions

View File

@@ -23,6 +23,9 @@ namespace Serein.WorkBench.Node.ViewModel
/// </summary>
internal NodeModelBase Node { get; }
private bool isSelect;
/// <summary>
/// 表示节点控件是否被选中
@@ -37,29 +40,68 @@ namespace Serein.WorkBench.Node.ViewModel
}
}
private MethodDetails methodDetails;
public MethodDetails MethodDetails
public NodeDebugSetting DebugSetting
{
get => methodDetails;
get => Node.DebugSetting;
set
{
methodDetails = value;
OnPropertyChanged();
if (value != null)
{
Node.DebugSetting = value;
OnPropertyChanged(nameof(DebugSetting));
}
}
}
public MethodDetails MethodDetails
{
get => Node.MethodDetails;
set
{
if(value != null)
{
Node.MethodDetails = value;
OnPropertyChanged(nameof(MethodDetails));
}
}
}
public bool IsInterrupt
{
get => Node.DebugSetting.IsInterrupt;
set
{
if (value)
{
Node.Interrupt();
}
else
{
Node.CancelInterrupt();
}
OnPropertyChanged(nameof(IsInterrupt));
}
}
//public bool IsProtectionParameter
//{
// get => MethodDetails.IsProtectionParameter;
// set
// {
// MethodDetails.IsProtectionParameter = value;
// OnPropertyChanged(nameof(IsInterrupt));
// }
//}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
/// <summary>
///
/// </summary>
public void Selected()
{
IsSelect = true;
@@ -69,5 +111,7 @@ namespace Serein.WorkBench.Node.ViewModel
{
IsSelect = false;
}
}
}

View File

@@ -5,43 +5,73 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Serein.WorkBench.Node.View"
xmlns:vm="clr-namespace:Serein.WorkBench.Node.ViewModel"
xmlns:Converters="clr-namespace:Serein.WorkBench.Tool.Converters"
xmlns:themes="clr-namespace:Serein.WorkBench.Themes"
MaxWidth="300">
<UserControl.Resources>
<!--<BooleanToVisibilityConverter x:Key="BoolToVisConverter" />-->
<Converters:InvertableBooleanToVisibilityConverter x:Key="InvertedBoolConverter"/>
</UserControl.Resources>
<Grid>
<Grid.ToolTip>
<ToolTip Background="LightYellow" Foreground="Black" Content="{Binding MethodDetails.MethodName, UpdateSourceTrigger=PropertyChanged}" />
</Grid.ToolTip>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Background="#FFCFDF">
<CheckBox VerticalContentAlignment="Center">
<Border>
<Border.Style>
<Style TargetType="Border">
<!-- 默认无边框 -->
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Style.Triggers>
<!-- 当 DebugSetting.IsInterrupt 为 True 时,显示红色边框 -->
<DataTrigger Binding="{Binding IsInterrupt}" Value="True">
<Setter Property="BorderBrush" Value="Red" />
<Setter Property="BorderThickness" Value="2" />
<Setter Property="Background" Value="#80000000" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
</CheckBox>
<TextBlock Text="{Binding MethodDetails.MethodTips}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<themes:MethodDetailsControl Grid.Row="1" MethodDetails="{Binding MethodDetails}" />
<Grid Grid.Row="2" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Background="#EAFFD0" BorderBrush="#EAFFD0" BorderThickness="1">
<TextBlock Text="result" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Border Grid.Column="1" Background="#EAFFD0" BorderBrush="#EAFFD0" BorderThickness="1">
<TextBlock Text="{Binding MethodDetails.ReturnType}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
</Border>
</Grid>
<StackPanel Grid.Row="0" Orientation="Horizontal" Background="#FFCFDF">
<CheckBox IsChecked="{Binding DebugSetting.IsEnable, Mode=TwoWay}" VerticalContentAlignment="Center"/>
<CheckBox IsChecked="{Binding MethodDetails.IsProtectionParameter, Mode=TwoWay}" VerticalContentAlignment="Center"/>
<TextBlock Text="{Binding MethodDetails.MethodTips}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<themes:MethodDetailsControl Grid.Row="1" MethodDetails="{Binding MethodDetails}"/>
<!-- ParameterProtectionMask 参数保护 -->
<!--取反 Visibility="{Binding DebugSetting.IsEnable, Converter={StaticResource InvertedBoolConverter}, ConverterParameter=Inverted}"-->
<Border Grid.Row="1" x:Name="ParameterProtectionMask" Background="LightBlue" Opacity="0.5" BorderBrush="Black" BorderThickness="0"
Visibility="{Binding MethodDetails.IsProtectionParameter, Converter={StaticResource InvertedBoolConverter},ConverterParameter=Normal}" />
<Grid Grid.Row="2" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Background="#EAFFD0" BorderBrush="#EAFFD0" BorderThickness="1">
<TextBlock Text="result" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Border Grid.Column="1" Background="#EAFFD0" BorderBrush="#EAFFD0" BorderThickness="1">
<TextBlock Text="{Binding MethodDetails.ReturnType}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
</Border>
</Grid>
</Grid>
</Border>
<!--Visibility="{Binding IsEnable, Converter={StaticResource BoolToVisConverter}, ConverterParameter=False}"-->
</Grid>
</local:NodeControlBase>

View File

@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:Serein.WorkBench.Node.View"
MaxWidth="300">
<Grid>
<Border BorderBrush="Black" BorderThickness="1" Padding="10">
<!--<Border BorderBrush="Black" BorderThickness="1" Padding="10">
<StackPanel>
<Grid Margin="2,2,2,5">
<TextBlock Text="动作区域" FontWeight="Bold" HorizontalAlignment="Left" FontSize="14" Margin="0,1,0,0"/>
@@ -14,7 +14,7 @@
</Grid>
<ListBox x:Name="ActionsListBox" AllowDrop="True" Drop="ActionsListBox_Drop" />
</StackPanel>
</Border>
</Border>-->
</Grid>

View File

@@ -8,9 +8,7 @@
xmlns:themes="clr-namespace:Serein.WorkBench.Themes"
MaxWidth="300">
<!--d:DataContext="{d:DesignInstance Type=vm:ConditionNodeControlViewModel}"-->
<UserControl.Resources>
<!--<vm:TypeToStringConverter x:Key="TypeToStringConverter"/>-->
<BooleanToVisibilityConverter x:Key="BoolToVis" />
</UserControl.Resources>