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.
213 lines
5.2 KiB
C#
213 lines
5.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Mesnac.Controls.Intake.Base;
|
|
using Mesnac.Controls.Base;
|
|
|
|
namespace Mesnac.Controls.Intake
|
|
{
|
|
/// <summary>
|
|
/// 通断阀
|
|
/// </summary>
|
|
[ToolboxBitmap(typeof(AirOnoffValve), "ICONS.OnoffValve.bmp")]//新添加的代码
|
|
public partial class AirOnoffValve : IntakeControl, IValve
|
|
{
|
|
public AirOnoffValve():base()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Init();
|
|
|
|
ReloadStream();
|
|
|
|
this.Reload();
|
|
}
|
|
|
|
bool bNewPic = false;
|
|
string _statusName;
|
|
|
|
public string StatusName
|
|
{
|
|
get
|
|
{
|
|
return _statusName;
|
|
}
|
|
set
|
|
{
|
|
_statusName = value;
|
|
}
|
|
}
|
|
|
|
public enum Statuses
|
|
{
|
|
zsTurnOff = 0, zsTurnOn = 1, zsAlarm = 2
|
|
}
|
|
|
|
Statuses _status;
|
|
string[,] sImages;
|
|
|
|
public enum Types
|
|
{
|
|
ttHorizontal = 0, ttVertical = 1
|
|
}
|
|
|
|
Types _type;
|
|
|
|
|
|
protected override void Init()
|
|
{
|
|
base.Init();
|
|
_imageStream = null;
|
|
|
|
sImages = new string[ 2 , 3 ];
|
|
sImages[0, 0] = "Mesnac.Controls.Intake.Resources.tdf.FMTP20.png";//dkNull
|
|
sImages[0, 1] = "Mesnac.Controls.Intake.Resources.tdf.FMTP21.png";//dkNull
|
|
sImages[0, 2] = "Mesnac.Controls.Intake.Resources.tdf.FMTP2ARM.gif";//dkNull
|
|
sImages[1, 0] = "Mesnac.Controls.Intake.Resources.tdf.FMTP10.png";//dkNull
|
|
sImages[1, 1] = "Mesnac.Controls.Intake.Resources.tdf.FMTP11.png";//dkNull
|
|
sImages[1, 2] = "Mesnac.Controls.Intake.Resources.tdf.FMTP1ARM.gif";//dkNull
|
|
|
|
_status = Statuses.zsTurnOff;
|
|
_type = Types.ttHorizontal;
|
|
}
|
|
|
|
private void ReloadStream()
|
|
{
|
|
//CloseStream();
|
|
int nIndex0 = (int)_type;
|
|
int nIndex1 = (int)_status;
|
|
_imageStream = _assembly.GetManifestResourceStream(sImages[nIndex0, nIndex1]);
|
|
}
|
|
|
|
public Types Type
|
|
{
|
|
get
|
|
{
|
|
return _type;
|
|
}
|
|
set
|
|
{
|
|
if (bFirstCreated == true)
|
|
{
|
|
bFirstCreated = false;
|
|
}
|
|
|
|
if (_type != value)
|
|
{
|
|
if (this.DesignMode == true)
|
|
{
|
|
bNewPic = true;
|
|
}
|
|
}
|
|
|
|
_type = value;
|
|
ReloadStream();
|
|
//this.Refresh();
|
|
|
|
this.Reload();
|
|
}
|
|
}
|
|
public Statuses Status
|
|
{
|
|
get
|
|
{
|
|
return _status;
|
|
}
|
|
set
|
|
{
|
|
if (bFirstCreated == true)
|
|
{
|
|
bFirstCreated = false;
|
|
}
|
|
bool flag = false;
|
|
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();
|
|
|
|
this.Reload();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 直通状态属性
|
|
/// </summary>
|
|
public OnOffStatuses AirOnoffValveStatus
|
|
{
|
|
get { return this._status == Statuses.zsTurnOn ? OnOffStatuses.On : OnOffStatuses.Off; }
|
|
}
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
{
|
|
if (_imageStream != null)
|
|
{
|
|
Graphics g = e.Graphics;
|
|
Image img = Image.FromStream(_imageStream);
|
|
|
|
if (bNewPic == true)
|
|
{
|
|
this.Size = img.Size;
|
|
bNewPic = false;
|
|
}
|
|
|
|
g.DrawImage(img, 0, 0, this.Width, this.Height);
|
|
}
|
|
}
|
|
|
|
private void OnoffValve_Load(object sender, EventArgs e)
|
|
{
|
|
if (bFirstCreated == true && this.DesignMode == true)
|
|
{
|
|
bNewPic = true;
|
|
bFirstCreated = false;
|
|
this.Reload();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private void Reload()
|
|
{
|
|
if (_imageStream != null)
|
|
{
|
|
Image img = Image.FromStream(_imageStream);
|
|
if (bNewPic == true)
|
|
{
|
|
this.Size = img.Size;
|
|
bNewPic = false;
|
|
}
|
|
pictureBox1.Image = img;
|
|
pictureBox1.Refresh();
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|