ironruby

via IronRuby アルファのリリース – 荒井省三のBlog


ironrubyのアルファ試してみた。

require 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

class Form1 < System::Windows::Forms::Form
  def layout
    p "layout"
    self.SuspendLayout
    yield
    self.ResumeLayout
  end

  def initialize
    p "initialize"
    self.Name = self.Text = "Form1"

    layout{
      button1 = System::Windows::Forms::Button.new
      button1.Name = button1.Text = "button1"
      button1.UseVisualStyleBackColor = true;
      button1.Click{
        p "click!"
      }
      self.Controls.Add(button1)
    }
  end

  def Dispose(disposing)
    p disposing
  end
end

System::Windows::Forms::Application.EnableVisualStyles
System::Windows::Forms::Application.SetCompatibleTextRenderingDefault(false)
System::Windows::Forms::Application.Run(Form1.new)

これが普通に動いた!素敵!
フォームが出てボタンクリックするとちゃんとコンソールにメッセージが出るよ。


まえに試した時はp位のメソッドから使えなかった気がしたけど今回は余裕です。
まあRailsがちらっと動くくらいの勢いらしいので当たり前かもだけど。


ボタンのイベント直にブロックいけるとかはナイスだよね。
Disposeは良く分からないつーか.Netが良く分からない。
けどでも応援したい気持ちになりました。