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.
185 lines
4.6 KiB
C#
185 lines
4.6 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( SwitchOutValve ) , "ICONS.SwitchValve.bmp" )]//新添加的代码
|
|
public partial class SwitchOutValve : FeedingControl
|
|
{
|
|
bool bNewPic = false;
|
|
string _statusName;
|
|
|
|
public string StatusName
|
|
{
|
|
get
|
|
{
|
|
return _statusName;
|
|
}
|
|
set
|
|
{
|
|
_statusName = value;
|
|
}
|
|
}
|
|
|
|
public enum Statuses
|
|
{
|
|
csBSide = 0, csASide = 1, csAlarm = 2
|
|
}
|
|
|
|
Statuses _status;
|
|
string[,] sImages;
|
|
|
|
public enum Types
|
|
{
|
|
ctDown = 0, ctUp = 1
|
|
}
|
|
|
|
Types _type;
|
|
|
|
public SwitchOutValve():base()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Init();
|
|
|
|
ReloadStream();
|
|
}
|
|
|
|
protected override void Init()
|
|
{
|
|
base.Init();
|
|
_imageStream = null;
|
|
|
|
sImages = new string[ 2 , 3 ];
|
|
sImages[ 0 , 0 ] = "Mesnac.Controls.Feeding.Resources.cdf.cdf001.png";//
|
|
sImages[ 0 , 1 ] = "Mesnac.Controls.Feeding.Resources.cdf.cdf000.png";//
|
|
sImages[ 0 , 2 ] = "Mesnac.Controls.Feeding.Resources.cdf.cdf002.gif";//
|
|
sImages[ 1 , 0 ] = "Mesnac.Controls.Feeding.Resources.cdf.cdf011.png";//
|
|
sImages[ 1 , 1 ] = "Mesnac.Controls.Feeding.Resources.cdf.cdf010.png";//
|
|
sImages[ 1 , 2 ] = "Mesnac.Controls.Feeding.Resources.cdf.cdf012.gif";//
|
|
|
|
_status = Statuses.csASide;
|
|
_type = Types.ctDown;
|
|
}
|
|
|
|
private void ReloadStream()
|
|
{
|
|
//CloseStream();
|
|
int nIndex = (int)_type;
|
|
_imageStream = _assembly.GetManifestResourceStream( sImages[ (int)_type , (int)_status ] );
|
|
}
|
|
|
|
public Types Type
|
|
{
|
|
get
|
|
{
|
|
return _type;
|
|
}
|
|
set
|
|
{
|
|
if (bFirstCreated == true)
|
|
{
|
|
bFirstCreated = false;
|
|
}
|
|
|
|
if (_type != value)
|
|
{
|
|
if (this.DesignMode == true)
|
|
{
|
|
bNewPic = true;
|
|
}
|
|
}
|
|
|
|
_type = value;
|
|
|
|
this.Refresh();
|
|
|
|
|
|
}
|
|
}
|
|
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 > 2 )
|
|
{
|
|
_status = (Statuses)2;
|
|
}
|
|
else
|
|
{
|
|
_status = value;
|
|
}
|
|
if (flag)
|
|
{
|
|
ReloadStream();
|
|
this.Refresh();
|
|
}
|
|
|
|
}
|
|
}
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
{
|
|
if (_imageStream != null)
|
|
{
|
|
Graphics g = e.Graphics;
|
|
Image img = Image.FromStream(_imageStream);
|
|
if (_type == Types.ctDown)
|
|
{
|
|
//img.RotateFlip(RotateFlipType.
|
|
}
|
|
else if (_type == Types.ctUp)
|
|
{
|
|
img.RotateFlip(RotateFlipType.RotateNoneFlipY);
|
|
}
|
|
if (bNewPic == true)
|
|
{
|
|
this.Size = img.Size;
|
|
bNewPic = false;
|
|
}
|
|
|
|
g.DrawImage(img, 0, 0, this.Width, this.Height);
|
|
}
|
|
}
|
|
|
|
private void SwitchOutValve_Load(object sender, EventArgs e)
|
|
{
|
|
if (bFirstCreated == true && this.DesignMode == true)
|
|
{
|
|
bNewPic = true;
|
|
bFirstCreated = false;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|