|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Controls.ChemicalWeighing
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
[ToolboxBitmap(typeof(ControlCabinet), "Resources.controlCabinet.png")]
|
|
|
|
|
public partial class ControlCabinet : ChemicalWeighingControl
|
|
|
|
|
{
|
|
|
|
|
public enum Statuses
|
|
|
|
|
{
|
|
|
|
|
TurnOff = 0,
|
|
|
|
|
TurnOn = 1,
|
|
|
|
|
Alarm = 2,
|
|
|
|
|
}
|
|
|
|
|
private bool bNewPic = false;
|
|
|
|
|
private string _statusName;
|
|
|
|
|
//private object _textName = string.Empty;
|
|
|
|
|
private Statuses _status;
|
|
|
|
|
private string[] sImages;
|
|
|
|
|
|
|
|
|
|
public ControlCabinet() : base()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
Init();
|
|
|
|
|
|
|
|
|
|
ReloadStream();
|
|
|
|
|
this.Reload();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Init()
|
|
|
|
|
{
|
|
|
|
|
base.Init();
|
|
|
|
|
_imageStream = null;
|
|
|
|
|
sImages = new string[3];
|
|
|
|
|
sImages[0] = "Mesnac.Controls.ChemicalWeighing.Resources.controlCabinet.png";//zsTurnOff
|
|
|
|
|
sImages[1] = "Mesnac.Controls.ChemicalWeighing.Resources.controlCabinet1.png";//zsTurnOn
|
|
|
|
|
sImages[2] = "Mesnac.Controls.ChemicalWeighing.Resources.controlCabinet0.png";//zsAlarm
|
|
|
|
|
_status = Statuses.TurnOff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ReloadStream()
|
|
|
|
|
{
|
|
|
|
|
int nIndex = (int)_status;
|
|
|
|
|
_imageStream = _assembly.GetManifestResourceStream(sImages[nIndex]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string StatusName
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _statusName;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_statusName = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Statuses Status
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _status;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (bFirstCreated == true)
|
|
|
|
|
{
|
|
|
|
|
bFirstCreated = false;
|
|
|
|
|
}
|
|
|
|
|
bool flag = false;
|
|
|
|
|
//if (_status != value &&(this.Size.Width != 150 || this.Size.Height != 150) )
|
|
|
|
|
if (_status != value)
|
|
|
|
|
{
|
|
|
|
|
flag = true;
|
|
|
|
|
if (this.DesignMode == true)
|
|
|
|
|
{
|
|
|
|
|
bNewPic = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((int)value < 0)
|
|
|
|
|
{
|
|
|
|
|
_status = (Statuses)0;
|
|
|
|
|
}
|
|
|
|
|
else if ((int)value > 2)
|
|
|
|
|
{
|
|
|
|
|
_status = (Statuses)1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_status = value;
|
|
|
|
|
}
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
ReloadStream();
|
|
|
|
|
Reload();
|
|
|
|
|
this.Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Reload()
|
|
|
|
|
{
|
|
|
|
|
if (_imageStream != null)
|
|
|
|
|
{
|
|
|
|
|
Image img = Image.FromStream(_imageStream);
|
|
|
|
|
Size size = new Size();
|
|
|
|
|
size.Width = 11;
|
|
|
|
|
size.Height = 14;
|
|
|
|
|
this.Size = size;
|
|
|
|
|
if (bNewPic == true)
|
|
|
|
|
{
|
|
|
|
|
this.Size = size;
|
|
|
|
|
bNewPic = false;
|
|
|
|
|
}
|
|
|
|
|
pictureBox1.Image = img;
|
|
|
|
|
pictureBox1.Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ControlCabinet_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (bFirstCreated == true && this.DesignMode == true)
|
|
|
|
|
{
|
|
|
|
|
bNewPic = true;
|
|
|
|
|
bFirstCreated = false;
|
|
|
|
|
Reload();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|