|
|
|
|
using Mesnac.Controls.Base;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Controls.Default
|
|
|
|
|
{
|
|
|
|
|
[ToolboxBitmap(typeof(TestMCKZY), "Resources.MC_TS.Mc0.png")]
|
|
|
|
|
public partial class TestMCKZY : MCButton
|
|
|
|
|
{
|
|
|
|
|
protected Assembly _assembly = Assembly.GetExecutingAssembly();
|
|
|
|
|
protected Stream _imageStream;
|
|
|
|
|
private List<DesignAction> _clickActionList = new List<DesignAction>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool bNewPic = false;
|
|
|
|
|
string _statusName;
|
|
|
|
|
|
|
|
|
|
public string StatusName
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _statusName;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_statusName = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public enum Statuses
|
|
|
|
|
{
|
|
|
|
|
TurnOff = 0, TurnOn = 3, TurnWarn = 5
|
|
|
|
|
}
|
|
|
|
|
private Statuses _status;
|
|
|
|
|
private string[] sImages;
|
|
|
|
|
public TestMCKZY() : base()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
Init();
|
|
|
|
|
|
|
|
|
|
ReloadStream();
|
|
|
|
|
this.Reload();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
protected void Init()
|
|
|
|
|
{
|
|
|
|
|
_imageStream = null;
|
|
|
|
|
sImages = new string[6];
|
|
|
|
|
sImages[0] = "Mesnac.Controls.Default.Resources.MC_TS.Mc0.png";//zsTurnOn
|
|
|
|
|
sImages[1] = "Mesnac.Controls.Default.Resources.MC_TS.Mc1.png";//zsTurnOn
|
|
|
|
|
sImages[2] = "Mesnac.Controls.Default.Resources.MC_TS.Mc1.png";//zsTurnOn
|
|
|
|
|
sImages[3] = "Mesnac.Controls.Default.Resources.MC_TS.Mc1.png";//zsTurnOn
|
|
|
|
|
sImages[4] = "Mesnac.Controls.Default.Resources.MC_TS.Mc1.png";//zsTurnOn
|
|
|
|
|
sImages[5] = "Mesnac.Controls.Default.Resources.MC_TS.Mc2.png";//zsTurnOn
|
|
|
|
|
//sImages[6] = "Mesnac.Controls.Default.Resources.MC_TS.Mc2.png";//zsTurnOn
|
|
|
|
|
//sImages[7] = "Mesnac.Controls.Default.Resources.MC_TS.Mc2.png";//zsTurnOn
|
|
|
|
|
|
|
|
|
|
this.Text = "";
|
|
|
|
|
_status = Statuses.TurnOff;
|
|
|
|
|
}
|
|
|
|
|
public TestMCKZY(IContainer container)
|
|
|
|
|
{
|
|
|
|
|
container.Add(this);
|
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
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 == 3)
|
|
|
|
|
{
|
|
|
|
|
_status = (Statuses)3;
|
|
|
|
|
}
|
|
|
|
|
else if ((int)value == 5)
|
|
|
|
|
{
|
|
|
|
|
_status = (Statuses)5;
|
|
|
|
|
}
|
|
|
|
|
else if ((int)value == 7)
|
|
|
|
|
{
|
|
|
|
|
_status = (Statuses)5;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_status = value;
|
|
|
|
|
}
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
ReloadStream();
|
|
|
|
|
Reload();
|
|
|
|
|
this.Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void ReloadStream()
|
|
|
|
|
{
|
|
|
|
|
int nIndex = (int)_status;
|
|
|
|
|
_imageStream = _assembly.GetManifestResourceStream(sImages[nIndex]);
|
|
|
|
|
this.BackgroundImage = Image.FromStream(_imageStream);
|
|
|
|
|
this.BackgroundImageLayout = ImageLayout.Stretch;
|
|
|
|
|
}
|
|
|
|
|
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 Reload()
|
|
|
|
|
{
|
|
|
|
|
if (_imageStream != null)
|
|
|
|
|
{
|
|
|
|
|
Image img = Image.FromStream(_imageStream);
|
|
|
|
|
Size size = new Size();
|
|
|
|
|
size.Width = 54;
|
|
|
|
|
size.Height = 10;
|
|
|
|
|
this.Size = size;
|
|
|
|
|
if (bNewPic == true)
|
|
|
|
|
{
|
|
|
|
|
this.Size = size;
|
|
|
|
|
bNewPic = false;
|
|
|
|
|
}
|
|
|
|
|
this.BackgroundImage = img;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#region 事件属性Click
|
|
|
|
|
public List<DesignAction> ClickActionList
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this._clickActionList;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
this._clickActionList = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|