mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-17 13:26:34 +08:00
1. 重新设计了Generate项目及相关特性的命名,避免与其他类型混淆。
2. 补充了部分注释。 3. 修改了删除容器节点时,容器内子节点未正确删除的问题。
This commit is contained in:
56
NodeFlow/Model/Operations/CreateCanvasOperation.cs
Normal file
56
NodeFlow/Model/Operations/CreateCanvasOperation.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Serein.Library;
|
||||
using Serein.Library.Api;
|
||||
using Serein.NodeFlow.Model.Nodes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.NodeFlow.Model.Operations
|
||||
{
|
||||
internal class CreateCanvasOperation : OperationBase
|
||||
{
|
||||
public override string Theme => nameof(CreateCanvasOperation);
|
||||
public override bool IsCanUndo => false;
|
||||
|
||||
public required FlowCanvasDetailsInfo CanvasInfo { get; set; }
|
||||
|
||||
|
||||
|
||||
private FlowCanvasDetails? flowCanvasDetails;
|
||||
|
||||
public override bool ValidationParameter()
|
||||
{
|
||||
if (CanvasInfo is null)
|
||||
return false; // 没有必须的参数
|
||||
if (string.IsNullOrEmpty(CanvasInfo.Guid))
|
||||
return false; // 不能没有Guid
|
||||
if(flowModelService.ContainsCanvasModel(CanvasInfo.Guid))
|
||||
return false; // 画布已存在
|
||||
return true;
|
||||
}
|
||||
|
||||
public override async Task<bool> ExecuteAsync()
|
||||
{
|
||||
if(!ValidationParameter()) return false;
|
||||
|
||||
var cavasnModel = new FlowCanvasDetails(flowEnvironment);
|
||||
cavasnModel.LoadInfo(CanvasInfo);
|
||||
flowModelService.AddCanvasModel(cavasnModel);
|
||||
this.flowCanvasDetails = cavasnModel; ;
|
||||
|
||||
await TriggerEvent(() =>
|
||||
{
|
||||
flowEnvironmentEvent.OnCanvasCreated(new CanvasCreateEventArgs(cavasnModel));
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ToInfo()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user