LocalFlowEnvironment文件丢失,需要重写

This commit is contained in:
fengjiayi
2025-06-22 21:53:37 +08:00
parent 999060b67a
commit 97df2a04b2
58 changed files with 4285 additions and 354 deletions

View File

@@ -40,7 +40,7 @@ namespace Serein.Workbench.Customs
/// <summary>
/// FlowMethodInfoListBox.xaml 的交互逻辑
/// </summary>
public partial class FlowMethodInfoListBox : UserControl,System.ComponentModel.INotifyPropertyChanged
public partial class FlowMethodInfoListBox : UserControl, System.ComponentModel.INotifyPropertyChanged
{
private object viewMethodInfo;
public object ViewMethodInfo

View File

@@ -50,7 +50,7 @@ namespace Serein.Workbench.Node.View
this.MouseDown += ParamsArg_OnMouseDown; // 增加或删除
this.MouseMove += ParamsArgControl_MouseMove;
this.MouseLeave += ParamsArgControl_MouseLeave;
AddOrRemoveParamsTask = AddParamAsync;
AddOrRemoveParamsAction = AddParamAsync;
}
@@ -112,11 +112,11 @@ namespace Serein.Workbench.Node.View
private bool isMouseOver; // 鼠标悬停状态
private Func<Task> AddOrRemoveParamsTask; // 增加或删除参数
private Action AddOrRemoveParamsAction; // 增加或删除参数
public async void ParamsArg_OnMouseDown(object sender, MouseButtonEventArgs e)
public void ParamsArg_OnMouseDown(object sender, MouseButtonEventArgs e)
{
await AddOrRemoveParamsTask.Invoke();
AddOrRemoveParamsAction.Invoke();
}
private void ParamsArgControl_MouseMove(object sender, MouseEventArgs e)
@@ -133,7 +133,7 @@ namespace Serein.Workbench.Node.View
// 如果焦点仍在控件上时,则改变点击事件
if (isMouseOver)
{
AddOrRemoveParamsTask = RemoveParamAsync;
AddOrRemoveParamsAction = RemoveParamAsync;
this.Dispatcher.Invoke(InvalidateVisual);// 触发一次重绘
}
@@ -149,7 +149,7 @@ namespace Serein.Workbench.Node.View
private void ParamsArgControl_MouseLeave(object sender, MouseEventArgs e)
{
isMouseOver = false;
AddOrRemoveParamsTask = AddParamAsync; // 鼠标焦点离开时恢复点击事件
AddOrRemoveParamsAction = AddParamAsync; // 鼠标焦点离开时恢复点击事件
cts?.Cancel();
this.Dispatcher.Invoke(InvalidateVisual);// 触发一次重绘
@@ -157,13 +157,13 @@ namespace Serein.Workbench.Node.View
private async Task AddParamAsync()
private void AddParamAsync()
{
await this.MyNode.Env.ChangeParameter(MyNode.Guid, true, ArgIndex);
this.MyNode.Env.ChangeParameter(MyNode.Guid, true, ArgIndex);
}
private async Task RemoveParamAsync()
private void RemoveParamAsync()
{
await this.MyNode.Env.ChangeParameter(MyNode.Guid, false, ArgIndex);
this.MyNode.Env.ChangeParameter(MyNode.Guid, false, ArgIndex);
}
}

View File

@@ -243,11 +243,11 @@ namespace Serein.Workbench.Node.View
var jctEnd = End.JunctionType.ToConnectyionType();
if (jct == JunctionOfConnectionType.Invoke)
{
env.RemoveConnectInvokeAsync(canvasGuid, Start.MyNode.Guid, End.MyNode.Guid, InvokeType);
env.RemoveInvokeConnect(canvasGuid, Start.MyNode.Guid, End.MyNode.Guid, InvokeType);
}
else if (jct == JunctionOfConnectionType.Arg)
{
env.RemoveConnectArgSourceAsync(canvasGuid,Start.MyNode.Guid, End.MyNode.Guid, ArgIndex) ;
env.RemoveArgSourceConnect(canvasGuid,Start.MyNode.Guid, End.MyNode.Guid, ArgIndex) ;
}
}

View File

@@ -1,4 +1,4 @@
using Serein.NodeFlow.Model;
using Serein.NodeFlow.Model.Node;
using Serein.Workbench.Node.View;
namespace Serein.Workbench.Node.ViewModel

View File

@@ -1,4 +1,4 @@
using Serein.NodeFlow.Model;
using Serein.NodeFlow.Model.Node;
using Serein.Workbench.Node.View;
namespace Serein.Workbench.Node.ViewModel

View File

@@ -1,7 +1,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Serein.Library;
using Serein.Library.Api;
using Serein.NodeFlow.Model;
using Serein.NodeFlow.Model.Node;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@@ -27,7 +27,7 @@ namespace Serein.Workbench.Services
/// </summary>
private readonly IFlowEnvironment flowEnvironment;
private readonly IFlowEnvironmentEvent flowEnvironmentEvent;
private readonly UIContextOperation uIContextOperation;
private readonly UIContextOperation uiContextOperation;
/// <summary>
/// 转发流程运行环境各个事件的实现类
@@ -41,7 +41,7 @@ namespace Serein.Workbench.Services
{
this.flowEnvironment = flowEnvironment;
this.flowEnvironmentEvent = flowEnvironmentEvent;
this.uIContextOperation = uIContextOperation;
this.uiContextOperation = uIContextOperation;
InitFlowEnvironmentEvent();
}
@@ -184,7 +184,7 @@ namespace Serein.Workbench.Services
/// <param name="value"></param>
private void FlowEnvironment_OnEnvOutEvent(InfoType type, string value)
{
uIContextOperation.Invoke(() =>
uiContextOperation.Invoke(() =>
{
EnvOutput?.Invoke(type, value);
});
@@ -245,7 +245,10 @@ namespace Serein.Workbench.Services
/// <exception cref="NotImplementedException"></exception>
private void FlowEnvironmentEvent_OnCanvasCreate(CanvasCreateEventArgs eventArgs)
{
CanvasCreated?.Invoke(eventArgs);
uiContextOperation?.Invoke(() =>
{
CanvasCreated?.Invoke(eventArgs);
});
}
/// <summary>

View File

@@ -656,11 +656,7 @@ namespace Serein.Workbench.Services
{
int width = 1200;
int height = 780;
_ = Task.Run(async () =>
{
var result = await flowEnvironment.CreateCanvasAsync("", width, height);
Console.WriteLine(result.Guid);
});
flowEnvironment.CreateCanvas("", width, height);
}
/// <summary>
@@ -673,7 +669,7 @@ namespace Serein.Workbench.Services
return;
}
var model = ((FlowCanvasViewModel)CurrentSelectCanvas.DataContext).Model;
_ = flowEnvironment.RemoveCanvasAsync(model.Guid);
flowEnvironment.RemoveCanvas(model.Guid);
}
/// <summary>
@@ -692,7 +688,7 @@ namespace Serein.Workbench.Services
{
return;
}
_ = flowEnvironment.CreateNodeAsync(canvasGuid, nodeType, position, methodDetailsInfo);
flowEnvironment.CreateNode(canvasGuid, nodeType, position, methodDetailsInfo);
}
/// <summary>
@@ -711,7 +707,7 @@ namespace Serein.Workbench.Services
return;
}
_ = flowEnvironment.RemoveNodeAsync(model.CanvasDetails.Guid, model.Guid);
flowEnvironment.RemoveNode(model.CanvasDetails.Guid, model.Guid);
}
#endregion

View File

@@ -23,6 +23,11 @@ namespace Serein.Workbench.Services
this.flowEnvironment = flowEnvironment;
}
public void StartProjectManagementServer()
{
// CollabrationSideManagement
}
public void LoadLocalProject(string filePath)
{
if (File.Exists(filePath))

View File

@@ -123,7 +123,7 @@ namespace Serein.Workbench.Themes
private void ExecuteAddParams(object parameter)
{
// 方法逻辑
this.MethodDetails.AddParamsArg();
this.MethodDetails.AddParamsArg(0);
}

View File

@@ -8,7 +8,7 @@ namespace Serein.Workbench.ViewModels
{
public class MainMenuBarViewModel : ObservableObject
{
private readonly IFlowEnvironment environment;
private readonly IFlowEnvironment flowEnvironment;
private readonly FlowNodeService flowNodeService;
private readonly FlowProjectService flowProjectService;
@@ -61,12 +61,18 @@ namespace Serein.Workbench.ViewModels
public ICommand OpenDynamicCompilerCommand { get; private set; }
/// <summary>
/// 开启远程服务
/// </summary>
public ICommand OpenRemoteServerCommand { get; private set; }
public MainMenuBarViewModel(IFlowEnvironment environment,
public MainMenuBarViewModel(IFlowEnvironment flowEnvironment,
FlowNodeService flowNodeService,
FlowProjectService flowProjectService)
{
this.environment = environment;
this.flowEnvironment = flowEnvironment;
this.flowNodeService = flowNodeService;
this.flowProjectService = flowProjectService;
SaveProjectCommand = new RelayCommand(SaveProject); // 保存项目
@@ -81,29 +87,51 @@ namespace Serein.Workbench.ViewModels
StopCurrentCanvasFlowCommand = new RelayCommand(StopCurrentCanvasFlow); // 停止当前流程
OpenEnvOutWindowCommand = new RelayCommand(OpenEnvOutWindow); // 打开运行输出窗口
OpenDynamicCompilerCommand = new RelayCommand(OpenDynamicCompiler); // 打开动态编译仓库窗口
OpenDynamicCompilerCommand = new RelayCommand(OpenDynamicCompiler); // 打开动态编译窗口
OpenRemoteServerCommand = new RelayCommand(OpenRemoteServer); // 打开动态编译窗口
this.flowProjectService = flowProjectService;
}
private void SaveProject() => environment.SaveProject(); // 保存项目
private void LoadLocalProject() {
private void SaveProject() => flowEnvironment.SaveProject(); // 保存项目
private void LoadLocalProject()
{
flowProjectService.SelectProjectFile(); //选择项目
}
private void LoadRemoteProject()
{
private void LoadRemoteProject()
{
}
private void CreateFlowCanvas() => flowNodeService.CreateFlowCanvas();
private void RemoteFlowCanvas() => flowNodeService.RemoveFlowCanvas();
private void StartUIFlow() => environment.StartFlowAsync([.. flowNodeService.FlowCanvass.Select(c => c.Guid)]);
private void StartCurrentCanvasFlow() => environment.StartFlowAsync([flowNodeService.CurrentSelectCanvas.Guid]);
private void StartUIFlow()
{
var canvass = flowNodeService.FlowCanvass;
if(canvass.Length > 0)
{
string[] guids = [..canvass.Select(c => c.Guid)];
flowEnvironment.StartFlowAsync(guids);
}
}
private void StartCurrentCanvasFlow()
{
var canvas = flowNodeService.CurrentSelectCanvas;
if (canvas is null) return;
flowEnvironment.StartFlowAsync([canvas.Guid]);
}
private void StopCurrentCanvasFlow() { }
private void OpenDynamicCompiler() { }
private void OpenEnvOutWindow() => LogWindow.Instance?.Show();
private void OpenRemoteServer()
{
flowEnvironment.StartRemoteServerAsync();
}
}
}

View File

@@ -372,7 +372,7 @@ namespace Serein.Workbench.Views
if (TryPlaceNodeInRegion(nodeControl, position, out var regionControl)) // 判断添加到区域容器
{
// 通知运行环境调用加载节点子项的方法
_ = flowEnvironment.PlaceNodeToContainerAsync(Guid,
flowEnvironment.PlaceNodeToContainer(Guid,
nodeControl.ViewModel.NodeModel.Guid, // 待移动的节点
regionControl.ViewModel.NodeModel.Guid); // 目标的容器节点
return;
@@ -566,7 +566,8 @@ namespace Serein.Workbench.Views
// F5 调试当前选定节点
var nodeModel = selectNodeControls[0].ViewModel.NodeModel;
SereinEnv.WriteLine(InfoType.INFO, $"调试运行当前节点:{nodeModel.Guid}");
_ = nodeModel.StartFlowAsync(new DynamicContext(flowEnvironment), new CancellationToken());
_ = flowEnvironment.StartFlowFromSelectNodeAsync(nodeModel.Guid);
//_ = nodeModel.StartFlowAsync(new DynamicContext(flowEnvironment), new CancellationToken());
}
}
@@ -898,7 +899,7 @@ namespace Serein.Workbench.Views
{
var canvasGuid = this.Guid;
await flowEnvironment.ConnectInvokeNodeAsync(
flowEnvironment.ConnectInvokeNode(
canvasGuid,
cd.StartJunction.MyNode.Guid,
cd.CurrentJunction.MyNode.Guid,
@@ -922,7 +923,7 @@ namespace Serein.Workbench.Views
}
var canvasGuid = this.Guid;
await flowEnvironment.ConnectArgSourceNodeAsync(
flowEnvironment.ConnectArgSourceNode(
canvasGuid,
cd.StartJunction.MyNode.Guid,
cd.CurrentJunction.MyNode.Guid,
@@ -1269,7 +1270,7 @@ namespace Serein.Workbench.Views
if (!string.IsNullOrEmpty(guid))
{
var canvasGuid = this.Guid;
flowEnvironment.RemoveNodeAsync(canvasGuid, guid);
flowEnvironment.RemoveNode(canvasGuid, guid);
}
}
}
@@ -1491,10 +1492,10 @@ namespace Serein.Workbench.Views
contextMenu.Items.Add(WpfFuncTool.CreateMenuItem("设为起点", (s, e) => flowEnvironment.SetStartNodeAsync(canvasGuid, nodeGuid)));
contextMenu.Items.Add(WpfFuncTool.CreateMenuItem("设为起点", (s, e) => flowEnvironment.SetStartNode(canvasGuid, nodeGuid)));
contextMenu.Items.Add(WpfFuncTool.CreateMenuItem("删除", async (s, e) =>
{
var result = await flowEnvironment.RemoveNodeAsync(canvasGuid, nodeGuid);
flowEnvironment.RemoveNode(canvasGuid, nodeGuid);
}));
#region -

View File

@@ -14,7 +14,7 @@
<MenuItem Header="项目">
<MenuItem Header="保存项目" Command="{Binding SaveProjectCommand}"></MenuItem>
<MenuItem Header="加载本地项目" Command="{Binding LoadLocalProjectCommand}" ></MenuItem>
<MenuItem Header="加载远程项目"></MenuItem>
<!--<MenuItem Header="加载远程项目"></MenuItem>-->
</MenuItem>
<MenuItem Header="画布">
@@ -24,19 +24,19 @@
<MenuItem Header="运行">
<MenuItem Header="运行(仅当前画布)" Command="{Binding StartCurrentCanvasFlowCommand}"></MenuItem>
<MenuItem Header="运行(从选定节点)" ></MenuItem>
<!--<MenuItem Header="运行(从选定节点)" ></MenuItem>-->
<MenuItem Header="运行(全部画布)" Command="{Binding StartFlowCommand}"></MenuItem>
<MenuItem Header="结束流程" ></MenuItem>
<!--<MenuItem Header="结束流程" ></MenuItem>-->
</MenuItem>
<MenuItem Header="视图">
<MenuItem Header="输出窗口" Command="{Binding OpenEnvOutWindowCommand}"></MenuItem>
<MenuItem Header="定位节点" ></MenuItem>
<!--<MenuItem Header="定位节点" ></MenuItem>-->
</MenuItem>
<!--<MenuItem Header="拓展">
<MenuItem Header="动态编译" ></MenuItem>
<MenuItem Header="拓展">
<!--<MenuItem Header="动态编译" ></MenuItem>-->
<MenuItem Header="启动远程服务"></MenuItem>
</MenuItem>-->
</MenuItem>
</Menu>
</Grid>