You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/Controls/Mesnac.Controls.ChemicalWei.../SwithHostLight.cs

91 lines
2.1 KiB
C#

using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
namespace Mesnac.Controls.ChemicalWeighing
{
[ToolboxBitmap(typeof(SwithHostLight), "Resources.AlarmLight.bmp")]//新添加的代码
public partial class SwithHostLight : ChemicalWeighingControl
{
private string[] sImages = new string[3];
private bool _m;
private bool _t;
private bool _s;
public SwithHostLight()
{
InitializeComponent();
_assembly = Assembly.GetExecutingAssembly();
sImages[0] = "Mesnac.Controls.ChemicalWeighing.Resources.AlarmLightNewGray.png";//
sImages[1] = "Mesnac.Controls.ChemicalWeighing.Resources.AlarmLightNewGreen.png";//
}
/// <summary>
/// 电机Runing 3种状态
/// </summary>
public string MName { get; set; }
public string TName { get; set; }
public string SName { get; set; }
public bool M
{
get => _m;
set
{
_m = value;
R();
}
}
public bool T
{
get => _t;
set
{
_t = value;
R();
}
}
public bool S
{
get => _s;
set
{
_s = value;
R();
}
}
private void Reload()
{
if ( _imageStream != null )
{
Image img = Image.FromStream( _imageStream);
pictureBox1.Image = img;
pictureBox1.Refresh();
}
}
private void ReloadStream()
{
int defaultIndex = 0;
//如果出现报警 就去判断是直还是斜
if (M && (S || T))
{
defaultIndex = 1;
}
_imageStream = _assembly.GetManifestResourceStream(sImages[defaultIndex]);
}
private void R()
{
ReloadStream();
Reload();
}
}
}