|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Drawing;
|
|
|
using System.IO;
|
|
|
using System.Reflection;
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace Mesnac.Controls.Feeding
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 竖管
|
|
|
/// </summary>
|
|
|
[ToolboxBitmap( typeof( StraightTubeV ) , "ICONS.StraightTube.bmp" )]//新添加的代码
|
|
|
public partial class StraightTubeV : FeedingControl
|
|
|
{
|
|
|
public enum Types
|
|
|
{
|
|
|
ptUpToDown = 0 ,
|
|
|
ptDownToUp = 1 ,
|
|
|
}
|
|
|
public enum Statuses
|
|
|
{
|
|
|
ptTurnOff = 0 ,
|
|
|
ptTurnOn = 1
|
|
|
}
|
|
|
|
|
|
#region 变量
|
|
|
Types _type;
|
|
|
Statuses _status;
|
|
|
string[] sImages;
|
|
|
private string _master;
|
|
|
string _statusName;
|
|
|
//int iWidth=45;
|
|
|
//int iHeight=5;
|
|
|
#endregion
|
|
|
|
|
|
#region 属性
|
|
|
public string StatusName
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _statusName;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_statusName = value;
|
|
|
}
|
|
|
}
|
|
|
public Types Type
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _type;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
if (bFirstCreated == true)
|
|
|
{
|
|
|
bFirstCreated = false;
|
|
|
}
|
|
|
|
|
|
_type = value;
|
|
|
|
|
|
ReloadStream();
|
|
|
this.Reload();
|
|
|
}
|
|
|
}
|
|
|
public Statuses Status
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _status;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
if ( bFirstCreated == true )
|
|
|
{
|
|
|
bFirstCreated = false;
|
|
|
}
|
|
|
|
|
|
if ( (int)value < 0 )
|
|
|
{
|
|
|
_status = (Statuses)0;
|
|
|
}
|
|
|
else if ( (int)value > 1 )
|
|
|
{
|
|
|
_status = (Statuses)0; //报警时plc值大于1,这时应该设置不流动
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_status = value;
|
|
|
}
|
|
|
ReloadStream();
|
|
|
this.Reload();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
[TypeConverter( typeof( StringListConverterStraightTube2 ) )]
|
|
|
public string Master
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _master;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_master = value;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
public StraightTubeV():base()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
|
|
|
Init();
|
|
|
|
|
|
ReloadStream();
|
|
|
|
|
|
this.Reload();
|
|
|
}
|
|
|
|
|
|
#region 方法
|
|
|
public void SetStatus( OnoffValve.Statuses s )
|
|
|
{
|
|
|
switch(s)
|
|
|
{
|
|
|
case OnoffValve.Statuses.zsTurnOn:
|
|
|
_status = Statuses.ptTurnOn;
|
|
|
break;
|
|
|
case OnoffValve.Statuses.zsTurnOff:
|
|
|
_status = Statuses.ptTurnOff;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
ReloadStream();
|
|
|
this.Reload();
|
|
|
}
|
|
|
|
|
|
protected override void Init()
|
|
|
{
|
|
|
base.Init();
|
|
|
_imageStream = null;
|
|
|
_type = Types.ptUpToDown;
|
|
|
this._status = Statuses.ptTurnOff;
|
|
|
|
|
|
sImages = new string[ 3 ];
|
|
|
sImages[ 0 ] = "Mesnac.Controls.Feeding.Resources.zg.ZGVBlack1.gif";//
|
|
|
sImages[ 1 ] = "Mesnac.Controls.Feeding.Resources.zg.ZGVBlack2.gif";//
|
|
|
sImages[ 2 ] = "Mesnac.Controls.Feeding.Resources.zg.ZGV.png";//
|
|
|
}
|
|
|
|
|
|
private void ReloadStream()
|
|
|
{
|
|
|
//CloseStream();
|
|
|
int iType = (int)_type;
|
|
|
int iStatus = (int)_status;
|
|
|
string img = this.sImages[2];
|
|
|
if (this._status == Statuses.ptTurnOn)
|
|
|
{
|
|
|
if (this._type == Types.ptUpToDown)
|
|
|
{
|
|
|
img = this.sImages[0];
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
img = this.sImages[1];
|
|
|
}
|
|
|
}
|
|
|
//_imageStream = _assembly.GetManifestResourceStream( sImages[ 2 * iStatus + iType / ( iStatus + 1 ) ] );
|
|
|
_imageStream = _assembly.GetManifestResourceStream(img);
|
|
|
}
|
|
|
|
|
|
private void Reload()
|
|
|
{
|
|
|
if ( _imageStream != null )
|
|
|
{
|
|
|
Image img = Image.FromStream( _imageStream );
|
|
|
pictureBox1.Image = img;
|
|
|
pictureBox1.Refresh();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private void StraightTubeV_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
if (bFirstCreated == true && this.DesignMode == true)
|
|
|
{
|
|
|
bFirstCreated = false;
|
|
|
|
|
|
Reload();
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
private void StraightTubeV_Resize( object sender , EventArgs e )
|
|
|
{
|
|
|
this.Width = 5;
|
|
|
}
|
|
|
}
|
|
|
}
|