mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-04 15:26:34 +08:00
添加Avalonia项目的demo
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia;
|
||||
using Serein.Library;
|
||||
using Serein.Workbench.Avalonia.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive.Subjects;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Input;
|
||||
using System.Windows.Input;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Collections;
|
||||
using System.Collections;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Serein.Workbench.Avalonia.Custom.ViewModels
|
||||
{
|
||||
|
||||
internal partial class FlowLibraryInfoViewModel:ViewModelBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 依赖名称
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
public string _libraryName;
|
||||
|
||||
private ObservableCollection<MethodDetailsInfo> activateMethods;
|
||||
private ObservableCollection<MethodDetailsInfo> flipflopMethods;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 动作节点
|
||||
/// </summary>
|
||||
public ObservableCollection<MethodDetailsInfo> ActivateMethods { get => activateMethods; set => SetProperty(ref activateMethods,value); }
|
||||
|
||||
/// <summary>
|
||||
/// 触发器节点
|
||||
/// </summary>
|
||||
public ObservableCollection<MethodDetailsInfo> FlipflopMethods { get => flipflopMethods; set => SetProperty(ref activateMethods, value); }
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 加载项目信息
|
||||
///// </summary>
|
||||
///// <param name="libraryMds"></param>
|
||||
//public void LoadLibraryInfo(LibraryMds libraryMds)
|
||||
//{
|
||||
// this.AssemblyName = libraryMds.AssemblyName;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Serein.Library;
|
||||
using Serein.Workbench.Avalonia.Services;
|
||||
using Serein.Workbench.Avalonia.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Workbench.Avalonia.Custom.ViewModels
|
||||
{
|
||||
|
||||
internal partial class FlowLibraryMethodInfoViewModel : ViewModelBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前预览的方法信息
|
||||
/// </summary>
|
||||
|
||||
[ObservableProperty]
|
||||
private MethodDetailsInfo methodDetailsInfo;
|
||||
|
||||
|
||||
private IWorkbenchEventService workbenchEventService;
|
||||
|
||||
public FlowLibraryMethodInfoViewModel()
|
||||
{
|
||||
workbenchEventService = App.GetService<IWorkbenchEventService>();
|
||||
workbenchEventService.OnPreviewlMethodInfo += WorkbenchEventService_OnPreviewlMethodInfo;
|
||||
methodDetailsInfo = new MethodDetailsInfo
|
||||
{
|
||||
AssemblyName = "wait selection...",
|
||||
MethodAnotherName = "wait selection...",
|
||||
MethodName = "wait selection...",
|
||||
NodeType = "wait selection...",
|
||||
ReturnTypeFullName = "wait selection...",
|
||||
IsParamsArgIndex = -1,
|
||||
ParameterDetailsInfos = []
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private void WorkbenchEventService_OnPreviewlMethodInfo(PreviewlMethodInfoEventArgs eventArgs)
|
||||
{
|
||||
var mdInfo = eventArgs.MethodDetailsInfo;
|
||||
MethodDetailsInfo = mdInfo;
|
||||
Debug.WriteLine($"预览了 {mdInfo.AssemblyName } - {mdInfo.MethodAnotherName} 方法");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using Newtonsoft.Json;
|
||||
using Serein.Library;
|
||||
using Serein.Library.Api;
|
||||
using Serein.Workbench.Avalonia.Api;
|
||||
using Serein.Workbench.Avalonia.Services;
|
||||
using Serein.Workbench.Avalonia.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Tracing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Workbench.Avalonia.Custom.ViewModels
|
||||
{
|
||||
internal partial class FlowLibrarysViewModel : ViewModelBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 运行环境
|
||||
/// </summary>
|
||||
private IFlowEnvironment flowEnvironment { get; }
|
||||
/// <summary>
|
||||
/// 流程运行环境事件服务
|
||||
/// </summary>
|
||||
private IFlowEEForwardingService feefService { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 运行环境加载的依赖
|
||||
/// </summary>
|
||||
public ObservableCollection<LibraryMds> LibraryList { get; } = new ObservableCollection<LibraryMds>();
|
||||
|
||||
|
||||
|
||||
public FlowLibrarysViewModel()
|
||||
{
|
||||
flowEnvironment = App.GetService<IFlowEnvironment>();
|
||||
feefService = App.GetService<IFlowEEForwardingService>();
|
||||
feefService.OnDllLoad += FeefService_OnDllLoad; ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载了依赖信息
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
private void FeefService_OnDllLoad(LoadDllEventArgs e)
|
||||
{
|
||||
Debug.WriteLine(e.NodeLibraryInfo.AssemblyName + " count :" + e.MethodDetailss.Count);
|
||||
var libraryMds = new LibraryMds { AssemblyName = e.NodeLibraryInfo.AssemblyName, Mds = e.MethodDetailss.ToArray() };
|
||||
LibraryList.Add(libraryMds);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Serein.Library.Api;
|
||||
using Serein.Library.Utils;
|
||||
using Serein.Workbench.Avalonia.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Workbench.Avalonia.Custom.ViewModels
|
||||
{
|
||||
internal partial class MainMenuBarViewModel : ViewModelBase
|
||||
{
|
||||
private IFlowEnvironment flowEnvironment { get; }
|
||||
|
||||
|
||||
public MainMenuBarViewModel()
|
||||
{
|
||||
flowEnvironment = App.GetService<IFlowEnvironment>();
|
||||
|
||||
var uiContextOperation = App.GetService<UIContextOperation>();
|
||||
}
|
||||
|
||||
public void SaveProjectCommand()
|
||||
{
|
||||
flowEnvironment.SaveProject();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Avalonia.Controls;
|
||||
using Serein.Library.Api;
|
||||
using Serein.NodeFlow.Env;
|
||||
using Serein.Workbench.Avalonia.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Workbench.Avalonia.Custom.ViewModels
|
||||
{
|
||||
internal class NodeContainerViewModel : ViewModelBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 正在创建方法调用关系的连接线
|
||||
/// </summary>
|
||||
public bool IsConnectionInvokeNode { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 正在创建参数传递关系的连接线
|
||||
/// </summary>
|
||||
public bool IsConnectionArgSourceNode { get; set; } = false;
|
||||
public NodeContainerViewModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Serein.Library;
|
||||
using Serein.Workbench.Avalonia.Custom.Views;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using Serein.Workbench.Avalonia.ViewModels;
|
||||
|
||||
namespace Serein.Workbench.Avalonia.Custom.ViewModels
|
||||
{
|
||||
|
||||
|
||||
internal partial class ParameterDetailsViewModel : ViewModelBase
|
||||
{
|
||||
|
||||
public ParameterDetails ParameterDetails { get; set; }
|
||||
|
||||
public ParameterDetailsViewModel()
|
||||
{
|
||||
}
|
||||
public ParameterDetailsViewModel(ParameterDetails parameterDetails)
|
||||
{
|
||||
ParameterDetails = parameterDetails;
|
||||
RefreshIsVisible();
|
||||
|
||||
// 监视“是否为显式参数”更改
|
||||
ParameterDetails.PropertyChanged += (o, e) =>
|
||||
{
|
||||
if (nameof(ParameterDetails.IsExplicitData).Equals(e.PropertyName))
|
||||
RefreshIsVisible();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private void RefreshIsVisible()
|
||||
{
|
||||
if (!ParameterDetails.IsExplicitData)
|
||||
{
|
||||
// 并非显式设置参数
|
||||
IsVisibleA = true;
|
||||
IsVisibleB = false;
|
||||
IsVisibleC = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if ("Value".Equals(ParameterDetails.ExplicitTypeName))
|
||||
{
|
||||
// 值类型
|
||||
IsVisibleA = false;
|
||||
IsVisibleB = true;
|
||||
IsVisibleC = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 选项类型
|
||||
IsVisibleA = false;
|
||||
IsVisibleB = false;
|
||||
IsVisibleC = true;
|
||||
}
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isVisibleA;
|
||||
[ObservableProperty]
|
||||
private bool isVisibleB;
|
||||
[ObservableProperty]
|
||||
private bool isVisibleC;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user