文档介绍:C# WinForm 自定义控件开发实例
最近做一个图象的采集,需要一个图形的选择控件,但 ,所以考虑了自己 写一个控件。下面我将从头创建控件,这个控件主要是用来 选择图形的Rectangle有ReSizeble=value; this」nvalidate(); } } [Description(”控件选择区域 "),Category("Behavior")] public Rectangle SelectRectangle { get { Rectangle selectRectangler=new Rectangle();
= +7; = +7; = -15; = -15; return selectRectangler; } } protected override void
OnPaint(PaintEventArgs pe) { // Calling the base class
OnPaint (pe);
ReDrawControl(); } private void DrawSelector(Graphics graphics) { SolidBrush SelectorPen=new SolidBrush(); Pen borderPen=new Pen(,1); try { //
实心 PointF[] LeftPoints=getPointF(0,-3,6,6);
(SelectorPen, LeftPoints);
PointF[] TopPoints=getPointF(-3,0,6,6); (SelectorPen, TopPoints);
PointF[] RightPoints=getPointF(-7,-3,6,6); (SelectorPen, RightPoints);
PointF[] BottomPoints=getPointF(-3,-7,6,6); (SelectorPen, BottomPoints);
PointF[] LeftTopPoints=getPointF(0,0,6,6); (SelectorPen, LeftTopPoints);
PointF[] RightTopPoints=getPointF(-7,0,6,6); (SelectorPen, RightTopPoints);
PointF[] RightBottomPoints=getPointF(-7,-7,6,
6); (SelectorPen, RightBottomPoints); PointF[] LeftBottomPoints=getPointF(0,-7,6,6); (SelectorPen, LeftBottomPoints); //边框 = 0;
= -3; = 6; = 6;
(borderPen, _rectLeftSelector); = -3;
= 0; = 6; = 6;