|
|
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 Mesnac.Controls.Base;
|
|
|
|
|
|
namespace Mesnac.Controls.Intake
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 岔道阀进2
|
|
|
/// </summary>
|
|
|
[ToolboxBitmap(typeof(ForkValveInTwo), "ICONS.ForkValveInTwo.bmp")]
|
|
|
public partial class ForkValveInTwo : IntakeControl, IValve
|
|
|
{
|
|
|
#region 岔道阀类型定义,根据八个方向进行定义
|
|
|
|
|
|
public enum Types
|
|
|
{
|
|
|
ctUpLeft = 0, ctUpRight = 1, ctDownLeft = 2, ctDownRight = 3, ctRightUp = 4, ctRightDown = 5, ctLeftUp = 6, ctLeftDown = 7
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 枚举状态定义,岔道阀有5个状态:AB均不通、直通、直通故障、斜通、斜通故障
|
|
|
|
|
|
public enum Statuses
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// AB均不通
|
|
|
/// </summary>
|
|
|
csNormal = 0,
|
|
|
/// <summary>
|
|
|
/// 直通
|
|
|
/// </summary>
|
|
|
csASide = 1,
|
|
|
/// <summary>
|
|
|
/// 直通故障
|
|
|
/// </summary>
|
|
|
csAAlarm = 2,
|
|
|
/// <summary>
|
|
|
/// 斜通
|
|
|
/// </summary>
|
|
|
csBSide = 4,
|
|
|
/// <summary>
|
|
|
/// 斜通故障
|
|
|
/// </summary>
|
|
|
csBAlarm = 8
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 字段定义
|
|
|
|
|
|
private bool bNewPic = false;
|
|
|
private Types _type;
|
|
|
private string _statusName;
|
|
|
private Statuses _status;
|
|
|
private string[,] sImages;
|
|
|
private string tempImage = String.Empty;
|
|
|
private System.Timers.Timer timer = null;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
public ForkValveInTwo(): base()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
Init();
|
|
|
ReloadStream();
|
|
|
}
|
|
|
|
|
|
protected override void Init()
|
|
|
{
|
|
|
base.Init();
|
|
|
_imageStream = null;
|
|
|
|
|
|
sImages = new string[8, 9];
|
|
|
|
|
|
#region 图片资源初始化
|
|
|
|
|
|
sImages[0, 0] = "Mesnac.Controls.Intake.Resources.ForkValve.UpLeft_Normal.png";
|
|
|
sImages[0, 1] = "Mesnac.Controls.Intake.Resources.ForkValve.UpLeft_ASide.png";
|
|
|
sImages[0, 2] = "Mesnac.Controls.Intake.Resources.ForkValve.UpLeft_AAlarm.png";
|
|
|
sImages[0, 4] = "Mesnac.Controls.Intake.Resources.ForkValve.UpLeft_BSide.png";
|
|
|
sImages[0, 8] = "Mesnac.Controls.Intake.Resources.ForkValve.UpLeft_BAlarm.png";
|
|
|
|
|
|
sImages[1, 0] = "Mesnac.Controls.Intake.Resources.ForkValve.UpRight_Normal.png";
|
|
|
sImages[1, 1] = "Mesnac.Controls.Intake.Resources.ForkValve.UpRight_ASide.png";
|
|
|
sImages[1, 2] = "Mesnac.Controls.Intake.Resources.ForkValve.UpRight_AAlarm.png";
|
|
|
sImages[1, 4] = "Mesnac.Controls.Intake.Resources.ForkValve.UpRight_BSide.png";
|
|
|
sImages[1, 8] = "Mesnac.Controls.Intake.Resources.ForkValve.UpRight_BAlarm.png";
|
|
|
|
|
|
sImages[2, 0] = "Mesnac.Controls.Intake.Resources.ForkValve.DownLeft_Normal.png";
|
|
|
sImages[2, 1] = "Mesnac.Controls.Intake.Resources.ForkValve.DownLeft_ASide.png";
|
|
|
sImages[2, 2] = "Mesnac.Controls.Intake.Resources.ForkValve.DownLeft_AAlarm.png";
|
|
|
sImages[2, 4] = "Mesnac.Controls.Intake.Resources.ForkValve.DownLeft_BSide.png";
|
|
|
sImages[2, 8] = "Mesnac.Controls.Intake.Resources.ForkValve.DownLeft_BAlarm.png";
|
|
|
|
|
|
sImages[3, 0] = "Mesnac.Controls.Intake.Resources.ForkValve.DownRight_Normal.png";
|
|
|
sImages[3, 1] = "Mesnac.Controls.Intake.Resources.ForkValve.DownRight_ASide.png";
|
|
|
sImages[3, 2] = "Mesnac.Controls.Intake.Resources.ForkValve.DownRight_AAlarm.png";
|
|
|
sImages[3, 4] = "Mesnac.Controls.Intake.Resources.ForkValve.DownRight_BSide.png";
|
|
|
sImages[3, 8] = "Mesnac.Controls.Intake.Resources.ForkValve.DownRight_BAlarm.png";
|
|
|
|
|
|
sImages[4, 0] = "Mesnac.Controls.Intake.Resources.ForkValve.RightUp_Normal.png";
|
|
|
sImages[4, 1] = "Mesnac.Controls.Intake.Resources.ForkValve.RightUp_ASide.png";
|
|
|
sImages[4, 2] = "Mesnac.Controls.Intake.Resources.ForkValve.RightUp_AAlarm.png";
|
|
|
sImages[4, 4] = "Mesnac.Controls.Intake.Resources.ForkValve.RightUp_BSide.png";
|
|
|
sImages[4, 8] = "Mesnac.Controls.Intake.Resources.ForkValve.RightUp_BAlarm.png";
|
|
|
|
|
|
sImages[5, 0] = "Mesnac.Controls.Intake.Resources.ForkValve.RightDown_Normal.png";
|
|
|
sImages[5, 1] = "Mesnac.Controls.Intake.Resources.ForkValve.RightDown_ASide.png";
|
|
|
sImages[5, 2] = "Mesnac.Controls.Intake.Resources.ForkValve.RightDown_AAlarm.png";
|
|
|
sImages[5, 4] = "Mesnac.Controls.Intake.Resources.ForkValve.RightDown_BSide.png";
|
|
|
sImages[5, 8] = "Mesnac.Controls.Intake.Resources.ForkValve.RightDown_BAlarm.png";
|
|
|
|
|
|
sImages[6, 0] = "Mesnac.Controls.Intake.Resources.ForkValve.LeftUp_Normal.png";
|
|
|
sImages[6, 1] = "Mesnac.Controls.Intake.Resources.ForkValve.LeftUp_ASide.png";
|
|
|
sImages[6, 2] = "Mesnac.Controls.Intake.Resources.ForkValve.LeftUp_AAlarm.png";
|
|
|
sImages[6, 4] = "Mesnac.Controls.Intake.Resources.ForkValve.LeftUp_BSide.png";
|
|
|
sImages[6, 8] = "Mesnac.Controls.Intake.Resources.ForkValve.LeftUp_BAlarm.png";
|
|
|
|
|
|
sImages[7, 0] = "Mesnac.Controls.Intake.Resources.ForkValve.LeftDown_Normal.png";
|
|
|
sImages[7, 1] = "Mesnac.Controls.Intake.Resources.ForkValve.LeftDown_ASide.png";
|
|
|
sImages[7, 2] = "Mesnac.Controls.Intake.Resources.ForkValve.LeftDown_AAlarm.png";
|
|
|
sImages[7, 4] = "Mesnac.Controls.Intake.Resources.ForkValve.LeftDown_BSide.png";
|
|
|
sImages[7, 8] = "Mesnac.Controls.Intake.Resources.ForkValve.LeftDown_BAlarm.png";
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
_type = Types.ctUpLeft; //初始类型
|
|
|
_status = Statuses.csNormal; //初始值
|
|
|
|
|
|
this.timer = new System.Timers.Timer();
|
|
|
this.timer.Interval = 400;
|
|
|
this.timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
|
|
|
}
|
|
|
|
|
|
private void ReloadStream()
|
|
|
{
|
|
|
int ntype = (int)_type;
|
|
|
int nIndex = (int)_status;
|
|
|
if (nIndex != 0 && nIndex != 1 && nIndex != 2 && nIndex != 4 && nIndex != 8)
|
|
|
{
|
|
|
nIndex = 2;
|
|
|
}
|
|
|
_imageStream = _assembly.GetManifestResourceStream(sImages[ntype, nIndex]);
|
|
|
this.tempImage = String.Empty;
|
|
|
if (sImages[ntype, nIndex].IndexOf("Alarm") > 0)
|
|
|
{
|
|
|
this.timer.Start();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.timer.Stop();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public Types Type
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _type;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
//if (bFirstCreated == true)
|
|
|
//{
|
|
|
// bFirstCreated = false;
|
|
|
//}
|
|
|
bool side = true;
|
|
|
bool flag = false;
|
|
|
if ((int)_type <= 3)
|
|
|
{
|
|
|
side = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
side = false;
|
|
|
}
|
|
|
_type = value;
|
|
|
|
|
|
if ((int)_type <= 3)
|
|
|
{
|
|
|
if (side)
|
|
|
{
|
|
|
flag = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
flag = true;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (side)
|
|
|
{
|
|
|
flag = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
flag = false;
|
|
|
}
|
|
|
}
|
|
|
if (flag)
|
|
|
{
|
|
|
this.Size = new Size(this.Height, this.Width);
|
|
|
}
|
|
|
ReloadStream();
|
|
|
this.Refresh();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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 > 8)
|
|
|
{
|
|
|
_status = (Statuses)8;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_status = value;
|
|
|
}
|
|
|
if (flag)
|
|
|
{
|
|
|
ReloadStream();
|
|
|
this.Refresh();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 直通状态属性
|
|
|
/// </summary>
|
|
|
public OnOffStatuses ASideStatus
|
|
|
{
|
|
|
get { return this._status == Statuses.csASide ? OnOffStatuses.On : OnOffStatuses.Off; }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 斜通状态属性
|
|
|
/// </summary>
|
|
|
public OnOffStatuses BSideStatus
|
|
|
{
|
|
|
get { return this._status == Statuses.csBSide ? 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 ForkValve_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
if (bFirstCreated == true && this.DesignMode == true)
|
|
|
{
|
|
|
bNewPic = true;
|
|
|
bFirstCreated = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 报警动画处理
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
|
|
{
|
|
|
int ntype = (int)_type;
|
|
|
int nIndex = (int)_status;
|
|
|
string sImage = sImages[ntype, nIndex];
|
|
|
if (String.IsNullOrEmpty(sImage))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
if (sImage.IndexOf("Alarm") > 0)
|
|
|
{
|
|
|
if (String.IsNullOrEmpty(this.tempImage))
|
|
|
{
|
|
|
this.tempImage = sImage.Replace(".png", "2.png");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (this.tempImage.IndexOf("2") > 0)
|
|
|
{
|
|
|
this.tempImage = sImage.Replace("2.png", ".png");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.tempImage = sImage.Replace(".png", "2.png");
|
|
|
}
|
|
|
}
|
|
|
_imageStream = _assembly.GetManifestResourceStream(this.tempImage);
|
|
|
|
|
|
if (this.InvokeRequired)
|
|
|
{
|
|
|
Delegate d = new DRefresh(this.Refresh);
|
|
|
this.BeginInvoke(d);
|
|
|
}
|
|
|
|
|
|
//this.Refresh();
|
|
|
}
|
|
|
}
|
|
|
private delegate void DRefresh();
|
|
|
}
|
|
|
}
|