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.
118 lines
2.6 KiB
C#
118 lines
2.6 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// 榄菊的开关阀门
|
|
/// </summary>
|
|
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();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 故障名称
|
|
/// </summary>
|
|
public string AlarmName { get; set; }
|
|
|
|
/// <summary>
|
|
/// 是不是通到位
|
|
/// </summary>
|
|
public string SetName { get; set; }
|
|
|
|
|
|
public bool Alarm
|
|
{
|
|
get => _alarm;
|
|
set
|
|
{
|
|
|
|
|
|
_alarm = value;
|
|
R();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public bool Set
|
|
{
|
|
get => _set;
|
|
set
|
|
{
|
|
|
|
_set = value;
|
|
R();
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|