NeoSwiff的映像按鈕

來源:互聯網
上載者:User
按鈕
最近研究了一下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() );
}
}
}




相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。