using System; using System.Drawing; using System.IO; using System.Reflection; using System.Windows.Forms; namespace Mesnac.Controls.Feeding { [ToolboxBitmap(typeof(ConveyorTube), "Resources.BagOpenStation.bmp")]//新添加的代码 public partial class ConveyorTube : FeedingControl { bool bNewPic = false; //public enum Statuses //{ // rgNull = 0, rgMid = 1, rgFull = 2 //} //Statuses _status; string sImages; public ConveyorTube():base() { InitializeComponent(); Init(); ReloadStream(); } protected override void Init() { base.Init(); _imageStream = null; //sImages = new string[3]; sImages = "Mesnac.Controls.Feeding.Resources.Home.gif";//dkNull //_status = Statuses.rgNull; } private void ReloadStream() { //CloseStream(); //int nIndex = (int)_status; _imageStream = _assembly.GetManifestResourceStream(sImages); if (this.DesignMode == true) { bNewPic = true; } } 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 ConveyorTube_Load(object sender, EventArgs e) { if (bFirstCreated == true && this.DesignMode == true) { bNewPic = true; bFirstCreated = false; } } } }