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.

154 lines
4.3 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(LargeTank), "ICONS.LargeTank.bmp")]
public partial class LargeTank : BaseIntakeControl
{
#region 枚举状态定义大罐有11个状态0为空,10为满
public enum Statuses
{
ssNull = 0,
ssValue1 = 1, ssValue2 = 2, ssValue3 = 3, ssValue4 = 4, ssValue5 = 5, ssValue6 = 6, ssValue7 = 7, ssValue8 = 8, ssValue9 = 9,
ssFull = 10
}
#endregion
#region 字段定义
private bool bNewPic = false;
private string _statusName;
private Statuses _status;
private string[] sImages;
#endregion
public LargeTank(): base()
{
InitializeComponent();
Init();
ReloadStream();
}
protected override void Init()
{
base.Init();
_imageStream = null;
sImages = new string[11];
sImages[0] = "Mesnac.Controls.Intake.Resources.LargeTank.dg0.png";//dgNull
sImages[1] = "Mesnac.Controls.Intake.Resources.LargeTank.dg1.png";
sImages[2] = "Mesnac.Controls.Intake.Resources.LargeTank.dg2.png";
sImages[3] = "Mesnac.Controls.Intake.Resources.LargeTank.dg3.png";
sImages[4] = "Mesnac.Controls.Intake.Resources.LargeTank.dg4.png";
sImages[5] = "Mesnac.Controls.Intake.Resources.LargeTank.dg5.png";
sImages[6] = "Mesnac.Controls.Intake.Resources.LargeTank.dg6.png";
sImages[7] = "Mesnac.Controls.Intake.Resources.LargeTank.dg7.png";
sImages[8] = "Mesnac.Controls.Intake.Resources.LargeTank.dg8.png";
sImages[9] = "Mesnac.Controls.Intake.Resources.LargeTank.dg9.png";
sImages[10] = "Mesnac.Controls.Intake.Resources.LargeTank.dg10.png";//dgFull
_status = Statuses.ssValue5; //初始值
}
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 > 10)
{
_status = (Statuses)10;
}
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 LargeTank_Load(object sender, EventArgs e)
{
if (bFirstCreated == true && this.DesignMode == true)
{
bNewPic = true;
bFirstCreated = false;
}
}
}
}