mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-19 16:06:33 +08:00
实现了多画布下,节点的复制粘贴功能
This commit is contained in:
@@ -19,9 +19,9 @@ namespace Serein.Workbench.ViewModels
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 画布当前选中的节点
|
||||
/// 画布当前的节点
|
||||
/// </summary>
|
||||
public NodeControlBase CurrentSelectNode { get; set; }
|
||||
public Dictionary<string, NodeControlBase> NodeControls { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 正在创建节点方法调用关系
|
||||
|
||||
@@ -23,9 +23,6 @@ namespace Serein.Workbench.ViewModels
|
||||
public partial class FlowEditViewModel : ObservableObject
|
||||
{
|
||||
public ObservableCollection<FlowEditorTabModel> CanvasTabs { get; set; } = [];
|
||||
public ICommand AddTabCommand { get; set; }
|
||||
public ICommand RemoveTabCommand { get; set; }
|
||||
public ICommand RenameTabCommand { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -39,8 +36,7 @@ namespace Serein.Workbench.ViewModels
|
||||
public FlowEditViewModel(FlowNodeService flowNodeService)
|
||||
{
|
||||
this.flowNodeService = flowNodeService;
|
||||
AddTabCommand = new RelayCommand(AddTab);
|
||||
RemoveTabCommand = new RelayCommand(RemoveTab);
|
||||
|
||||
|
||||
flowNodeService.OnCreateFlowCanvasView += OnCreateFlowCanvasView; // 创建了画布
|
||||
flowNodeService.OnRemoveFlowCanvasView += OnRemoveFlowCanvasView; // 移除了画布
|
||||
@@ -81,13 +77,6 @@ namespace Serein.Workbench.ViewModels
|
||||
#endregion
|
||||
|
||||
|
||||
private void AddTab() => flowNodeService.CreateFlowCanvas();
|
||||
private void RemoveTab()
|
||||
{
|
||||
if (CanvasTabs.Count > 0 && SelectedTab != null) flowNodeService.RemoveFlowCanvas();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Serein.Library;
|
||||
using Serein.Library.Api;
|
||||
using Serein.NodeFlow.Env;
|
||||
using Serein.Workbench.Api;
|
||||
using Serein.Workbench.Models;
|
||||
using Serein.Workbench.Services;
|
||||
@@ -15,16 +17,33 @@ namespace Serein.Workbench.ViewModels
|
||||
internal partial class FlowLibrarysViewModel : ObservableObject
|
||||
{
|
||||
private readonly IFlowEEForwardingService flowEEForwardingService;
|
||||
|
||||
private readonly IFlowEnvironment flowEnvironment;
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<FlowLibraryInfo> flowLibraryInfos;
|
||||
|
||||
public FlowLibrarysViewModel(IFlowEEForwardingService flowEEForwardingService)
|
||||
public FlowLibrarysViewModel(IFlowEEForwardingService flowEEForwardingService,IFlowEnvironment flowEnvironment)
|
||||
{
|
||||
this.flowEEForwardingService = flowEEForwardingService;
|
||||
this.flowEnvironment = flowEnvironment;
|
||||
FlowLibraryInfos = new ObservableCollection<FlowLibraryInfo>();
|
||||
flowEEForwardingService.OnDllLoad += FlowEEForwardingService_OnDllLoad;
|
||||
}
|
||||
/// <summary>
|
||||
/// 加载文件依赖
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
public void LoadFileLibrary(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
flowEnvironment.LoadLibrary(filePath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
flowEnvironment.WriteLine(Library.InfoType.ERROR, ex.ToString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void FlowEEForwardingService_OnDllLoad(Library.Api.LoadDllEventArgs eventArgs)
|
||||
{
|
||||
@@ -32,10 +51,10 @@ namespace Serein.Workbench.ViewModels
|
||||
List<MethodDetailsInfo> mds = eventArgs.MethodDetailss;
|
||||
NodeLibraryInfo libraryInfo = eventArgs.NodeLibraryInfo;
|
||||
|
||||
var methodInfo = new ObservableCollection<FlowLibraryMethodDetailsInfo>();
|
||||
var methodInfo = new ObservableCollection<MethodDetailsInfo>();
|
||||
foreach (var md in mds)
|
||||
{
|
||||
methodInfo.Add(new FlowLibraryMethodDetailsInfo(md));
|
||||
methodInfo.Add(md);
|
||||
}
|
||||
var flInfo = new FlowLibraryInfo
|
||||
{
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Serein.Library.Api;
|
||||
using Serein.NodeFlow.Env;
|
||||
using Serein.Workbench.Api;
|
||||
using Serein.Workbench.Models;
|
||||
using Serein.Workbench.Services;
|
||||
@@ -8,19 +10,36 @@ using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Serein.Workbench.ViewModels
|
||||
{
|
||||
internal partial class FlowWorkbenchViewModel : ObservableObject
|
||||
{
|
||||
private readonly IFlowEEForwardingService flowEEForwardingService;
|
||||
private readonly IFlowEnvironment flowEnvironment;
|
||||
private readonly IWorkbenchEventService workbenchEventService;
|
||||
private readonly IKeyEventService keyEventService;
|
||||
|
||||
public FlowWorkbenchViewModel(IFlowEEForwardingService flowEEForwardingService, IWorkbenchEventService workbenchEventService)
|
||||
public FlowWorkbenchViewModel(IFlowEnvironment flowEnvironment,
|
||||
IWorkbenchEventService workbenchEventService,
|
||||
IKeyEventService keyEventService)
|
||||
{
|
||||
this.flowEEForwardingService = flowEEForwardingService;
|
||||
this.flowEnvironment = flowEnvironment;
|
||||
this.workbenchEventService = workbenchEventService;
|
||||
//flowEEForwardingService.OnDllLoad += FlowEEForwardingService_OnDllLoad;
|
||||
this.keyEventService = keyEventService;
|
||||
EventManager.RegisterClassHandler(typeof(Window), Keyboard.KeyDownEvent, new KeyEventHandler(OnKeyDown)); // 按下事件
|
||||
EventManager.RegisterClassHandler(typeof(Window), Keyboard.KeyUpEvent, new KeyEventHandler(OnKeyUp)); // 松开事件
|
||||
}
|
||||
private void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
keyEventService.KeyDown(e.Key);
|
||||
}
|
||||
private void OnKeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
keyEventService.KeyUp(e.Key);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Serein.Library.Api;
|
||||
using Serein.Workbench.Services;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Serein.Workbench.ViewModels
|
||||
@@ -8,6 +9,7 @@ namespace Serein.Workbench.ViewModels
|
||||
public class MainMenuBarViewModel : ObservableObject
|
||||
{
|
||||
private readonly IFlowEnvironment environment;
|
||||
private readonly FlowNodeService flowNodeService;
|
||||
|
||||
/// <summary>
|
||||
/// 保存项目
|
||||
@@ -31,6 +33,10 @@ namespace Serein.Workbench.ViewModels
|
||||
/// </summary>
|
||||
public ICommand RemoteFlowCanvasCommand { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 运行当前画布流程
|
||||
/// </summary>
|
||||
public ICommand StartFlowCommand { get; private set; }
|
||||
/// <summary>
|
||||
/// 运行当前画布流程
|
||||
/// </summary>
|
||||
@@ -55,10 +61,10 @@ namespace Serein.Workbench.ViewModels
|
||||
|
||||
|
||||
|
||||
public MainMenuBarViewModel(IFlowEnvironment environment)
|
||||
public MainMenuBarViewModel(IFlowEnvironment environment, FlowNodeService flowNodeService)
|
||||
{
|
||||
this.environment = environment;
|
||||
|
||||
this.flowNodeService = flowNodeService;
|
||||
SaveProjectCommand = new RelayCommand(SaveProject); // 保存项目
|
||||
LoadLocalProjectCommand = new RelayCommand(LoadLocalProject); // 加载本地项目
|
||||
LoadRemoteProjectCommand = new RelayCommand(LoadRemoteProject); // 加载远程项目
|
||||
@@ -66,26 +72,30 @@ namespace Serein.Workbench.ViewModels
|
||||
CreateFlowCanvasCommand = new RelayCommand(CreateFlowCanvas); // 增加画布
|
||||
RemoteFlowCanvasCommand = new RelayCommand(RemoteFlowCanvas); // 移除画布
|
||||
|
||||
StartCurrentCanvasFlowCommand = new RelayCommand(StartCurrentCanvasFlow); // 运行当前流程
|
||||
StartFlowCommand = new RelayCommand(StartFlow);
|
||||
StartCurrentCanvasFlowCommand = new RelayCommand(StartCurrentCanvasFlow); // 运行当前所查看画布的流程
|
||||
StopCurrentCanvasFlowCommand = new RelayCommand(StopCurrentCanvasFlow); // 停止当前流程
|
||||
|
||||
OpenEnvOutWindowCommand = new RelayCommand(OpenEnvOutWindow); // 打开运行输出窗口
|
||||
OpenDynamicCompilerCommand = new RelayCommand(OpenDynamicCompiler); // 打开动态编译仓库窗口
|
||||
}
|
||||
|
||||
private void SaveProject() {
|
||||
environment.SaveProject(); // 保存项目
|
||||
}
|
||||
private void SaveProject() => environment.SaveProject(); // 保存项目
|
||||
private void LoadLocalProject() {
|
||||
//environment.LoadProject(); // 加载项目
|
||||
}
|
||||
private void LoadRemoteProject() { }
|
||||
private void CreateFlowCanvas() { }
|
||||
private void RemoteFlowCanvas() { }
|
||||
private void StartCurrentCanvasFlow() { }
|
||||
private void LoadRemoteProject()
|
||||
{
|
||||
}
|
||||
private void CreateFlowCanvas() => flowNodeService.CreateFlowCanvas();
|
||||
|
||||
private void RemoteFlowCanvas() => flowNodeService.RemoveFlowCanvas();
|
||||
|
||||
private void StartFlow() => environment.StartFlowAsync([.. flowNodeService.FlowCanvass.Select(c => c.Guid)]);
|
||||
private void StartCurrentCanvasFlow() => environment.StartFlowAsync([flowNodeService.CurrentSelectCanvas.Guid]);
|
||||
private void StopCurrentCanvasFlow() { }
|
||||
private void OpenDynamicCompiler() { }
|
||||
private void OpenEnvOutWindow() { }
|
||||
private void OpenEnvOutWindow() => LogWindow.Instance?.Show();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Serein.Workbench.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using System.Windows;
|
||||
|
||||
namespace Serein.Workbench.ViewModels
|
||||
{
|
||||
public class MainViewModel : ObservableObject
|
||||
{
|
||||
public MainViewModel()
|
||||
private readonly IKeyEventService keyEventService;
|
||||
|
||||
public MainViewModel(IKeyEventService keyEventService)
|
||||
{
|
||||
|
||||
this.keyEventService = keyEventService;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user