mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-08 08:56:35 +08:00
脚本节点能够自定义变量名
This commit is contained in:
@@ -3,12 +3,17 @@
|
||||
xmlns:local="clr-namespace:Serein.Workbench.Themes"
|
||||
xmlns:view="clr-namespace:Serein.Workbench.Node.View"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:serein="clr-namespace:Serein.Library;assembly=Serein.Library"
|
||||
xmlns:converters="clr-namespace:Serein.Workbench.Tool.Converters">
|
||||
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
|
||||
<converters:InvertableBooleanToVisibilityConverter x:Key="InvertedBoolConverter"/>
|
||||
<converters:EnumToBooleanConverter x:Key="EnumToBooleanConverter"/>
|
||||
|
||||
<Style TargetType="{x:Type local:MethodDetailsControl}">
|
||||
<Setter Property="Template">
|
||||
@@ -18,8 +23,8 @@
|
||||
<!--根据方法入参数量生成相应的控件-->
|
||||
<ItemsControl ItemsSource="{Binding MethodDetails.ParameterDetailss, RelativeSource={RelativeSource TemplatedParent}}" Background="#E3FDFD" >
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid >
|
||||
<DataTemplate DataType="serein:ParameterData">
|
||||
<Grid DataContext="{Binding}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
@@ -31,11 +36,70 @@
|
||||
<!--连接控制器-->
|
||||
<view:ArgJunctionControl x:Name="ArgJunctionControl" Grid.Column="0" ArgIndex="{Binding Index}" MyNode="{Binding NodeModel}" />
|
||||
<!--参数索引提示-->
|
||||
<TextBlock Grid.Column="1" Text="{Binding Index,StringFormat=agr{0}}" Margin="2,0,2,0" VerticalAlignment="Center"/>
|
||||
<!--<TextBlock Grid.Column="1" Text="{Binding Index,StringFormat=agr{0}}" Margin="2,0,2,0" VerticalAlignment="Center"/>-->
|
||||
|
||||
<!--是否设置为显式参数-->
|
||||
<CheckBox Grid.Column="2" IsChecked="{Binding IsExplicitData, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="2,0,2,0" VerticalContentAlignment="Center"/>
|
||||
|
||||
|
||||
<!--入参参数名称-->
|
||||
<TextBlock Grid.Column="3" MinWidth="50" Text="{Binding Name}" Margin="2,0,2,0" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<ContentControl Content="{Binding}" Grid.Column="3" Margin="2,0,2,0" HorizontalAlignment="Left" VerticalAlignment="Center">
|
||||
<ContentControl.Resources>
|
||||
<local:DataContextProxy x:Key="Proxy"
|
||||
DataContext="{Binding}" />
|
||||
</ContentControl.Resources>
|
||||
<ContentControl.Style>
|
||||
<Style TargetType="ContentControl">
|
||||
<Style.Triggers>
|
||||
|
||||
<!--脚本节点输入变量名称-->
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding NodeModel.ControlType}" Value="{x:Static serein:NodeControlType.Script}"/>
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBox MinWidth="50" Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"/>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</MultiDataTrigger>
|
||||
|
||||
|
||||
<!--显示Action节点方法入参名称-->
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding NodeModel.ControlType}" Value="{x:Static serein:NodeControlType.Action}"/>
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock Grid.Column="0" MinWidth="50" Text="{Binding Name}"/>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</MultiDataTrigger>
|
||||
|
||||
<!--显示Flip方法入参名称-->
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding NodeModel.ControlType}" Value="{x:Static serein:NodeControlType.Flipflop}"/>
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock Grid.Column="0" MinWidth="50" Text="{Binding Name}"/>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</MultiDataTrigger>
|
||||
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ContentControl.Style>
|
||||
</ContentControl>
|
||||
|
||||
<!--增加可选参数(如果有)-->
|
||||
<view:ParamsArgControl x:Name="ParamsArgControl"
|
||||
ArgIndex="{Binding Index}"
|
||||
@@ -44,7 +108,7 @@
|
||||
Grid.Column="5" Margin="2,0,2,0" HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Visibility="{Binding IsParams, Mode=OneWay,
|
||||
Converter={StaticResource InvertedBoolConverter},ConverterParameter=Normal}"
|
||||
/>
|
||||
/>
|
||||
|
||||
<ContentControl Content="{Binding}" Grid.Column="4" VerticalAlignment="Center">
|
||||
<ContentControl.Style>
|
||||
|
||||
@@ -39,6 +39,29 @@ namespace Serein.Workbench.Themes
|
||||
}
|
||||
|
||||
|
||||
public class DataContextProxy : Freezable
|
||||
{
|
||||
public DataContextProxy()
|
||||
{
|
||||
BindingOperations.SetBinding(this, DataContextProperty, new Binding());
|
||||
}
|
||||
|
||||
public ParameterDetails DataContext
|
||||
{
|
||||
get { return (ParameterDetails)GetValue(DataContextProperty); }
|
||||
set { SetValue(DataContextProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public static readonly DependencyProperty DataContextProperty = FrameworkElement
|
||||
.DataContextProperty.AddOwner(typeof(DataContextProxy));
|
||||
|
||||
protected override Freezable CreateInstanceCore()
|
||||
{
|
||||
return new DataContextProxy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 方法参数控件
|
||||
@@ -78,13 +101,17 @@ namespace Serein.Workbench.Themes
|
||||
CommandAddParams = new RelayCommand(ExecuteAddParams);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void ExecuteAddParams(object parameter)
|
||||
{
|
||||
// 方法逻辑
|
||||
this.MethodDetails.AddParamsArg();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
27
Workbench/Tool/Converters/EnumToBooleanConverter.cs
Normal file
27
Workbench/Tool/Converters/EnumToBooleanConverter.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Serein.Workbench.Tool.Converters
|
||||
{
|
||||
public class EnumToBooleanConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null || parameter == null)
|
||||
return false;
|
||||
|
||||
return value.ToString().Equals(parameter.ToString(), StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user