- IronRuby の活用div id="outArea1" > # イベントハンドラの関数定義...
-
Upload
trinhhuong -
Category
Documents
-
view
231 -
download
2
Transcript of - IronRuby の活用div id="outArea1" > # イベントハンドラの関数定義...
- IronRuby の活用 -
1.0 を 2010 年 4 月にリリース 祝
<head> <title>Hello Active Script Ruby</title> <script language= "RubyScript" > @doc = @window.document def click(btn) @doc.all(btn).value = btn + " is here" end </script> </head> <body onload="@windows.alert 'Body is loaded !'" language= "RubyScript" > <input type= "button" id= "btn1" onclick= "click('btn1')" language= "RubyScript" > <input type= "button" id= "btn2" onclick= "@doc.all('btn2').value='btn2 is here'" language= "RubyScript" > </body> </html>
おもしろい
IronRuby on .NET 2.0
IronRuby on .NET 4
IronRuby on Silverlight = >
<head> <title>ハローワールド by Gestalt</title> <script type="text/javascript" src="http://gestalt.ironpython.net/dlr-latest.js"> </script> </head> <body> <h1>初めてのゲシュタルト</h1> <script type="text/ruby"> window.alert "ルビーで表示します" </script> <script type="text/python"> window.Alert("Pythonで表示します") </script> </body> </html>
dlr.js
<script type="text/javascript" src="http://gestalt.ironpython.net/dlr-latest.js"> </script>
<script type="text/ruby"> window.alert "ルビーで表示します" </script> <script type="text/python"> window.Alert("Pythonで表示します") </script>
<script type= "text/ruby" > window.alert "ルビーで表示します" </script>
<script language= "RubyScript" > @doc = @window.document def click(btn) @doc.all(btn).value = btn + " is here" end </script>
似てるよねー = おもしろくない?
<p>メッセージ:<input type="text" id="txtMessage" /></p> <input type="button" id="btnRun" value="実行します"/> <p>結果:</p><div id="outArea1"></div><div id="outArea2"></div> <script type="text/ruby"> # イベントハンドラの関数定義 document.btnRun.onclick do |s, e| document.outArea1.html = document.txtMessage.value + "byruby" end # rubyでは、innerHtml も html の指定も可能 </script> <script type="text/python"> def click(s, e): # イベントハンドラの関数定義 msg = document.txtMessage.value + " by Python" window.Alert(msg) document.outArea2.innerHtml = document.txtMessage.value + " by Python" # イベントハンドラを関連付ける document.btnRun.events.onclick += click </script>
<h1>ハローワールド改2</h1> <p>メッセージ:<input type="text" id="txtMessage" /></p> <input type="button" id="btnRun" value="実行します" /> <p>結果:</p> <div id="outArea1" ></div><div id="outArea2" ></div> <script type="text/ruby" src="DLR/helloworld.rb"> </script> <script type="text/python" src="DLR/helloworld.py"> </script>
# イベントハンドラの関数定義 (DLR/helloworld.rb) document.btnRun.onclick do |s, e| document.outArea1.html = document.txtMessage.value + " by ルビー" end
<script type="application/x-zip-compressed" src="ライブラリのZIPファイル名"> </script> <script type="text/ruby"> require “アーカイブ/ライブラリ名" # Pythonであれば import アーカイブ.ライブラリ名 </script>
<head> <title>Ruby コンソール デバッグ用</title> <script type="text/javascript"> window.DLR = {settings: {console: true, debug: true}} </script> <script type="text/javascript" src="http://gestalt.ironpython.net/dlr-latest.js" > </script> </head> <body> <h1>デバッグ シナリオ</h1> <div id="message">Loading ...</div> <script type="text/ruby"> document.message.html = "こんにちは、Rubyです!" </script> </body>
<script type="application/xml+xaml" id="inlineXaml" width="400" height="400"> <Canvas xmlns="http://.../winfx/2006/xaml/presentation" xmlns:x="http://.../winfx/2006/xaml"> <TextBlock HorizontalAlignment="Center" Height="23" Width="Auto" FontSize="18" Text="ハローワールド XAML 版"/> <TextBlock HorizontalAlignment="Right" Width="78" Height="23" Margin="10" Text="メッセージ:"/> <TextBox x:Name="txtMessage" Width="248" Height="25" HorizontalAlignment="Center" /> <Button x:Name="btnRun" HorizontalAlignment="Left" Width="93" Height="29" Content="実行します"/> <!– 省略しています --> </Canvas> </script>
<script type="application/xml+xaml" id="inlineXaml" width="400" height="400"> XAMLコンテンツを記述 </script>
<body> <h1>ハローワールド XAML版 改(Ruby)</h1> <script type="application/xml+xaml" id="externalXaml" src="DLR/HelloWorld.xaml" width="400" height="300"> </script> <!-- ポイントは、xamlタグのidをclassに設定すること --> <script type="text/ruby" class="externalXaml"> root = xaml.hellocanvas root.txtMessage.text = "てすと" # イベントハンドラを設定します root.btnRun.click { |s ,e| root.outArea.text = root.txtMessage.text + " by ルビー" } </script> </body>
html
head
body
object silverlightDLRObject1
object silverlightDlrObject_DOMOnly
<body> <h1>ハローワールド XAML版 改(Ruby)</h1> <script type="application/xml+xaml" id= "internalXaml" defer=“true” width= "400" height= "300" > XAMLを記述 </script> <!-- ポイントは、xamlタグのidをclassに設定すること --> <script type="text/ruby" class= " internalXaml"> include Microsoft::Scripting::Silverlight app = DynamicApplication.Current root = app.LoadRootVisualFromString( document.externalXaml.innerHTML) root.txtMessage.text = "てすと" # イベントハンドラを設定します root.btnRun.click { |s ,e| root.outArea.text = root.txtMessage.text + " by ルビー" } </script> </body>
defer=“true”
html dlr.js dlr.xap
text/ ruby
type id src class defer width height
application/xml-xaml
必須 オプション 不要 オプション 必須
text/python オプション XAML を使用する場合は必須」
不要 (内部では 1に固定)
text/ruby
application/x-zip-compressed
必須 (拡張子はzip)
不要
dlr.xap Appmanifest.xaml languages.config
Microsoft.Scripting.slvx DynamicApplication
ホスト関係のアセンブリ
IronPython.slvx 言語アセンブリ
IronRuby.slvx 言語アセンブリ
Ruby などで Silverlight アプリを開発できる環境を実現したもの 組合わせは自由です サーバー RoR 、クライアント RIA とか アイディア次第で RIA ができます
じゃ、なくて
http://gestalt.ironpython.net/dlr-latest.js
http://visitmix.com/labs/gestalt/downloads/xaml.playground.html
http://visitmix.com/labs/gestalt/http://www.ironpython.net/browser/
http://ironpython.net/browser/docs.html
http://www.silverlight.net/learn/dynamic-languages/
http://ironpython.codeplex.com/http://ironruby.codeplex.com/http://gestalt.codeplex.com/
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market
conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.
MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.