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; namespace Mesnac.Controls.Sulf { public partial class Valve : SulfControl { bool bNewPic = false; string _statusName; public string StatusName { get { return _statusName; } set { _statusName = value; } } Statuses _status; string[] sImages; public Valve() : base() { InitializeComponent(); Init(); ReloadStream(); } public enum Statuses { opne = 1, close = 0 } Types _types; public Types Types1 { get { return _types; } set { _types = value; } } public enum Types { 内压蒸汽进 = 15, 热水进 = 14, 热水回 = 13, 热水回5bar = 12, 热水回0bar = 11, 抽真空 = 10, 一次水进 = 9, 热水回1 = 8 } protected override void Init() { base.Init(); _imageStream = null; sImages = new string[3]; sImages[0] = "Mesnac.Controls.Sulf.Resources.moniter.valveclose.jpg";//close sImages[1] = "Mesnac.Controls.Sulf.Resources.moniter.valveopen.jpg";//opne _status = Statuses.close; } private void ReloadStream() { int nIndex = (int)_status; _imageStream = _assembly.GetManifestResourceStream(sImages[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); } } public Statuses Status { get { return _status; } set { 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(); } } } } }