Files

71 lines
1.8 KiB
C#
Raw Permalink Normal View History

2024-10-07 15:15:18 +08:00

using Net462DllTest.Signal;
using Net462DllTest.Trigger;
using Serein.Library;
2024-09-27 10:30:19 +08:00
using Serein.Library.Api;
using Serein.Library.Utils;
using System;
2024-10-07 15:15:18 +08:00
using System.Threading.Tasks;
2024-09-27 10:30:19 +08:00
using System.Windows.Forms;
2024-10-07 15:15:18 +08:00
namespace Net462DllTest.LogicControl
{
2024-09-30 16:36:55 +08:00
2024-09-27 10:30:19 +08:00
[AutoRegister]
2024-10-07 15:15:18 +08:00
[DynamicFlow("[View]")]
2024-09-27 10:30:19 +08:00
public class ViewLogicControl
{
private readonly ViewManagement ViewManagement;
public ViewLogicControl(ViewManagement ViewManagement)
{
this.ViewManagement = ViewManagement;
}
2024-09-27 10:30:19 +08:00
2024-10-07 15:15:18 +08:00
#region
2024-09-27 10:30:19 +08:00
2024-10-11 16:46:16 +08:00
[NodeAction(NodeType.Flipflop, "等待视图命令")]
public async Task<IFlipflopContext<int>> WaitTask(CommandSignal command)
2024-10-07 15:15:18 +08:00
{
var result = await ViewManagement.WaitTriggerWithTimeoutAsync<int>(command, TimeSpan.FromHours(10));
if (result.Type == TriggerDescription.Overtime)
2024-10-07 15:15:18 +08:00
{
return new FlipflopContext<int>(FlipflopStateType.Cancel, result.Value);
2024-10-07 15:15:18 +08:00
}
2024-10-11 16:46:16 +08:00
else
2024-10-07 15:15:18 +08:00
{
return new FlipflopContext<int>(FlipflopStateType.Succeed, result.Value);
2024-10-07 15:15:18 +08:00
}
}
#endregion
2024-10-11 19:31:34 +08:00
[NodeAction(NodeType.Action, "打开窗体(转换器)")]
2024-09-28 23:55:19 +08:00
public void OpenForm2([EnumTypeConvertor(typeof(FromValue))] Form form, bool isTop = true)
2024-09-27 10:30:19 +08:00
{
// 枚举转换为对应的Type并自动实例化
ViewManagement.OpenView(form, isTop);
2024-09-27 10:30:19 +08:00
}
2024-09-28 23:55:19 +08:00
[NodeAction(NodeType.Action, "关闭指定类型的所有窗体")]
2024-10-07 15:15:18 +08:00
public void CloseForm(IDynamicContext context, FromValue fromId = FromValue.FromWorkBenchView)
2024-09-27 10:30:19 +08:00
{
2024-09-28 23:55:19 +08:00
var fromType = EnumHelper.GetBoundValue<FromValue, Type>(fromId, attr => attr.Value);
2024-09-27 10:30:19 +08:00
if (fromType is null) return;
ViewManagement.CloseView(fromType);
}
2024-09-28 23:55:19 +08:00
2024-09-27 10:30:19 +08:00
}
}