修改环境接口(增加画布ID)

This commit is contained in:
fengjiayi
2025-04-03 15:58:57 +08:00
parent b1a9679138
commit ba74facf7d
12 changed files with 25 additions and 21 deletions

View File

@@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>True</UseWPF>
<BaseOutputPath>D:\Project\C#\DynamicControl\SereinFlow\.Output</BaseOutputPath>
<BaseOutputPath>..\.\.Output</BaseOutputPath>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<!--<IsRoslynComponent>true</IsRoslynComponent>-->

View File

@@ -117,7 +117,7 @@ namespace Serein.Workbench.Services
#endregion
#region
@@ -128,10 +128,13 @@ namespace Serein.Workbench.Services
/// <returns></returns>
public void CreateFlowCanvas()
{
string canvasName = "";
int height = 1000;
int width = 600;
_ = flowEnvironment.CreateCanvasAsync(canvasName, width, height);
_ = Task.Run(async () =>
{
var result = await flowEnvironment.CreateCanvasAsync("", width, height);
Console.WriteLine(result.Guid);
});
}
/// <summary>

View File

@@ -28,7 +28,6 @@ namespace Serein.Workbench.ViewModels
[ObservableProperty]
private FlowCanvasModel _selectedTab;
private int _addCount = 0;
private readonly FlowNodeService flowNodeService;
public FlowEditViewModel(FlowNodeService flowNodeService)
@@ -37,8 +36,8 @@ namespace Serein.Workbench.ViewModels
AddTabCommand = new RelayCommand(AddTab);
RemoveTabCommand = new RelayCommand(RemoveTab, CanRemoveTab);
flowNodeService.OnCreateFlowCanvasView += OnCreateFlowCanvasView; // 环境创建了节点
flowNodeService.OnRemoveFlowCanvasView += OnRemoveFlowCanvasView;
flowNodeService.OnCreateFlowCanvasView += OnCreateFlowCanvasView; // 运行环境创建了画布
flowNodeService.OnRemoveFlowCanvasView += OnRemoveFlowCanvasView; // 运行环境移除了画布
this.PropertyChanged += OnPropertyChanged;
}

View File

@@ -19,8 +19,6 @@ namespace Serein.Workbench.ViewModels
[ObservableProperty]
private ObservableCollection<FlowLibraryInfo> flowLibraryInfos;
public FlowLibrarysViewModel(IFlowEEForwardingService flowEEForwardingService)
{
this.flowEEForwardingService = flowEEForwardingService;

View File

@@ -14,8 +14,6 @@ namespace Serein.Workbench.ViewModels
{
private readonly IFlowEEForwardingService flowEEForwardingService;
public FlowWorkbenchViewModel(IFlowEEForwardingService flowEEForwardingService)
{
this.flowEEForwardingService = flowEEForwardingService;

View File

@@ -26,7 +26,7 @@ namespace Serein.Workbench.Views
/// </summary>
public partial class FlowCanvasView : UserControl
{
public FlowCanvasViewModel ViewModel => ViewModel as FlowCanvasViewModel;
public FlowCanvasViewModel ViewModel => this.DataContext as FlowCanvasViewModel;
/// <summary>
/// 存储所有的连接。考虑集成在运行环境中。
/// </summary>
@@ -89,8 +89,8 @@ namespace Serein.Workbench.Views
private IFlowEnvironment EnvDecorator;
public FlowCanvasView()
{
ViewModel = App.GetService<Locator>().FlowCanvasViewModel;
this.DataContext = ViewModel;
var vm = App.GetService<Locator>().FlowCanvasViewModel;
this.DataContext = vm;
EnvDecorator = App.GetService<IFlowEnvironment>();
InitializeComponent();