mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-07 02:00:47 +08:00
重构了底层,方便向Android、Web、Linux进行跨平台迁移
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using Serein.Library.Entity;
|
||||
using Serein.NodeFlow;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
|
||||
@@ -115,8 +117,10 @@ namespace Serein.WorkBench
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static SereinOutputFileData? FData;
|
||||
/// <summary>
|
||||
/// 成功加载的工程文件
|
||||
/// </summary>
|
||||
public static SereinOutputFileData? FData { get; set; }
|
||||
public static string FileDataPath = "";
|
||||
private void Application_Startup(object sender, StartupEventArgs e)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
xmlns:custom="clr-namespace:Serein.WorkBench.Node.View"
|
||||
Title="Dynamic Node Flow" Height="700" Width="1200"
|
||||
AllowDrop="True" Drop="Window_Drop" DragOver="Window_DragOver"
|
||||
SizeChanged ="Window_SizeChanged"
|
||||
Loaded="Window_Loaded"
|
||||
Closing="Window_Closing">
|
||||
|
||||
@@ -55,9 +54,9 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>-->
|
||||
|
||||
<custom:ExpOpNodeControl x:Name="ExpOpNodeControl" Margin="10" AllowDrop="True" Drop="ConditionRegionControl_Drop" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<custom:ConditionNodeControl x:Name="ConditionNodeControl" Margin="10" AllowDrop="True" Drop="ConditionNodeControl_Drop" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<custom:ConditionRegionControl x:Name="ConditionRegionControl" Margin="10" AllowDrop="True" Drop="ConditionRegionControl_Drop" PreviewMouseMove="RegionControl_PreviewMouseMove"/>
|
||||
<custom:ExpOpNodeControl x:Name="ExpOpNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<custom:ConditionNodeControl x:Name="ConditionNodeControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<custom:ConditionRegionControl x:Name="ConditionRegionControl" Margin="10" AllowDrop="True" PreviewMouseMove="BaseNodeControl_PreviewMouseMove"/>
|
||||
<!--<custom:ActionRegionControl x:Name="ActionRegionControl" Grid.Column="1" Margin="10" AllowDrop="True" Drop="ActionRegionControl_Drop" PreviewMouseMove="RegionControl_PreviewMouseMove"/>-->
|
||||
<!--<TextBlock Text="触发器" Grid.Column="2"/>-->
|
||||
<!--<custom:StateRegionControl x:Name="StateRegionControl" Grid.Column="2" Margin="10" AllowDrop="True" Drop="StateRegionControl_Drop" PreviewMouseMove="RegionControl_PreviewMouseMove"/>-->
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
81
WorkBench/MainWindowViewModel.cs
Normal file
81
WorkBench/MainWindowViewModel.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using Serein.Library.Attributes;
|
||||
using Serein.Library.Entity;
|
||||
using Serein.Library.Utils;
|
||||
using Serein.NodeFlow;
|
||||
using Serein.NodeFlow.Tool;
|
||||
using Serein.WorkBench.Node.View;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Serein.WorkBench
|
||||
{
|
||||
public class MainWindowViewModel
|
||||
{
|
||||
private readonly MainWindow window ;
|
||||
public MainWindowViewModel(MainWindow window)
|
||||
{
|
||||
FlowEnvironment = new FlowEnvironment();
|
||||
this.window = window;
|
||||
}
|
||||
|
||||
public FlowEnvironment FlowEnvironment { get; set; }
|
||||
|
||||
|
||||
#region 加载项目文件
|
||||
public void LoadProjectFile(SereinOutputFileData projectFile)
|
||||
{
|
||||
var dllPaths = projectFile.Librarys.Select(it => it.Path).ToList();
|
||||
foreach (var dll in dllPaths)
|
||||
{
|
||||
var filePath = System.IO.Path.GetFullPath(System.IO.Path.Combine(App.FileDataPath, dll));
|
||||
//LoadAssembly(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void DisplayControlDll(Assembly assembly,
|
||||
List<MethodDetails> conditionTypes,
|
||||
List<MethodDetails> actionTypes,
|
||||
List<MethodDetails> flipflopMethods)
|
||||
{
|
||||
|
||||
var dllControl = new DllControl
|
||||
{
|
||||
Header = "DLL name : " + assembly.GetName().Name // 设置控件标题为程序集名称
|
||||
};
|
||||
|
||||
|
||||
foreach (var item in actionTypes)
|
||||
{
|
||||
dllControl.AddAction(item.Clone()); // 添加动作类型到控件
|
||||
}
|
||||
foreach (var item in flipflopMethods)
|
||||
{
|
||||
dllControl.AddFlipflop(item.Clone()); // 添加触发器方法到控件
|
||||
}
|
||||
|
||||
/*foreach (var item in stateTypes)
|
||||
{
|
||||
dllControl.AddState(item);
|
||||
}*/
|
||||
|
||||
window.DllStackPanel.Children.Add(dllControl); // 将控件添加到界面上显示
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Serein.NodeFlow.Model;
|
||||
using Serein.NodeFlow;
|
||||
using Serein.NodeFlow.Model;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
@@ -107,8 +108,19 @@ namespace Serein.WorkBench.Node.View
|
||||
{
|
||||
if (sender is TextBlock typeText)
|
||||
{
|
||||
var dragData = new DataObject(MouseNodeType.RegionType, typeText.Tag);
|
||||
MoveNodeData moveNodeData = new MoveNodeData
|
||||
{
|
||||
NodeControlType = Library.Enums.NodeControlType.ConditionRegion
|
||||
};
|
||||
|
||||
// 创建一个 DataObject 用于拖拽操作,并设置拖拽效果
|
||||
DataObject dragData = new DataObject(MouseNodeType.CreateDllNodeInCanvas, moveNodeData);
|
||||
|
||||
DragDrop.DoDragDrop(typeText, dragData, DragDropEffects.Move);
|
||||
|
||||
|
||||
//var dragData = new DataObject(MouseNodeType.CreateNodeInCanvas, typeText.Tag);
|
||||
//DragDrop.DoDragDrop(typeText, dragData, DragDropEffects.Move);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
using Serein.NodeFlow;
|
||||
using Serein.Library.Entity;
|
||||
using Serein.Library.Enums;
|
||||
using Serein.NodeFlow;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
@@ -115,12 +118,26 @@ namespace Serein.WorkBench.Node.View
|
||||
{
|
||||
// 获取触发事件的 TextBlock
|
||||
|
||||
TextBlock typeText = sender as TextBlock;
|
||||
|
||||
if (typeText != null)
|
||||
if (sender is TextBlock typeText && typeText.Tag is MethodDetails md)
|
||||
{
|
||||
MoveNodeData moveNodeData = new MoveNodeData
|
||||
{
|
||||
NodeControlType = md.MethodDynamicType switch
|
||||
{
|
||||
NodeType.Action => NodeControlType.Action,
|
||||
NodeType.Flipflop => NodeControlType.Flipflop,
|
||||
_ => NodeControlType.None,
|
||||
},
|
||||
MethodDetails = md,
|
||||
};
|
||||
if(moveNodeData.NodeControlType == NodeControlType.None)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建一个 DataObject 用于拖拽操作,并设置拖拽效果
|
||||
DataObject dragData = new DataObject(MouseNodeType.DllNodeType, typeText.Tag);
|
||||
DataObject dragData = new DataObject(MouseNodeType.CreateDllNodeInCanvas, moveNodeData);
|
||||
DragDrop.DoDragDrop(typeText, dragData, DragDropEffects.Move);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Serein.NodeFlow;
|
||||
using Serein.NodeFlow.Model;
|
||||
using Serein.Library.Api;
|
||||
using Serein.Library.Entity;
|
||||
using Serein.NodeFlow.Base;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
@@ -34,7 +35,7 @@ namespace Serein.WorkBench.Node.View
|
||||
|
||||
public abstract class NodeControlViewModelBase : INotifyPropertyChanged
|
||||
{
|
||||
public NodeControlViewModelBase(NodeBase node)
|
||||
public NodeControlViewModelBase(NodeModelBase node)
|
||||
{
|
||||
this.Node = node;
|
||||
MethodDetails = this.Node.MethodDetails;
|
||||
@@ -43,7 +44,7 @@ namespace Serein.WorkBench.Node.View
|
||||
/// <summary>
|
||||
/// 对应的节点实体类
|
||||
/// </summary>
|
||||
public NodeBase Node { get; set; }
|
||||
public NodeModelBase Node { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 表示节点控件是否被选中
|
||||
@@ -63,13 +64,7 @@ namespace Serein.WorkBench.Node.View
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
|
||||
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
|
||||
{
|
||||
|
||||
@@ -1,183 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.WorkBench
|
||||
{
|
||||
|
||||
public class SereinOutputFileData
|
||||
{
|
||||
/// <summary>
|
||||
/// 基础
|
||||
/// </summary>
|
||||
|
||||
public Basic basic { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的DLL
|
||||
/// </summary>
|
||||
|
||||
public Library[] library { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 起始节点GUID
|
||||
/// </summary>
|
||||
|
||||
public string startNode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 节点信息集合
|
||||
/// </summary>
|
||||
|
||||
public NodeInfo[] nodes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 区域集合
|
||||
/// </summary>
|
||||
|
||||
public Region[] regions { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 基础
|
||||
/// </summary>
|
||||
public class Basic
|
||||
{
|
||||
/// <summary>
|
||||
/// 画布
|
||||
/// </summary>
|
||||
|
||||
public FlowCanvas canvas { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 版本
|
||||
/// </summary>
|
||||
|
||||
public string versions { get; set; }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 画布
|
||||
/// </summary>
|
||||
public class FlowCanvas
|
||||
{
|
||||
/// <summary>
|
||||
/// 宽度
|
||||
/// </summary>
|
||||
public float width { get; set; }
|
||||
/// <summary>
|
||||
/// 高度
|
||||
/// </summary>
|
||||
public float lenght { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DLL
|
||||
/// </summary>
|
||||
public class Library
|
||||
{
|
||||
/// <summary>
|
||||
/// DLL名称
|
||||
/// </summary>
|
||||
|
||||
public string name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 路径
|
||||
/// </summary>
|
||||
|
||||
public string path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 提示
|
||||
/// </summary>
|
||||
|
||||
public string tips { get; set; }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 节点
|
||||
/// </summary>
|
||||
public class NodeInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// GUID
|
||||
/// </summary>
|
||||
|
||||
public string guid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
|
||||
public string name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 显示标签
|
||||
/// </summary>
|
||||
|
||||
public string label { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类型
|
||||
/// </summary>
|
||||
|
||||
public string type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 于画布中的位置
|
||||
/// </summary>
|
||||
|
||||
public Position position { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 真分支节点GUID
|
||||
/// </summary>
|
||||
|
||||
public string[] trueNodes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 假分支节点
|
||||
/// </summary>
|
||||
|
||||
public string[] falseNodes { get; set; }
|
||||
public string[] upstreamNodes { get; set; }
|
||||
|
||||
|
||||
|
||||
public Parameterdata[] parameterData { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class Parameterdata
|
||||
{
|
||||
public bool state { get; set; }
|
||||
public string value { get; set; }
|
||||
public string expression { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 节点于画布中的位置
|
||||
/// </summary>
|
||||
public class Position
|
||||
{
|
||||
public float x { get; set; }
|
||||
public float y { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 区域
|
||||
/// </summary>
|
||||
public class Region
|
||||
{
|
||||
public string guid { get; set; }
|
||||
public NodeInfo[] childNodes { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Serein.NodeFlow;
|
||||
using Serein.Library.Entity;
|
||||
using Serein.NodeFlow;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
|
||||
Reference in New Issue
Block a user