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.
118 lines
2.7 KiB
C#
118 lines
2.7 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 bigLight : SulfControl
|
|
{
|
|
string _statusName;
|
|
bool bNewPic = false;
|
|
public string StatusName
|
|
{
|
|
get
|
|
{
|
|
return _statusName;
|
|
}
|
|
set
|
|
{
|
|
_statusName = value;
|
|
}
|
|
}
|
|
|
|
Statuses _status;
|
|
string[] sImages;
|
|
public bigLight()
|
|
: base()
|
|
{
|
|
InitializeComponent();
|
|
Init();
|
|
ReloadStream();
|
|
}
|
|
|
|
|
|
public enum Statuses
|
|
{
|
|
opne = 1, close = 0
|
|
}
|
|
|
|
protected override void Init()
|
|
{
|
|
base.Init();
|
|
_imageStream = null;
|
|
|
|
sImages = new string[3];
|
|
sImages[0] = "Mesnac.Controls.Sulf.Resources.moniter.Red.png";//close
|
|
sImages[1] = "Mesnac.Controls.Sulf.Resources.moniter.Green.png";//opne
|
|
|
|
}
|
|
|
|
private void ReloadStream()
|
|
{
|
|
int nIndex = (int)_status;
|
|
if (nIndex > 2)
|
|
nIndex = 0;
|
|
_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();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|