Files
6150-HMI/CowainHmi/FrmTagEdit.cs

55 lines
2.0 KiB
C#
Raw Normal View History

2026-01-15 15:06:36 +08:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace CowainHmi.UIEditor
{
public partial class FrmTagEdit : Form
{
public PlcTagColumn PlcTag { get; set; }
public FrmTagEdit(PlcTagColumn tag)
{
InitializeComponent();
PlcTag = tag;
List<KeyValuePair<string, .DatType>> enumList = Enum.GetValues(typeof(.DatType))
.Cast<.DatType>()
.Select(e => new KeyValuePair<string, .DatType>(e.ToString(), e))
.ToList();
// 绑定数据源
cbxType.DisplayMember = "Key"; // 显示枚举的名称
cbxType.ValueMember = "Value"; // 存储枚举的值
cbxType.DataSource = enumList;
this.udPLC.Value = tag.PLC;
this.txtAddress.Text = tag.Address;
this.cbxType.SelectedValue = tag.DatType;
this.udDecimalPlaces.Value = tag.DecimalPlaces;
this.udStringLength.Value = tag.StringLength;
this.txtVarName.Text = tag.VarName;
this.txtVarDesc.Text = tag.VarDesc;
}
private void btnOk_Click(object sender, EventArgs e)
{
PlcTag = new PlcTagColumn()
{
PLC = (int)this.udPLC.Value,
Address = this.txtAddress.Text,
DecimalPlaces = (int)this.udDecimalPlaces.Value,
StringLength = (int)this.udStringLength.Value,
DatType = (.DatType)this.cbxType.SelectedValue,
VarName = this.txtVarName.Text,
VarDesc = this.txtVarDesc.Text,
};
this.DialogResult = DialogResult.OK;
}
}
}