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.

149 lines
3.9 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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;
namespace Mesnac.Controls.Intake
{
/// <summary>
/// 压送罐
/// </summary>
[ToolboxBitmap(typeof(PressureTank), "ICONS.PressureTank.bmp")]
public partial class PressureTank : BaseIntakeControl
{
#region 枚举状态定义压送罐有6个状态0为空,4为满,5为报警
public enum Statuses
{
ssNull = 0,
ssValue1 = 1, ssValue2 = 2, ssValue3 = 3, ssFull = 4,
ssAlarm = 5
}
#endregion
#region 字段定义
private bool bNewPic = false;
private string _statusName;
private Statuses _status;
private string[] sImages;
#endregion
public PressureTank(): base()
{
InitializeComponent();
Init();
ReloadStream();
}
protected override void Init()
{
base.Init();
_imageStream = null;
sImages = new string[6];
sImages[0] = "Mesnac.Controls.Intake.Resources.PressureTank.ysg0.png";//ysgNull
sImages[1] = "Mesnac.Controls.Intake.Resources.PressureTank.ysg1.png";
sImages[2] = "Mesnac.Controls.Intake.Resources.PressureTank.ysg2.png";
sImages[3] = "Mesnac.Controls.Intake.Resources.PressureTank.ysg3.png";
sImages[4] = "Mesnac.Controls.Intake.Resources.PressureTank.ysg4.png";//ysgFull
sImages[5] = "Mesnac.Controls.Intake.Resources.PressureTank.ysgalarm.png";
_status = Statuses.ssValue2; //初始值
}
private void ReloadStream()
{
int nIndex = (int)_status;
_imageStream = _assembly.GetManifestResourceStream(sImages[nIndex]);
}
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 &&(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 > 5)
{
_status = (Statuses)5;
}
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 (bNewPic == true)
{
this.Size = img.Size;
bNewPic = false;
}
g.DrawImage(img, 0, 0, this.Width, this.Height);
}
}
private void PressureTank_Load(object sender, EventArgs e)
{
if (bFirstCreated == true && this.DesignMode == true)
{
bNewPic = true;
bFirstCreated = false;
}
}
}
}