NeoSwiff的图像按钮

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

最近研究了一下NeoSwiff的SDK.能写出flash的C#语法编译器,太强了!! 他的独立IDE安装文件只有3m.

怀疑是不是有公开的C# 语法分析器......

作者对.net framework很熟悉.虽然它的GDI+与.net略有不同.

我用一个ImageButton扩展System.Windows.Forms.Button控件小试了一下 //ImageButton.ccs

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms; namespace Component

{

public class ImageButton : Button

{

private Image image = null;

private String imagename = "";

public ImageButton()

{

InitializeComponent();

}

private void InitializeComponent()

{

this.Size = new Size(25,25);

}

public String ImageName

{

get { return imagename;}

set { imagename = value;}

}

protected override void OnPaint(PaintEventArgs e)

{

this.Visual.Clear();

this.Visual.ClearStroke();

Visual v = new Visual(this.Visual);

image = new Image(v,imagename);

v.X = (Width - v.Width)/2;

v.Y = (Height - v.Height)/2;

base.OnPaint(e);

}

} } //Form1.ccs

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms; namespace Component

{

public class Form1 : System.Windows.Forms.Form

{

private ImageButton button1 = null;

private Label lbl = null;

public Form1()

{

InitializeComponent(); //

// TODO: Add constructor logic here

//

this.BackColor = Color.WhiteSmoke;

} private void InitializeComponent()

{

this.button1 = new ImageButton();

this.lbl = new Label();

this.SuspendLayout();

//

// button1

//

this.button1.Location = new System.Drawing.Point(50, 50);

this.button1.ImageName = "book";

this.button1.Click += new EventHandler(this.button1_Click); //

// lbl

//

this.lbl.Location = new Point(40,100);

this.lbl.Visible = false;

this.lbl.Text = "Appear!!";

//

// Form1

//

this.Controls.Add(this.button1);

this.Controls.Add(this.lbl);

this.Text = "Form1";

this.ResumeLayout(false);

}

public void button1_Click(object sender, EventArgs e)

{

this.lbl.Visible = ! this.lbl.Visible;

}

static void Main()

{

//

// TODO: Add application logic here

//

Application.Run( new Form1() );

}

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航