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.Feeding/CBIMWeight.cs

141 lines
3.5 KiB
C#

using System;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
namespace Mesnac.Controls.Feeding
{
/// <summary>
/// 炭黑检料秤
/// </summary>
[ToolboxBitmap( typeof( CBIMWeight ) , "ICONS.CBIMWeight.bmp" )]//新添加的代码
public partial class CBIMWeight : FeedingControl
{
bool bNewPic = false;
string _statusName;
public string StatusName
{
get
{
return _statusName;
}
set
{
_statusName = value;
}
}
public enum Statuses
{
jnlNull = 0, jnlWeight = 1, jnlFull = 2, jnlUnload = 3, jnlAlarm = 4
}
Statuses _status;
string[] sImages;
public CBIMWeight():base()
{
InitializeComponent();
Init();
ReloadStream();
this.Reload();
}
protected override void Init()
{
base.Init();
_imageStream = null;
sImages = new string[5];
sImages[ 0 ] = "Mesnac.Controls.Feeding.Resources.thc.thc00.png";//
sImages[ 1 ] = "Mesnac.Controls.Feeding.Resources.thc.thc01.png";//
sImages[ 2 ] = "Mesnac.Controls.Feeding.Resources.thc.thc02.png";//
sImages[ 3 ] = "Mesnac.Controls.Feeding.Resources.thc.thc_unload.gif";//
sImages[ 4 ] = "Mesnac.Controls.Feeding.Resources.thc.thc04.png";//
_status = Statuses.jnlWeight;
}
private void ReloadStream()
{
//CloseStream();
int nIndex = (int)_status;
_imageStream = _assembly.GetManifestResourceStream(sImages[nIndex]);
}
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 > 4 )
{
_status = (Statuses)4;
}
else
{
_status = value;
}
if (flag)
{
ReloadStream();
this.Reload();
}
}
}
protected void Reload()
{
if (_imageStream != null)
{
Image img = Image.FromStream(_imageStream);
if (bNewPic == true)
{
this.Size = img.Size;
bNewPic = false;
}
this.pictureBox1.Image = img;
this.pictureBox1.Refresh();
}
}
private void CBIMWeight_Load(object sender, EventArgs e)
{
if (bFirstCreated == true && this.DesignMode == true)
{
bNewPic = true;
bFirstCreated = false;
}
}
}
}