183 lines
4.5 KiB
C#
183 lines
4.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace _29WxOrder.MyControl
|
|
{
|
|
public partial class MyCheckBox : UserControl
|
|
{
|
|
public MyCheckBox()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private int width;
|
|
[Description("控件宽度"), Category("自定义属性")]
|
|
public int SelfWidth
|
|
{
|
|
get
|
|
{
|
|
return width;
|
|
}
|
|
set
|
|
{
|
|
this.width = value;
|
|
this.Width = value;
|
|
}
|
|
}
|
|
|
|
private string text;
|
|
[Description("名称"), Category("自定义属性")]
|
|
public string SelfText
|
|
{
|
|
get
|
|
{
|
|
return text;
|
|
}
|
|
set
|
|
{
|
|
if (value == null)
|
|
{
|
|
this.text = "CheckBox";
|
|
//this.Text = value;
|
|
this.lblShow.Text = "CheckBox";
|
|
}
|
|
else
|
|
{
|
|
this.text = value;
|
|
this.lblShow.Text = value;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private bool MyChecked;
|
|
public bool SelfChecked
|
|
{
|
|
get
|
|
{
|
|
return MyChecked;
|
|
}
|
|
set
|
|
{
|
|
MyChecked = value;
|
|
//if (value)
|
|
//{
|
|
// this.pictureBox.BackgroundImage = Properties.Resources.show;
|
|
//}
|
|
//else
|
|
//{
|
|
// this.pictureBox.BackgroundImage = Properties.Resources.white;
|
|
//}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private Size size = new Size(12, 12);
|
|
[Description("选中框大小"), Category("自定义属性")]
|
|
public Size SelfCheckSize
|
|
{
|
|
get
|
|
{
|
|
return size;
|
|
}
|
|
set
|
|
{
|
|
this.pictureBox.Size = value;
|
|
|
|
}
|
|
}
|
|
|
|
//private System.Drawing.Bitmap img;
|
|
//[Description("选中框背景图"), Category("自定义属性")]
|
|
//public System.Drawing.Bitmap SelfCheckImg
|
|
//{
|
|
// get
|
|
// {
|
|
// return img;
|
|
// }
|
|
// set
|
|
// {
|
|
// if (value == null)
|
|
// {
|
|
// this.pictureBox.BackgroundImage = Properties.Resources.show;
|
|
// }
|
|
// else
|
|
// {
|
|
// this.pictureBox.BackgroundImage = value;
|
|
// }
|
|
|
|
// }
|
|
//}
|
|
|
|
|
|
//private Image _imageItem;
|
|
//[Description("选中图片"), Category("外观")]
|
|
//public Image SelfSelectImage { get { return _imageItem; } }
|
|
|
|
//private string _ImageName;
|
|
//[Description("图片路径"), Category("外观")]
|
|
//public string SelfImageName
|
|
//{
|
|
// get { return _ImageName; }
|
|
// set
|
|
// {
|
|
// _ImageName = value;
|
|
// this._imageItem = Image.FromFile(_ImageName);
|
|
// _ImageName = System.IO.Path.GetFileName(_ImageName);
|
|
// Name = _ImageName;
|
|
// }
|
|
//}
|
|
|
|
|
|
private void MyCheckBox_SizeChanged(object sender, EventArgs e)
|
|
{
|
|
this.SelfWidth = this.Width;
|
|
}
|
|
|
|
private void pictureBox_Click(object sender, EventArgs e)
|
|
{
|
|
if (MyChecked)
|
|
{
|
|
// this.pictureBox.BackgroundImage = Properties.Resources.white;
|
|
MyChecked = false;
|
|
}
|
|
else
|
|
{
|
|
// this.pictureBox.BackgroundImage = Properties.Resources.show;
|
|
MyChecked = true;
|
|
}
|
|
}
|
|
|
|
private void lblShow_Click(object sender, EventArgs e)
|
|
{
|
|
pictureBox_Click(null, null);
|
|
}
|
|
|
|
//新定义组件单击事件
|
|
public new event EventHandler Click
|
|
{
|
|
add
|
|
{
|
|
base.Click += value;
|
|
pictureBox.Click += value;
|
|
lblShow.Click += value;
|
|
}
|
|
remove
|
|
{
|
|
base.Click -= value;
|
|
pictureBox.Click -= value;
|
|
lblShow.Click -= value;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|