mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-11 20:19:24 +08:00
修复了脚本语言中构造器赋值的 bug
This commit is contained in:
@@ -8,6 +8,7 @@ using Serein.NodeFlow.Services;
|
||||
using Serein.Workbench.Api;
|
||||
using Serein.Workbench.Services;
|
||||
using Serein.Workbench.ViewModels;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -55,6 +56,23 @@ namespace Serein.Workbench
|
||||
// 这里是测试代码,可以删除
|
||||
private async Task LoadLocalProjectAsync()
|
||||
{
|
||||
var properties = new Dictionary<string, Type>
|
||||
{
|
||||
{ "Id", typeof(int) },
|
||||
{ "Name", typeof(string) },
|
||||
{ "CreateTime", typeof(DateTime) }
|
||||
};
|
||||
|
||||
var type = DynamicObjectHelper.CreateTypeWithINotifyPropertyChanged(properties, "MyDynamicClass");
|
||||
dynamic? obj = Activator.CreateInstance(type);
|
||||
if(obj is null) return;
|
||||
if (obj is INotifyPropertyChanged npc)
|
||||
{
|
||||
npc.PropertyChanged += (s, e) => Debug.WriteLine($"属性改变: {e.PropertyName}");
|
||||
}
|
||||
obj.Name = "下北泽";
|
||||
obj.Id = 114514;
|
||||
|
||||
|
||||
if (1 == 11)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
xmlns:local="clr-namespace:Serein.Workbench.Node.View"
|
||||
xmlns:vm="clr-namespace:Serein.Workbench.Node.ViewModel"
|
||||
xmlns:themes="clr-namespace:Serein.Workbench.Themes"
|
||||
xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
|
||||
d:DataContext="{d:DesignInstance vm:ScriptNodeControlViewModel}"
|
||||
mc:Ignorable="d"
|
||||
MinWidth="50">
|
||||
@@ -56,7 +57,17 @@
|
||||
<Button Content="执行" Margin="3,0,1,0" Command="{Binding CommandExecuting}" Height="17.2"></Button>
|
||||
</StackPanel>
|
||||
<themes:MethodDetailsControl Grid.Row="1" x:Name="MethodDetailsControl" MethodDetails="{Binding NodeModel.MethodDetails}" NodeViewModel="{Binding}"/>
|
||||
<TextBox Grid.Row="2" MinHeight="20" MinWidth="100" MaxWidth="270" TextWrapping="Wrap" AcceptsReturn="True" IsEnabled="{Binding IsEnabledOnView}" Text="{Binding Script}"></TextBox>
|
||||
<!--<TextBox Grid.Row="2" MinHeight="20" MinWidth="100" TextWrapping="Wrap" AcceptsReturn="True" IsEnabled="{Binding IsEnabledOnView}" Text="{Binding Script}"></TextBox>-->
|
||||
|
||||
<avalonEdit:TextEditor Grid.Row="2"
|
||||
x:Name="codeEditor"
|
||||
FontFamily="Consolas"
|
||||
FontSize="12"
|
||||
SyntaxHighlighting="C#"
|
||||
TextChanged="codeEditor_TextChanged"
|
||||
ShowLineNumbers="True"
|
||||
Margin="10"/>
|
||||
|
||||
<Grid Grid.Row="3" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50"/>
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace Serein.Workbench.Node.View
|
||||
DataContext = viewModel;
|
||||
viewModel.NodeModel.DisplayName = "[脚本节点]";
|
||||
InitializeComponent();
|
||||
codeEditor.Text = viewModel.Script ?? string.Empty; // 更新代码编辑器内容
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +97,11 @@ namespace Serein.Workbench.Node.View
|
||||
return [];
|
||||
}
|
||||
|
||||
private void codeEditor_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
viewModel.Script = codeEditor.Text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
<PackageReference Include="AvalonEdit" Version="6.3.0.90" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.6" />
|
||||
<!--<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.135" />-->
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ namespace Serein.Workbench.Views
|
||||
{
|
||||
this.DataContext = App.GetService<Locator>().MainViewModel;
|
||||
InitializeComponent();
|
||||
|
||||
Window window = new System.Windows.Window();
|
||||
window.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user