软件设计模式复习题(12)

2020-11-29 00:35

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;


软件设计模式复习题(12).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:二年级100以内加减乘除混合口算题(100题1页)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: