using System.ComponentModel; using System.Drawing; using System.Windows.Forms; namespace ProductionSystem_UserControl.ExtendedControls { public partial class MyResultControl : UserControl { public MyResultControl() { InitializeComponent(); MaximumSize = new Size(93, 28); } #region 自定义属性 /// /// 参数名称 /// [Category("自定义属性"), Description("参数名称")] public string LblItemText { get { return lblItemDesc.Text; } set { lblItemDesc.Text = value; } } /// /// 采集值 /// private string _testValText = ""; [Category("自定义属性"), Description("采集值")] public string TestValText { get { return txtTestVal.Text; } set { //if (txtTestVal.Text == "停止") //{ // txtTestVal.ForeColor = Color.Red; //} //else if(txtTestVal.Text == "启动") //{ // txtTestVal.ForeColor = Color.Green; //} //else //{ // txtTestVal.ForeColor = Color.Black; //} _testValText = value; txtTestVal.Text = _testValText; } } public void SetForeColor(Color color) { this.txtTestVal.ForeColor = color; } //添加背景颜色 /// /// 采集值PLC点位编码 /// [Category("自定义属性"), Description("采集值PLC点位编码")] public string TestValPLCPointCode { get { return txtTestVal.Tag?.ToString(); } set { txtTestVal.Tag = value; } } #endregion } }