|
|
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( StraightTubeH ) , "ICONS.StraightTube.bmp" )]//新添加的代码
|
|
|
public partial class StraightTubeH : FeedingControl
|
|
|
{
|
|
|
public enum Types
|
|
|
{
|
|
|
ptLeftToRight = 0 ,
|
|
|
ptRightToLeft = 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 StraightTubeH():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.ptLeftToRight;
|
|
|
this._status = Statuses.ptTurnOff;
|
|
|
|
|
|
sImages = new string[ 3 ];
|
|
|
sImages[ 0 ] = "Mesnac.Controls.Feeding.Resources.zg.ZGHBlack1.gif";//
|
|
|
sImages[ 1 ] = "Mesnac.Controls.Feeding.Resources.zg.ZGHBlack2.gif";//
|
|
|
sImages[ 2 ] = "Mesnac.Controls.Feeding.Resources.zg.ZGH.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.ptLeftToRight)
|
|
|
{
|
|
|
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 StraightTubeH_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
if (bFirstCreated == true && this.DesignMode == true)
|
|
|
{
|
|
|
bFirstCreated = false;
|
|
|
ReloadStream();
|
|
|
Reload();
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
private void StraightTubeH_Resize( object sender , EventArgs e )
|
|
|
{
|
|
|
this.Height = 5;
|
|
|
}
|
|
|
}
|
|
|
}
|