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.
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Controls.ChemicalWeighing
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 报警灯
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ToolboxBitmap(typeof(SystemStateShow), "Resources.SystemStop.png")]//新添加的代码
|
|
|
|
|
public partial class SystemStateShow : ChemicalWeighingControl
|
|
|
|
|
{
|
|
|
|
|
bool bNewPic = false;
|
|
|
|
|
string _statusName;
|
|
|
|
|
|
|
|
|
|
public string StatusName
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _statusName;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_statusName = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public enum Statuses
|
|
|
|
|
{
|
|
|
|
|
sssStop = 0, sssRun = 1
|
|
|
|
|
}
|
|
|
|
|
Statuses _status;
|
|
|
|
|
string[] sImages;
|
|
|
|
|
public SystemStateShow():base()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
Init();
|
|
|
|
|
ReloadStream();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Init()
|
|
|
|
|
{
|
|
|
|
|
base.Init();
|
|
|
|
|
_imageStream = null;
|
|
|
|
|
|
|
|
|
|
sImages = new string[2];
|
|
|
|
|
sImages[0] = "Mesnac.Controls.ChemicalWeighing.Resources.SystemStop.png";//
|
|
|
|
|
sImages[1] = "Mesnac.Controls.ChemicalWeighing.Resources.SystemRun.png";//
|
|
|
|
|
|
|
|
|
|
_status = Statuses.sssStop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ReloadStream()
|
|
|
|
|
{
|
|
|
|
|
int nIndex = (int)_status;
|
|
|
|
|
_imageStream = _assembly.GetManifestResourceStream(sImages[nIndex]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Statuses Status
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _status;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (bFirstCreated == true)
|
|
|
|
|
{
|
|
|
|
|
bFirstCreated = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( _status != value )
|
|
|
|
|
{
|
|
|
|
|
if (this.DesignMode == true)
|
|
|
|
|
{
|
|
|
|
|
bNewPic = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( (int)value < 0 )
|
|
|
|
|
{
|
|
|
|
|
_status = (Statuses)0;
|
|
|
|
|
}
|
|
|
|
|
else if ( (int)value > 1 )
|
|
|
|
|
{
|
|
|
|
|
_status = (Statuses)1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_status = value;
|
|
|
|
|
}
|
|
|
|
|
ReloadStream();
|
|
|
|
|
Reload();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void Reload()
|
|
|
|
|
{
|
|
|
|
|
if ( _imageStream != null )
|
|
|
|
|
{
|
|
|
|
|
Image img = Image.FromStream( _imageStream );
|
|
|
|
|
if ( bNewPic == true )
|
|
|
|
|
{
|
|
|
|
|
bNewPic = false;
|
|
|
|
|
}
|
|
|
|
|
pictureBox1.Image = img;
|
|
|
|
|
pictureBox1.Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_imageStream != null)
|
|
|
|
|
{
|
|
|
|
|
Graphics g = e.Graphics;
|
|
|
|
|
Image img = Image.FromStream(_imageStream);
|
|
|
|
|
if (bNewPic == true)
|
|
|
|
|
{
|
|
|
|
|
bNewPic = false;
|
|
|
|
|
}
|
|
|
|
|
g.DrawImage(img, 0, 0, this.Width, this.Height);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PressureSwitch_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (bFirstCreated == true && this.DesignMode == true)
|
|
|
|
|
{
|
|
|
|
|
bNewPic = true;
|
|
|
|
|
bFirstCreated = false;
|
|
|
|
|
Reload();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|