using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Controls.ChemicalWeighing
{
///
/// 榄菊的开关阀门
///
public partial class LjSwith : ChemicalWeighingControl
{
private object lockobj = new object();
private string[] sImages = new String[3];
private bool _alarm;
private bool _set;
public LjSwith()
{
InitializeComponent();
InitControl();
}
private void InitControl()
{
_assembly = Assembly.GetExecutingAssembly();
sImages[2] = "Mesnac.Controls.ChemicalWeighing.Resources.switch_failure.png";
sImages[1] = "Mesnac.Controls.ChemicalWeighing.Resources.switch_ok.png";
sImages[0] = "Mesnac.Controls.ChemicalWeighing.Resources.swith_default.png";
}
private void R()
{
lock (lockobj)
{
ReloadStream();
Reload();
}
}
private void ReloadStream()
{
int defaultIndex;
//如果报警就现实红色
if (_alarm)
{
defaultIndex = 2;
}
else
{
defaultIndex = _set ? 1 : 0;
}
_imageStream = _assembly.GetManifestResourceStream(sImages[defaultIndex]);
}
private void Reload()
{
if ( _imageStream != null )
{
Image img = Image.FromStream( _imageStream);
pictureBox1.Image = img;
pictureBox1.Refresh();
}
}
///
/// 故障名称
///
public string AlarmName { get; set; }
///
/// 是不是通到位
///
public string SetName { get; set; }
public bool Alarm
{
get => _alarm;
set
{
_alarm = value;
R();
}
}
public bool Set
{
get => _set;
set
{
_set = value;
R();
}
}
}
}