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.

129 lines
3.4 KiB
C#

1 year ago
using System;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
namespace Mesnac.Controls.Feeding
{
/// <summary>
/// 支管(三通)
/// </summary>
[ToolboxBitmap( typeof( SideTube ) , "ICONS.SideTube.bmp" )]//新添加的代码
public partial class SideTube : FeedingControl
{
bool bNewPic = false;
public enum Types
{
btLeft = 0, btRight = 1, btUp = 2, btDown = 3
}
Types _type;
string [] sImages;
public SideTube():base()
{
InitializeComponent();
Init();
ReloadStream();
}
protected override void Init()
{
base.Init();
_imageStream = null;
sImages = new string[ 4 ];
sImages[ 0 ] = "Mesnac.Controls.Feeding.Resources.st.STJ3.png";//
sImages[ 1 ] = "Mesnac.Controls.Feeding.Resources.st.STJ2.png";//
sImages[ 2 ] = "Mesnac.Controls.Feeding.Resources.st.STJ0.png";//
sImages[ 3 ] = "Mesnac.Controls.Feeding.Resources.st.STJ1.png";//
_type = Types.btLeft;
}
private void ReloadStream()
{
//CloseStream();
int nIndex = (int)_type;
_imageStream = _assembly.GetManifestResourceStream(sImages[nIndex]);
}
public Types Type
{
get
{
return _type;
}
set
{
if (bFirstCreated == true)
{
bFirstCreated = false;
}
bool flag = false;
if (_type != value)
{
flag = true;
if (this.DesignMode == true)
{
bNewPic = true;
}
}
_type = value;
if (flag)
{
ReloadStream();
this.Refresh();
}
}
}
protected override void OnPaint(PaintEventArgs e)
{
if (_imageStream != null)
{
Graphics g = e.Graphics;
Image img = Image.FromStream(_imageStream);
//if (_type == Types.btLeft)
//{
// //img.RotateFlip(RotateFlipType.
//}
//else if (_type == Types.btRight)
//{
// img.RotateFlip(RotateFlipType.RotateNoneFlipX);
//}
//else if (_type == Types.btUp)
//{
// img.RotateFlip(RotateFlipType.Rotate90FlipNone);
//}
//else if (_type == Types.btDown)
//{
// img.RotateFlip(RotateFlipType.Rotate270FlipNone);
//}
if (bNewPic == true)
{
this.Size = img.Size;
bNewPic = false;
}
g.DrawImage(img, 0, 0, this.Width, this.Height);
}
}
private void SideTube_Load(object sender, EventArgs e)
{
if (bFirstCreated == true && this.DesignMode == true)
{
bNewPic = true;
bFirstCreated = false;
}
}
}
}