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.

131 lines
3.0 KiB
C#

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();
}
}
}
}
}