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.

204 lines
4.9 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Controls.Feeding
{
public partial class StraightTubeNew : FeedingControl
{
public enum Types
{
ptLeftToRight = 0,
ptRightToLeft = 1,
}
public enum Statuses
{
ptTurnOff = 0,
ptTurnOn = 1
}
#region 变量
Types _type;
Statuses _status;
string[] sImages;
private string _master;
string _statusName;
//int iWidth=45;
//int iHeight=5;
#endregion
#region 属性
public string StatusName
{
get
{
return _statusName;
}
set
{
_statusName = value;
}
}
public Types Type
{
get
{
return _type;
}
set
{
if (bFirstCreated == true)
{
bFirstCreated = false;
}
_type = value;
ReloadStream();
this.Reload();
}
}
public Statuses Status
{
get
{
return _status;
}
set
{
if (bFirstCreated == true)
{
bFirstCreated = false;
}
if ((int)value < 0)
{
_status = (Statuses)0;
}
else if ((int)value > 1)
{
_status = (Statuses)0; //报警时plc值大于1这时应该设置不流动
}
else
{
_status = value;
}
ReloadStream();
this.Reload();
}
}
[TypeConverter(typeof(StringListConverterStraightTube2))]
public string Master
{
get
{
return _master;
}
set
{
_master = value;
}
}
#endregion
public StraightTubeNew() : base()
{
InitializeComponent();
Init();
ReloadStream();
this.Reload();
}
#region 方法
public void SetStatus(OnoffValve.Statuses s)
{
switch (s)
{
case OnoffValve.Statuses.zsTurnOn:
_status = Statuses.ptTurnOn;
break;
case OnoffValve.Statuses.zsTurnOff:
_status = Statuses.ptTurnOff;
break;
default:
break;
}
ReloadStream();
this.Reload();
}
protected override void Init()
{
base.Init();
_imageStream = null;
_type = Types.ptLeftToRight;
this._status = Statuses.ptTurnOff;
sImages = new string[3];
sImages[0] = "Mesnac.Controls.Feeding.Resources.zg.ZGHBlack1.gif";//
sImages[1] = "Mesnac.Controls.Feeding.Resources.zg.ZGHBlack2.gif";//
sImages[2] = "Mesnac.Controls.Feeding.Resources.zg.StraightTubeNew1.png";//
}
private void ReloadStream()
{
//CloseStream();
int iType = (int)_type;
int iStatus = (int)_status;
string img = this.sImages[2];
if (this._status == Statuses.ptTurnOn)
{
if (this._type == Types.ptLeftToRight)
{
img = this.sImages[0];
}
else
{
img = this.sImages[1];
}
}
//_imageStream = _assembly.GetManifestResourceStream( sImages[ 2 * iStatus + iType / ( iStatus + 1 ) ] );
_imageStream = _assembly.GetManifestResourceStream(img);
}
private void Reload()
{
if (_imageStream != null)
{
Image img = Image.FromStream(_imageStream);
pictureBox1.Image = img;
pictureBox1.Refresh();
}
}
private void StraightTubeH_Load(object sender, EventArgs e)
{
if (bFirstCreated == true && this.DesignMode == true)
{
bFirstCreated = false;
ReloadStream();
Reload();
}
}
#endregion
private void StraightTubeH_Resize(object sender, EventArgs e)
{
this.Height = 5;
}
}
}