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.
152 lines
4.1 KiB
C#
152 lines
4.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Mesnac.Controls.Feeding
|
|
{
|
|
/// <summary>
|
|
/// 电机
|
|
/// </summary>
|
|
[ToolboxBitmap(typeof(ElectricMachineryZ), "Resources.dj.djz0.png")]//新添加的代码
|
|
public partial class ElectricMachineryZ : FeedingControl
|
|
{
|
|
#region 事件定义
|
|
|
|
/// <summary>
|
|
/// 报警事件
|
|
/// </summary>
|
|
public event EventHandler OnAlarm;
|
|
|
|
#endregion
|
|
|
|
bool bNewPic = false;
|
|
string _statusName;
|
|
private string _alarmValue;
|
|
private string _alarmValue_;
|
|
|
|
public enum Statuses
|
|
{
|
|
djTurnOff = 0, djTurnOn = 1, djAlarm = 2
|
|
}
|
|
|
|
Statuses _status;
|
|
private System.Windows.Forms.PictureBox pictureBox1;
|
|
string[] sImages;
|
|
public ElectricMachineryZ() : base()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Init();
|
|
|
|
ReloadStream();
|
|
this.Reload();
|
|
}
|
|
private void ReloadStream()
|
|
{
|
|
//CloseStream();
|
|
int nIndex = (int)_status;
|
|
_imageStream = _assembly.GetManifestResourceStream(sImages[0 + nIndex]);
|
|
}
|
|
protected override void Init()
|
|
{
|
|
base.Init();
|
|
sImages = new string[3];
|
|
sImages[0] = "Mesnac.Controls.Feeding.Resources.dj.djz0.png";//zsTurnOn
|
|
sImages[1] = "Mesnac.Controls.Feeding.Resources.dj.djz1.gif";//zsTurnOff
|
|
sImages[2] = "Mesnac.Controls.Feeding.Resources.dj.djz2.gif";//zsAlarm
|
|
|
|
_status = Statuses.djTurnOff;
|
|
}
|
|
|
|
private void Reload()
|
|
{
|
|
if (_imageStream != null)
|
|
{
|
|
Image img = Image.FromStream(_imageStream);
|
|
|
|
if (bNewPic == true)
|
|
{
|
|
this.Size = img.Size;
|
|
bNewPic = false;
|
|
}
|
|
pictureBox1.Image = img;
|
|
pictureBox1.Refresh();
|
|
}
|
|
}
|
|
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 > 2)
|
|
{
|
|
_status = (Statuses)2;
|
|
}
|
|
else
|
|
{
|
|
_status = value;
|
|
}
|
|
if (flag)
|
|
{
|
|
ReloadStream();
|
|
this.Reload();
|
|
|
|
if (_status == Statuses.djAlarm)
|
|
{
|
|
this._alarmValue_ = this._alarmValue; //设置报警信息
|
|
}
|
|
else
|
|
{
|
|
this._alarmValue_ = String.Empty; //清空报警信息
|
|
}
|
|
//有事件订阅者,则触发报警事件
|
|
if (OnAlarm != null)
|
|
{
|
|
OnAlarm(this, System.EventArgs.Empty);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ElectricMachineryZ_Load(object sender, EventArgs e)
|
|
{
|
|
if (bFirstCreated == true && this.DesignMode == true)
|
|
{
|
|
bNewPic = true;
|
|
bFirstCreated = false;
|
|
|
|
Reload();
|
|
}
|
|
}
|
|
}
|
|
}
|