public Form1(){
InitializeComponent(); init();}
private void init() {
cdec = new CoolDecorator (btButtonA);
this.Controls.AddRange(new System.Windows.Forms.Control[] {cdec, cqdec});
this.Controls.Remove (btButtonA); }
[STAThread]
static void Main() {
Application.EnableVisualStyles();//实现高亮显示 Application.Run(new Form1());}} CoolDecorator组件类: namespace CoolDec{
public class CoolDecorator :Panel, Decorator{ protected Control contl;
protected Pen bPen, wPen, gPen; private bool mouse_over=false; protected float x1, y1, x2, y2;
public CoolDecorator(Control c) { contl = c;
this.Controls.AddRange(new Control[] {contl}); locate(c.Location );
http://www.77cn.com.cn = "deco"+http://www.77cn.com.cn ; this.Size = contl.Size; x1 = c.Location.X - 1; y1 = c.Location.Y - 1; x2 = c.Size.Width; y2 = c.Size.Height;
gPen = new Pen(c.BackColor, 2); bPen = new Pen(Color.White , 1); wPen = new Pen(Color.Black, 1);
c.MouseDown += new MouseEventHandler(mouseDown); c.Paint += new PaintEventHandler( paint);} public void locate(Point p){ this.Location = p;
contl.Location = new Point(0, 0); x1 = p.X; y1 = p.Y;}
public void mouseDown(object sender, EventArgs e){ mouse_over = true; this.Refresh();}
public virtual void paint(object sender, PaintEventArgs e){ Graphics g = e.Graphics;