Files
serein-flow/Net461DllTest/View/FromWorkBenchView.cs

63 lines
1.7 KiB
C#
Raw Normal View History

2024-09-27 10:30:19 +08:00
using Net461DllTest.Device;
using Net461DllTest.Signal;
using Net461DllTest.ViewModel;
using Serein.Library.Api;
2024-09-27 10:30:19 +08:00
using Serein.Library.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Net461DllTest
{
public partial class FromWorkBenchView : Form
{
private FromWorkBenchViewModel ViewModel;
public FromWorkBenchView(IFlowEnvironment env)
2024-09-27 10:30:19 +08:00
{
2024-09-30 16:36:55 +08:00
ViewModel = env.IOC.Instantiate<FromWorkBenchViewModel>(); // 创建对象并注入依赖项
2024-09-27 10:30:19 +08:00
InitializeComponent();
Init();
}
public void Init()
{
2024-09-27 10:30:19 +08:00
listBox1.Items.Clear();
2024-09-30 16:36:55 +08:00
var enumValues = Enum.GetValues(typeof(CommandSignal)).Cast<CommandSignal>();
2024-09-27 10:30:19 +08:00
foreach (var value in enumValues)
{
listBox1.Items.Add(value.ToString());
}
}
private void button1_Click(object sender, EventArgs e)
{
2024-09-28 23:55:19 +08:00
textBoxPlcInfo.Text = ViewModel.GetDeviceInfo();
2024-09-27 10:30:19 +08:00
}
private void button2_Click(object sender, EventArgs e)
{
2024-09-28 23:55:19 +08:00
if(listBox1.SelectedItem is null)
{
return;
}
2024-09-27 10:30:19 +08:00
string type = listBox1.SelectedItem.ToString();
2024-09-30 16:36:55 +08:00
if (!string.IsNullOrEmpty(type) && Enum.TryParse(type, out CommandSignal signal) && Enum.IsDefined(typeof(CommandSignal), signal))
2024-09-27 10:30:19 +08:00
{
Console.WriteLine($"Trigger : {type}");
2024-09-28 23:55:19 +08:00
ViewModel.Trigger(signal,textBoxSpaceNum.Text);
2024-09-27 10:30:19 +08:00
}
}
}
}