46
- IronRuby の活用 -

- IronRuby の活用div id="outArea1" > # イベントハンドラの関数定義 (DLR/helloworld.rb) end

Embed Size (px)

Citation preview

Page 1: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

- IronRuby の活用 -

Page 2: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

1.0 を 2010 年 4 月にリリース 祝

Page 3: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

<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>

おもしろい

Page 4: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

IronRuby on .NET 2.0

IronRuby on .NET 4

IronRuby on Silverlight = >

Page 5: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 6: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 7: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 8: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

<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>

Page 9: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

dlr.js

<script type="text/javascript" src="http://gestalt.ironpython.net/dlr-latest.js"> </script>

Page 10: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

<script type="text/ruby"> window.alert "ルビーで表示します" </script> <script type="text/python"> window.Alert("Pythonで表示します") </script>

Page 11: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

<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>

似てるよねー = おもしろくない?

Page 12: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 13: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

<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>

Page 14: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 15: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 16: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

<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

Page 17: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

<script type="application/x-zip-compressed" src="ライブラリのZIPファイル名"> </script> <script type="text/ruby"> require “アーカイブ/ライブラリ名" # Pythonであれば import アーカイブ.ライブラリ名 </script>

Page 18: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 19: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 20: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

<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>

Page 21: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 22: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

<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>

Page 23: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

<script type="application/xml+xaml" id="inlineXaml" width="400" height="400"> XAMLコンテンツを記述 </script>

Page 24: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 25: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

<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>

Page 26: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 27: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 28: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

html

head

body

object silverlightDLRObject1

object silverlightDlrObject_DOMOnly

Page 29: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 30: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

<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>

Page 31: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

defer=“true”

Page 32: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 33: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

html dlr.js dlr.xap

text/ ruby

Page 34: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

type id src class defer width height

application/xml-xaml

必須 オプション 不要 オプション 必須

text/python オプション XAML を使用する場合は必須」

不要 (内部では 1に固定)

text/ruby

application/x-zip-compressed

必須 (拡張子はzip)

不要

Page 35: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

dlr.xap Appmanifest.xaml languages.config

Microsoft.Scripting.slvx DynamicApplication

ホスト関係のアセンブリ

IronPython.slvx 言語アセンブリ

IronRuby.slvx 言語アセンブリ

Page 36: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 37: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 38: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 39: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 40: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

Ruby などで Silverlight アプリを開発できる環境を実現したもの 組合わせは自由です サーバー RoR 、クライアント RIA とか アイディア次第で RIA ができます

Page 41: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 42: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

じゃ、なくて

Page 43: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end
Page 46: - IronRuby の活用div id="outArea1" >   # イベントハンドラの関数定義 (DLR/helloworld.rb) end

© 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.