2024-09-16 21:38:34 +08:00
|
|
|
|
using Serein.Library.Api;
|
2024-09-15 12:15:32 +08:00
|
|
|
|
using Serein.Library.Utils;
|
2024-10-20 12:10:57 +08:00
|
|
|
|
using Serein.NodeFlow.Env;
|
2024-09-15 12:15:32 +08:00
|
|
|
|
using System.Windows;
|
|
|
|
|
|
|
2024-10-15 21:56:09 +08:00
|
|
|
|
namespace Serein.Workbench
|
2024-09-15 12:15:32 +08:00
|
|
|
|
{
|
2024-10-15 21:56:09 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 工作台数据视图
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="window"></param>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
public class MainWindowViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly MainWindow window ;
|
2024-10-15 21:56:09 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 运行环境
|
|
|
|
|
|
/// </summary>
|
2024-09-16 21:38:34 +08:00
|
|
|
|
public IFlowEnvironment FlowEnvironment { get; set; }
|
2024-10-15 21:56:09 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 工作台数据视图
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="window"></param>
|
2024-09-15 12:15:32 +08:00
|
|
|
|
public MainWindowViewModel(MainWindow window)
|
|
|
|
|
|
{
|
2024-10-20 12:10:57 +08:00
|
|
|
|
UIContextOperation? uIContextOperation = null;
|
|
|
|
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
SynchronizationContext? uiContext = SynchronizationContext.Current; // 在UI线程上获取UI线程上下文信息
|
|
|
|
|
|
if (uiContext != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
uIContextOperation = new UIContextOperation(uiContext); // 封装一个调用UI线程的工具类
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (uIContextOperation is null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("无法封装 UIContextOperation ");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
FlowEnvironment = new FlowEnvironmentDecorator(uIContextOperation);
|
2024-10-22 00:13:13 +08:00
|
|
|
|
//_ = FlowEnvironment.StartRemoteServerAsync();
|
2024-10-20 12:10:57 +08:00
|
|
|
|
this.window = window;
|
|
|
|
|
|
}
|
2024-09-15 12:15:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|