Files
serein-flow/Net462DllTest/View/FromWorkBenchView.cs
2025-06-22 21:53:37 +08:00

60 lines
2.0 KiB
C#

using Net462DllTest.Signal;
using Net462DllTest.ViewModel;
using Serein.Library;
using Serein.Library.Api;
using Serein.Library.Utils;
using System;
using System.Windows.Forms;
namespace Net462DllTest
{
public partial class FromWorkBenchView : Form
{
private FromWorkBenchViewModel ViewModel;
public FromWorkBenchView(IFlowEnvironment env)
{
InitializeComponent();
ViewModel = env.IOC.Get<FromWorkBenchViewModel>();
if (ViewModel is null)
{
SereinEnv.WriteLine(InfoType.INFO, "创建对象并注入依赖项");
ViewModel = env.IOC.CreateObject<FromWorkBenchViewModel>();
}
BindData();
}
private void BindData()
{
textBoxPlcInfo.DataBindings.Add(nameof(textBoxPlcInfo.Text), ViewModel, nameof(ViewModel.DeviceInfo), false, DataSourceUpdateMode.OnPropertyChanged);
textBoxSpaceNum.DataBindings.Add(nameof(textBoxSpaceNum.Text), ViewModel, nameof(ViewModel.SpcaeNumber), false, DataSourceUpdateMode.OnPropertyChanged);
listBoxCommand.DataSource = Enum.GetValues(typeof(CommandSignal));
listBoxCommand.DataBindings.Add(nameof(listBoxCommand.SelectedItem), ViewModel, nameof(ViewModel.SelectedSignal), false, DataSourceUpdateMode.OnPropertyChanged);
listBoxCommand.SelectedIndexChanged += (s, e) => listBoxCommand.DataBindings[nameof(listBoxCommand.SelectedItem)].WriteValue();
}
private void FromWorkBenchView_Load(object sender, EventArgs e)
{
}
private void FromWorkBenchView_FormClosing(object sender, FormClosingEventArgs e)
{
ViewModel.CommandCloseForm.Execute();
}
private void button2_Click(object sender, EventArgs e)
{
ViewModel.CommandGetParkingSpace.Execute();
}
private void button1_Click(object sender, EventArgs e)
{
ViewModel.CommandViewPlcInfo.Execute();
}
}
}