|
|
|
|
|
using CompressorXN_Log;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
|
|
namespace CompressorXN_ControlLib
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class MyResultControl : UserControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public MyResultControl()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
|
|
|
|
|
this.SetStyle(ControlStyles.DoubleBuffer, true);
|
|
|
|
|
|
this.SetStyle(ControlStyles.ResizeRedraw, true);
|
|
|
|
|
|
this.SetStyle(ControlStyles.Selectable, true);
|
|
|
|
|
|
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 异步更新控件内容
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="control"></param>
|
|
|
|
|
|
/// <param name="content"></param>
|
|
|
|
|
|
private void UpdateControlContent(Control control, string content)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (control.InvokeRequired)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Invoke(new Action(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!control.IsHandleCreated || control.IsDisposed || control.Disposing)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
control.Text = content;
|
|
|
|
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
LogHelper.Error(ex, $"异步更新控件内容失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
control.Text = content;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 自定义属性
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 参数名称
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Category("自定义属性"), Description("参数名称")]
|
|
|
|
|
|
public string LblItemText
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return lblItemDesc.Text; }
|
|
|
|
|
|
set { lblItemDesc.Text = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 采集值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private string _testValText = "";
|
|
|
|
|
|
[Category("自定义属性"), Description("采集值")]
|
|
|
|
|
|
public string TestValText
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return txtTestVal.Text; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
_testValText = value;
|
|
|
|
|
|
UpdateControlContent(txtTestVal, _testValText);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 采集值控件背景颜色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Color _testResultBackColor = Color.Gainsboro;
|
|
|
|
|
|
[Category("自定义属性"), Description("采集值控件背景颜色")]
|
|
|
|
|
|
public Color TestResultBackColor
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return txtTestVal.BackColor; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
_testResultBackColor = value;
|
|
|
|
|
|
txtTestVal.BackColor=_testResultBackColor;
|
|
|
|
|
|
txtTestVal.Properties.AppearanceDisabled.BackColor = _testResultBackColor;
|
|
|
|
|
|
Color fontColor= _testResultBackColor==Color.Red || _testResultBackColor==Color.Green?Color.White:Color.Black;
|
|
|
|
|
|
txtTestVal.Properties.AppearanceDisabled.ForeColor= fontColor;
|
|
|
|
|
|
txtTestVal.Properties.Appearance.ForeColor = fontColor;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 采集值PLC点位编码
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Category("自定义属性"), Description("采集值PLC点位编码")]
|
|
|
|
|
|
public string TestValPLCPointCode
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return txtTestVal.Tag?.ToString(); }
|
|
|
|
|
|
set { txtTestVal.Tag = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 采集结果PLC点位编码
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Category("自定义属性"), Description("采集结果PLC点位编码")]
|
|
|
|
|
|
public string TestResultPLCPointCode
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return lblItemDesc.Tag?.ToString(); }
|
|
|
|
|
|
set { lblItemDesc.Tag = value; }
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|