mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
1. Workben项目中,优化了Node的入参类型与返回类型包含泛型成员的类型显示。
This commit is contained in:
@@ -10,9 +10,15 @@ using System.Windows;
|
||||
|
||||
namespace Serein.Workbench.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// 将集合的元素数量转换为可见性。
|
||||
/// </summary>
|
||||
internal class CountToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public bool Inverse { get; set; } = false; // 可选:反转逻辑
|
||||
/// <summary>
|
||||
/// 可选:是否反转逻辑。
|
||||
/// </summary>
|
||||
public bool Inverse { get; set; } = false;
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
|
||||
@@ -8,9 +8,12 @@ using System.Windows.Data;
|
||||
|
||||
namespace Serein.Workbench.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// 选择方法详情的转换器
|
||||
/// </summary>
|
||||
internal class MethodDetailsSelectorConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
bool isShareParam = (bool)values[0];
|
||||
var nodeDetails = values[1];
|
||||
|
||||
36
Workbench/Converters/TypeNameDisplaynConverter.cs
Normal file
36
Workbench/Converters/TypeNameDisplaynConverter.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Serein.Library.Utils;
|
||||
using Serein.Workbench.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Serein.Workbench.Converters
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 类型名称显示转换器
|
||||
/// </summary>
|
||||
internal class TypeNameDisplaynConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if(value is Type type)
|
||||
{
|
||||
string typeName = type.GetFriendlyName(false);
|
||||
return typeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
|
||||
namespace Serein.Workbench.Extension
|
||||
{
|
||||
@@ -44,34 +39,4 @@ namespace Serein.Workbench.Extension
|
||||
return new Vector(me.X, me.Y);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向量(Vector)的扩展方法
|
||||
/// </summary>
|
||||
public static class VectorExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 计算两个向量的点积。
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
public static double DotProduct(this Vector a, Vector b)
|
||||
{
|
||||
return a.X * b.X + a.Y * b.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算两个向量的叉积。
|
||||
/// </summary>
|
||||
/// <param name="v"></param>
|
||||
/// <returns></returns>
|
||||
public static Vector NormalizeTo(this Vector v)
|
||||
{
|
||||
var temp = v;
|
||||
temp.Normalize();
|
||||
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Workbench/Extension/VectorExtension.cs
Normal file
40
Workbench/Extension/VectorExtension.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Serein.Workbench.Extension
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 向量(Vector)的扩展方法
|
||||
/// </summary>
|
||||
public static class VectorExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 计算两个向量的点积。
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <param name="b"></param>
|
||||
/// <returns></returns>
|
||||
public static double DotProduct(this Vector a, Vector b)
|
||||
{
|
||||
return a.X * b.X + a.Y * b.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算两个向量的叉积。
|
||||
/// </summary>
|
||||
/// <param name="v"></param>
|
||||
/// <returns></returns>
|
||||
public static Vector NormalizeTo(this Vector v)
|
||||
{
|
||||
var temp = v;
|
||||
temp.Normalize();
|
||||
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
xmlns:themes="clr-namespace:Serein.Workbench.Themes"
|
||||
d:DataContext="{d:DesignInstance vm:ActionNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MaxWidth="300">
|
||||
MaxWidth="500">
|
||||
|
||||
<UserControl.Resources>
|
||||
<!--<BooleanToVisibilityConverter x:Key="BoolToVisConverter" />-->
|
||||
@@ -86,7 +86,7 @@
|
||||
<TextBlock Text="result ->" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
<Border Grid.Column="1" BorderThickness="1">
|
||||
<TextBlock Text="{Binding NodeModel.MethodDetails.ReturnType.FullName, Mode=OneTime}" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding NodeModel.MethodDetails.ReturnType, Converter={StaticResource TypeNameDisplaynConverter}}" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Column="2" BorderThickness="1">
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
xmlns:themes="clr-namespace:Serein.Workbench.Themes"
|
||||
d:DataContext="{d:DesignInstance vm:ConditionNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MaxWidth="300">
|
||||
MaxWidth="500">
|
||||
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVis" />
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
xmlns:vm="clr-namespace:Serein.Workbench.Node.ViewModel"
|
||||
d:DataContext="{d:DesignInstance vm:ExpOpNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MaxWidth="300">
|
||||
MaxWidth="500">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
xmlns:themes="clr-namespace:Serein.Workbench.Themes"
|
||||
d:DataContext="{d:DesignInstance vm:FlipflopNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MaxWidth="300">
|
||||
MaxWidth="500">
|
||||
|
||||
<UserControl.Resources>
|
||||
<vm:TypeToStringConverter x:Key="TypeToStringConverter"/>
|
||||
@@ -70,7 +70,7 @@
|
||||
<TextBlock Text="result ->" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
<Border Grid.Column="1" BorderThickness="1">
|
||||
<TextBlock Text="{Binding NodeModel.MethodDetails.ReturnType.FullName, Mode=OneTime}" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding NodeModel.MethodDetails.ReturnType, Converter={StaticResource TypeNameDisplaynConverter}}" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Column="2" BorderThickness="1">
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
xmlns:themes="clr-namespace:Serein.Workbench.Themes"
|
||||
mc:Ignorable="d"
|
||||
MaxWidth="300"
|
||||
|
||||
d:DataContext="{d:DesignInstance vm:FlowCallNodeControlViewModel}">
|
||||
|
||||
<UserControl.Resources>
|
||||
|
||||
@@ -38,14 +38,20 @@ namespace Serein.Workbench.Node.View
|
||||
ViewModel = viewModel;
|
||||
viewModel.NodeModel.DisplayName = "[流程接口]";
|
||||
InitializeComponent();
|
||||
ViewModel.UploadMethodDetailsControl = UploadMethodDetailsControl;
|
||||
ViewModel.UploadNode = UploadMethodDetailsControl;
|
||||
|
||||
}
|
||||
|
||||
private void UploadMethodDetailsControl(MethodDetails methodDetails)
|
||||
private void UploadMethodDetailsControl(IFlowNode? flowNode)
|
||||
{
|
||||
//MethodDetailsControl.MethodDetails = methodDetails;
|
||||
|
||||
if(flowNode is null)
|
||||
{
|
||||
this.MaxWidth = 300;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.MaxWidth = 300;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
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"
|
||||
d:DataContext="{d:DesignInstance vm:GlobalDataNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MaxWidth="300">
|
||||
xmlns:vm="clr-namespace:Serein.Workbench.Node.ViewModel"
|
||||
d:DataContext="{d:DesignInstance vm:GlobalDataNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MaxWidth="500">
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVis" />
|
||||
</UserControl.Resources>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
d:DataContext="{d:DesignInstance vm:NetScriptNodeControlViewModel}"
|
||||
|
||||
mc:Ignorable="d"
|
||||
MinWidth="50">
|
||||
MaxWidth="500">
|
||||
<Grid Background="#FEFAF4">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
|
||||
d:DataContext="{d:DesignInstance vm:ScriptNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MinWidth="50">
|
||||
MaxWidth="500">
|
||||
|
||||
<Grid Background="#FEFAF4">
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
<TextBlock Text="result ->" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
<Border Grid.Column="1" BorderThickness="1">
|
||||
<TextBlock Text="{Binding NodeModel.MethodDetails.ReturnType}" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding NodeModel.MethodDetails.ReturnType, Converter={StaticResource TypeNameDisplaynConverter}}" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Column="2" BorderThickness="1">
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Serein.Workbench.Node.ViewModel
|
||||
/// <summary>
|
||||
/// 刷新方法控件
|
||||
/// </summary>
|
||||
public Action<MethodDetails> UploadMethodDetailsControl;
|
||||
public Action<IFlowNode?> UploadNode;
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
@@ -105,9 +105,11 @@ namespace Serein.Workbench.Node.ViewModel
|
||||
{
|
||||
if(value is null)
|
||||
{
|
||||
UploadNode?.Invoke(null);
|
||||
FlowCallNode.ResetTargetNode(); // 如果是不选择了,则重置一下
|
||||
return;
|
||||
}
|
||||
UploadNode.Invoke(value);
|
||||
FlowCallNode.SetTargetNode(value.Guid); // 重新设置目标节点
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,11 @@
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<!--<IsRoslynComponent>true</IsRoslynComponent>-->
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net462|AnyCPU'">
|
||||
<NoWarn>1701;1702;1573;CS0414</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Node\NodeModel\**" />
|
||||
<Compile Remove="Themes\Condition\**" />
|
||||
@@ -28,6 +32,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Converters\TypeToColorConverter.cs" />
|
||||
<Compile Remove="MainWindow.xaml.cs" />
|
||||
<Compile Remove="MainWindowViewModel.cs" />
|
||||
<Compile Remove="Node\FlipflopRegionControl.xaml.cs" />
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
<converter:InvertableBooleanToVisibilityConverter x:Key="InvertedBoolConverter"/>
|
||||
<converter:EnumToBooleanConverter x:Key="EnumToBooleanConverter"/>
|
||||
<converter:TypeNameDisplaynConverter x:Key="TypeNameDisplaynConverter"/>
|
||||
<local:DescriptionOrNameConverter x:Key="DescOrNameConverter"/>
|
||||
|
||||
|
||||
@@ -21,18 +22,26 @@
|
||||
<Setter.Value>
|
||||
<ControlTemplate x:Name="MethodControlTemplate" TargetType="{x:Type local:MethodDetailsControl}">
|
||||
|
||||
|
||||
<!--根据方法入参数量生成相应的控件-->
|
||||
<ItemsControl ItemsSource="{Binding MethodDetails.ParameterDetailss, RelativeSource={RelativeSource TemplatedParent}}" Background="#E3FDFD" >
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<!-- 共享宽度启用 -->
|
||||
<StackPanel Grid.IsSharedSizeScope="True" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="serein:ParameterData">
|
||||
<Grid DataContext="{Binding}" >
|
||||
<Grid DataContext="{Binding}" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition SharedSizeGroup="Col1" Width="auto"/>
|
||||
<ColumnDefinition SharedSizeGroup="Col2" Width="auto"/>
|
||||
<ColumnDefinition SharedSizeGroup="Col3" Width="auto"/>
|
||||
<ColumnDefinition SharedSizeGroup="Col4" Width="auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
|
||||
</Grid.ColumnDefinitions>
|
||||
<!--连接控制器-->
|
||||
<view:ArgJunctionControl x:Name="ArgJunctionControl" Grid.Column="0" ArgIndex="{Binding Index}"
|
||||
@@ -43,7 +52,7 @@
|
||||
<CheckBox Grid.Column="1" IsChecked="{Binding IsExplicitData, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="2,0,2,0" VerticalContentAlignment="Center"/>
|
||||
|
||||
<!--参数类型提示-->
|
||||
<TextBlock Grid.Column="2" Text="{Binding DataType}" Margin="2,0,2,0" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="2" Text="{Binding DataType, Converter={StaticResource TypeNameDisplaynConverter}}" Margin="2,0,2,0" VerticalAlignment="Center"/>
|
||||
|
||||
|
||||
<!--入参参数名称-->
|
||||
@@ -144,6 +153,7 @@
|
||||
</ContentControl.Style>
|
||||
</ContentControl>
|
||||
|
||||
|
||||
<!--增加可选参数(如果有)-->
|
||||
<view:ParamsArgControl x:Name="ParamsArgControl"
|
||||
ArgIndex="{Binding Index}"
|
||||
|
||||
Reference in New Issue
Block a user