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.
274 lines
7.8 KiB
C#
274 lines
7.8 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( OilWeight ) , "ICONS.OilWeight.bmp" )]//新添加的代码
|
|
public partial class OilWeight : FeedingControl
|
|
{
|
|
bool bNewPic = false;
|
|
string _statusName;
|
|
private string _actOutStatusName;
|
|
private OnOffStatuses _actOutStatus;
|
|
private double _setValue = 1;
|
|
private double _weightValue;
|
|
private string _setValueName;
|
|
private string _weightValueName;
|
|
|
|
public string StatusName
|
|
{
|
|
get
|
|
{
|
|
return _statusName;
|
|
}
|
|
set
|
|
{
|
|
_statusName = value;
|
|
}
|
|
}
|
|
|
|
public enum Statuses
|
|
{
|
|
ycNull = 0, ycValue1 = 1, ycValue2 = 2, ycValue3 = 3, ycValue4 = 4, ycValue5 = 5,
|
|
ycValue6 = 6, ycValue7 = 7, ycValue8 = 8, ycValue9 = 9, ycValue10 = 10,
|
|
ycValue11 = 11, ycValue12 = 12, ycValue13 = 13, ycValue14 = 14, ycValue15 = 15,
|
|
ycUnload = 16, ycWeight = 17, ycFull = 18,
|
|
}
|
|
|
|
Statuses _status;
|
|
string[] sImages;
|
|
public OilWeight():base()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Init();
|
|
|
|
ReloadStream();
|
|
this.Reload();
|
|
}
|
|
|
|
protected override void Init()
|
|
{
|
|
base.Init();
|
|
_imageStream = null;
|
|
|
|
sImages = new string[ 19 ];
|
|
sImages[ 0 ] = "Mesnac.Controls.Feeding.Resources.yc.yc00.png";//
|
|
sImages[ 1 ] = "Mesnac.Controls.Feeding.Resources.yc.yc04.png";//
|
|
sImages[ 2 ] = "Mesnac.Controls.Feeding.Resources.yc.yc05.png";//
|
|
sImages[ 3 ] = "Mesnac.Controls.Feeding.Resources.yc.yc06.png";//
|
|
sImages[ 4 ] = "Mesnac.Controls.Feeding.Resources.yc.yc07.png";//
|
|
sImages[ 5 ] = "Mesnac.Controls.Feeding.Resources.yc.yc08.png";//
|
|
sImages[ 6 ] = "Mesnac.Controls.Feeding.Resources.yc.yc09.png";//
|
|
sImages[ 7 ] = "Mesnac.Controls.Feeding.Resources.yc.yc10.png";//
|
|
sImages[ 8 ] = "Mesnac.Controls.Feeding.Resources.yc.yc11.png";//
|
|
sImages[ 9 ] = "Mesnac.Controls.Feeding.Resources.yc.yc12.png";//
|
|
sImages[ 10 ] = "Mesnac.Controls.Feeding.Resources.yc.yc13.png";//
|
|
sImages[ 11 ] = "Mesnac.Controls.Feeding.Resources.yc.yc14.png";//
|
|
sImages[ 12 ] = "Mesnac.Controls.Feeding.Resources.yc.yc15.png";//
|
|
sImages[ 13 ] = "Mesnac.Controls.Feeding.Resources.yc.yc16.png";//
|
|
sImages[ 14 ] = "Mesnac.Controls.Feeding.Resources.yc.yc17.png";//
|
|
sImages[ 15 ] = "Mesnac.Controls.Feeding.Resources.yc.yc18.png";//
|
|
sImages[ 16 ] = "Mesnac.Controls.Feeding.Resources.yc.yc_unload.gif";//
|
|
sImages[ 17 ] = "Mesnac.Controls.Feeding.Resources.yc.yc01.png";//
|
|
sImages[ 18 ] = "Mesnac.Controls.Feeding.Resources.yc.yc02.png";//
|
|
|
|
_status = Statuses.ycValue8;
|
|
}
|
|
|
|
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 > 18 )
|
|
{
|
|
_status = (Statuses)18;
|
|
}
|
|
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 OilWeight_Load(object sender, EventArgs e)
|
|
{
|
|
if (bFirstCreated == true && this.DesignMode == true)
|
|
{
|
|
bNewPic = true;
|
|
bFirstCreated = false;
|
|
}
|
|
|
|
}
|
|
|
|
#region 卸料状态
|
|
|
|
/// <summary>
|
|
/// 卸料状态动画属性
|
|
/// </summary>
|
|
public string ActOutStatusName
|
|
{
|
|
get { return _actOutStatusName; }
|
|
set { _actOutStatusName = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 卸料状态
|
|
/// </summary>
|
|
public OnOffStatuses ActOutStatus
|
|
{
|
|
get { return _actOutStatus; }
|
|
set
|
|
{
|
|
bool flag = false;
|
|
if (this._actOutStatus != value)
|
|
flag = true;
|
|
if ((int)value > 1)
|
|
{
|
|
this._actOutStatus = OnOffStatuses.On;
|
|
}
|
|
else if ((int)value < 0)
|
|
{
|
|
this._actOutStatus = OnOffStatuses.Off;
|
|
}
|
|
else
|
|
{
|
|
this._actOutStatus = value;
|
|
}
|
|
if (this._actOutStatus == OnOffStatuses.On)
|
|
{
|
|
this._status = Statuses.ycUnload;
|
|
}
|
|
if (flag)
|
|
{
|
|
ReloadStream();
|
|
this.Reload();
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 称量值与设定值
|
|
|
|
/// <summary>
|
|
/// 设定值动画属性
|
|
/// </summary>
|
|
public string SetValueName
|
|
{
|
|
get { return _setValueName; }
|
|
set { _setValueName = value; }
|
|
}
|
|
/// <summary>
|
|
/// 称量值动画属性
|
|
/// </summary>
|
|
public string WeightValueName
|
|
{
|
|
get { return _weightValueName; }
|
|
set { _weightValueName = value; }
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 设定值
|
|
/// </summary>
|
|
public double SetValue
|
|
{
|
|
get { return _setValue; }
|
|
set
|
|
{
|
|
_setValue = value;
|
|
if (this._setValue == 0)
|
|
{
|
|
this._setValue = 1;
|
|
}
|
|
|
|
this.Status = (Statuses)Math.Floor((this._weightValue * 15) / this._setValue);
|
|
|
|
ReloadStream();
|
|
this.Reload();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 称量值
|
|
/// </summary>
|
|
public double WeightValue
|
|
{
|
|
get { return _weightValue; }
|
|
set
|
|
{
|
|
_weightValue = value;
|
|
|
|
if (this._weightValue > this._setValue)
|
|
{
|
|
this._weightValue = this._setValue;
|
|
}
|
|
|
|
this.Status = (Statuses)Math.Floor((this._weightValue * 15) / this._setValue);
|
|
|
|
ReloadStream();
|
|
this.Reload();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|