using System; using System.Drawing; using System.IO; using System.Reflection; using System.Windows.Forms; namespace Mesnac.Controls.ChemicalWeighing { /// /// 螺旋给料器左(小) /// [ToolboxBitmap(typeof(LSCREWBIG), "Resources.LSCREW_BIG01.png")] //新添加的代码 public partial class LSCREWBIG : ChemicalWeighingControl { private object _data = new object(); public enum Statuses { ylNormal = 0, ylMove = 1 //, ylAlarm = 2 } Statuses _status; string[] sImages; public LSCREWBIG() : base() { InitializeComponent(); Init(); ReloadStream(); } protected sealed override void Init() { base.Init(); _imageStream = null; sImages = new string[2]; sImages[0] = "Mesnac.Controls.ChemicalWeighing.Resources.LSCREW_BIG01.png"; sImages[1] = "Mesnac.Controls.ChemicalWeighing.Resources.LSCREW_BIGMOVE.gif"; _status = Statuses.ylNormal; } private void ReloadStream() { int nIndex = (int)_status; _imageStream = _assembly.GetManifestResourceStream(sImages[nIndex]); if (_imageStream != null) { Image img = Image.FromStream(_imageStream); pictureBox1.Image = img; pictureBox1.Refresh(); } } public Statuses Status { get => _status; set { if (_status != value) { lock (_data) { _status = value; ReloadStream(); } } } } private void PressureSwitch_Load(object sender, EventArgs e) { } } }