|
|
|
|
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 System.Drawing.Design;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Controls.Intake
|
|
|
|
|
{
|
|
|
|
|
[ToolboxBitmap(typeof(AirStraightTube), "ICONS.StraightTube.bmp")]//新添加的代码
|
|
|
|
|
public partial class AirStraightTube : IntakeControl, ITube
|
|
|
|
|
{
|
|
|
|
|
#region 字段
|
|
|
|
|
private bool bNewPic = false;
|
|
|
|
|
protected Stream _imageStream; //图片资源流
|
|
|
|
|
Types _type;
|
|
|
|
|
Statuses _status;
|
|
|
|
|
string[,] sImages;
|
|
|
|
|
string _statusName;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 连接的下一个控件
|
|
|
|
|
/// </summary>
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public AirStraightTube()
|
|
|
|
|
: base()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
Init();
|
|
|
|
|
ReloadStream();
|
|
|
|
|
Reload();
|
|
|
|
|
}
|
|
|
|
|
public enum Types
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 空气横管
|
|
|
|
|
/// </summary>
|
|
|
|
|
ptAirH = 0,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 空气竖管
|
|
|
|
|
/// </summary>
|
|
|
|
|
ptAirV = 1,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 炭黑横管
|
|
|
|
|
/// </summary>
|
|
|
|
|
ptCarbonH = 2,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 炭黑竖管
|
|
|
|
|
/// </summary>
|
|
|
|
|
ptCarbonV=3
|
|
|
|
|
}
|
|
|
|
|
public enum Statuses
|
|
|
|
|
{
|
|
|
|
|
ptTurnOff = 0,
|
|
|
|
|
ptTurnOn = 1
|
|
|
|
|
}
|
|
|
|
|
#region 属性
|
|
|
|
|
|
|
|
|
|
public string StatusName
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _statusName;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_statusName = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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 > 1)
|
|
|
|
|
{
|
|
|
|
|
_status = (Statuses)1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_status = value;
|
|
|
|
|
}
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
ReloadStream();
|
|
|
|
|
//this.Refresh();
|
|
|
|
|
this.Reload();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public Types Type
|
|
|
|
|
{
|
|
|
|
|
get { return _type; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (bFirstCreated == true)
|
|
|
|
|
{
|
|
|
|
|
bFirstCreated = false;
|
|
|
|
|
}
|
|
|
|
|
if (_type != value)
|
|
|
|
|
{
|
|
|
|
|
if (this.DesignMode == true)
|
|
|
|
|
{
|
|
|
|
|
bNewPic = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Types _tmpType = _type;
|
|
|
|
|
|
|
|
|
|
_type = value;
|
|
|
|
|
//if ((_tmpType != Types.ptAirH && value == Types.ptCarbonH || _tmpType != Types.ptCarbonH && value == Types.ptAirH))
|
|
|
|
|
if ((_tmpType == Types.ptAirH || _tmpType == Types.ptCarbonH) && (value == Types.ptAirV || value == Types.ptCarbonV))
|
|
|
|
|
{
|
|
|
|
|
int i = this.Height;
|
|
|
|
|
this.Height = this.Width;
|
|
|
|
|
this.Width = i;
|
|
|
|
|
}
|
|
|
|
|
//if ((_tmpType != Types.ptAirV && value == Types.ptCarbonV || _tmpType != Types.ptCarbonV && value == Types.ptAirV))
|
|
|
|
|
if ((_tmpType == Types.ptAirV || _tmpType == Types.ptCarbonV) &&( value == Types.ptAirH || value == Types.ptCarbonH))
|
|
|
|
|
{
|
|
|
|
|
int i = this.Width;
|
|
|
|
|
this.Width = this.Height;
|
|
|
|
|
this.Height = i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ReloadStream();
|
|
|
|
|
|
|
|
|
|
//this.Refresh();
|
|
|
|
|
this.Reload();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
protected override void Init()
|
|
|
|
|
{
|
|
|
|
|
base.Init();
|
|
|
|
|
_imageStream = null;
|
|
|
|
|
sImages = new string[4, 2];
|
|
|
|
|
|
|
|
|
|
sImages[0, 0] = "Mesnac.Controls.Intake.Resources.zg.airh.png";//
|
|
|
|
|
sImages[0, 1] = "Mesnac.Controls.Intake.Resources.zg.airh1.png";//
|
|
|
|
|
sImages[1, 0] = "Mesnac.Controls.Intake.Resources.zg.airv.png";//
|
|
|
|
|
sImages[1, 1] = "Mesnac.Controls.Intake.Resources.zg.airv1.png";//
|
|
|
|
|
|
|
|
|
|
sImages[2, 0] = "Mesnac.Controls.Intake.Resources.zg.carbonh.png";//
|
|
|
|
|
sImages[2, 1] = "Mesnac.Controls.Intake.Resources.zg.carbonh1.png";//
|
|
|
|
|
sImages[3, 0] = "Mesnac.Controls.Intake.Resources.zg.carbonv.png";//
|
|
|
|
|
sImages[3, 1] = "Mesnac.Controls.Intake.Resources.zg.carbonv1.png";//
|
|
|
|
|
|
|
|
|
|
_type = Types.ptCarbonH;
|
|
|
|
|
this._status = Statuses.ptTurnOff;
|
|
|
|
|
}
|
|
|
|
|
private void PipeLink_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (bFirstCreated == true && this.DesignMode == true)
|
|
|
|
|
{
|
|
|
|
|
bFirstCreated = false;
|
|
|
|
|
Reload();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void ReloadStream()
|
|
|
|
|
{
|
|
|
|
|
//CloseStream();
|
|
|
|
|
int ntype = (int)_type;
|
|
|
|
|
int nIndex = (int)_status;
|
|
|
|
|
|
|
|
|
|
_imageStream = _assembly.GetManifestResourceStream(sImages[ntype, nIndex]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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 Reload()
|
|
|
|
|
{
|
|
|
|
|
if (_imageStream != null)
|
|
|
|
|
{
|
|
|
|
|
Image img = Image.FromStream(_imageStream);
|
|
|
|
|
pictureBox1.Image = img;
|
|
|
|
|
pictureBox1.Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void StraightTube_Resize(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_type == Types.ptAirH || _type == Types.ptCarbonH)
|
|
|
|
|
{
|
|
|
|
|
this.Height = 5;
|
|
|
|
|
}
|
|
|
|
|
else if (_type == Types.ptAirV || _type == Types.ptCarbonV)
|
|
|
|
|
{
|
|
|
|
|
this.Width = 5;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|