ruby & python with silverlight o rly? ya rly!

18
Ruby and Python with Silverlight: Martha Rotter Microsoft Ireland Developer and Platform Group [email protected] O RLY? YA RLY!

Upload: martha-rotter

Post on 09-May-2015

3.034 views

Category:

Technology


5 download

DESCRIPTION

Introduction to Silverlight and dynamic languages

TRANSCRIPT

Page 1: Ruby & Python with Silverlight O RLY? YA RLY!

Ruby and Python with Silverlight:

Martha RotterMicrosoft Ireland

Developer and Platform Group

[email protected]

O RLY?YA RLY!

Page 2: Ruby & Python with Silverlight O RLY? YA RLY!

For Today:

•What is Silverlight?•What does Silverlight look like?•Ruby + Python + ??? on Silverlight

Page 3: Ruby & Python with Silverlight O RLY? YA RLY!

But first…

D00d what iz silverlight?!?!?!1

Page 4: Ruby & Python with Silverlight O RLY? YA RLY!

eXstensible Application Markup Language• Declarative Language – Just XML

• Describes the look and feel• Generated by Microsoft Expression tools

• Designer / Developer Workflow• No More Mockups or Wireframes

• Runtime Format• “Skinable” UI

Page 5: Ruby & Python with Silverlight O RLY? YA RLY!

XAML Basics

• You can create drawings directly with XAML

• XAML is made up of Tags• Represent a single item or container of the design

• E.g. Rectangle, Ellipse, Canvas, Storyboard, etc.• Not all Tags are design elements (e.g. animations)

Page 6: Ruby & Python with Silverlight O RLY? YA RLY!

Example XAML

• For example:

<Canvas xmlns="..." xmlns:x="..."> <Rectangle Width="200" Height="150" Fill="Black" /> <Ellipse Width="200" Height="150" Stroke="Orange" /></Canvas>

<Canvas xmlns="..." xmlns:x="..."> <Rectangle Width="200" Height="150" Fill="Black" /> <Ellipse Width="200" Height="150" Stroke="Orange" /></Canvas>

Page 7: Ruby & Python with Silverlight O RLY? YA RLY!

Common XAML Elements• Basic Vocabulary of Tags

• Canvas• Brushes• Basic shapes

• Rectange, Ellipse, Line, Polygon, etc.• TextBlock• Image

• No Controls in Silverlight 1.0

Page 8: Ruby & Python with Silverlight O RLY? YA RLY!

DEMOS

Page 9: Ruby & Python with Silverlight O RLY? YA RLY!

Silverlight Developer’s Toolkit

Page 10: Ruby & Python with Silverlight O RLY? YA RLY!

Silverlight Architecture

XAMLXAMLXAMLXAML

Browser Host

Integrated Networking

Stack

DOM Integration

InstallerJavaScript

Engine

Presentation Core

.NET for Silverlight

Inputs

KeyboardMouseInk

Media

WMV / VC1WMAMP3

ControlsLayout

Editing

UI Core

2D VectorsAnimatio

nText

ImagesTransfor

ms

DRM

Media

Dynamic LanguagesRuby Python

BCL

Generics

Collections

Web Services

RESTRSS

SOAP

POXJSON

Data

LINQ LINQ-to-XML

WPF for SilverlightExtensible

Controls

Common Language Runtime

ASP.NET AJAX Libs<asp:xaml><asp:media>

ServerSilverlight

1.0Silverlight

1.1

Legend

Page 11: Ruby & Python with Silverlight O RLY? YA RLY!

<Script <Script src=“Silverlight.js”/>src=“Silverlight.js”/><Script <Script src=“Default.html.js”/>src=“Default.html.js”/><Script <Script src=“Scene.xaml.js”/>src=“Scene.xaml.js”/>

Web BrowserWeb Browser

Web PageWeb Page

Silverlight HostSilverlight Host

UIUI LogicLogic

<div id="SilverlightPlugInHost"> <script type="text/javascript">

createSilverlight();

HTMLHTML

Page 12: Ruby & Python with Silverlight O RLY? YA RLY!

Helper JavaScript in SDK

Page 13: Ruby & Python with Silverlight O RLY? YA RLY!

Web Page<html xmlns="http://www.w3.org/1999/xhtml"><head>

<title>My Silverlight Application</title>

<script type="text/javascript" src="Silverlight.js"></script><script type="text/javascript" src="Default.html.js"></script><script type="text/javascript" src="Scene.xaml.js"></script>

</head>

<body><div id="SilverlightPlugInHost">

<script type="text/javascript">createSilverlight();

</script></div>

</body></html>

Page 14: Ruby & Python with Silverlight O RLY? YA RLY!

createSilverlight()function createSilverlight(){ Silverlight.createObject( "plugin.xaml", // Source property value. parentElement, // DOM reference to hosting DIV tag. "myPlugin", // Unique plug-in ID value. { // Plug-in properties. width:'1024', // Width of rectangular region of plug-in in pixels. height:'530', // Height of rectangular region of plug-in in pixels. inplaceInstallPrompt:false, // Determines whether to display in-place install prompt if invalid

version is detected. background:'white', // Background color of plug-in. isWindowless:'false', // Determines whether to display plug-in in windowless mode. framerate:'24', // MaxFrameRate property value. version:'1.0' // Silverlight version. }, { onError:null, // OnError property value -- event-handler function name. onLoad:null // OnLoad property value -- event-handler function name. }, null, // initParams -- user-settable string for information passing. null); // Context value -- passed to Silverlight.js onLoad event handlers.}

Page 15: Ruby & Python with Silverlight O RLY? YA RLY!

createSilverlightExfunction createSilverlightEx(){ Silverlight.createObjectEx({ source: 'plugin.xaml', // Source property value. parentElement:parentElement, // DOM reference to hosting DIV tag. id:'myPlugin', // Unique plug-in ID value. properties:{ // Plug-in properties. width:'1024', // Width of rectangular region of plug-in in pixels. height:'530', // Height of rectangular region of plug-in in pixels. inplaceInstallPrompt:false, // Determines whether to display in-place install prompt if invalid version

is detected. background:'white', // Background color of plug-in. isWindowless:'false', // Determines whether to display plug-in in windowless mode. framerate:'24', // MaxFrameRate property value. version:'1.0'}, // Silverlight version. events:{ onError:null, // OnError property value -- event-handler function name. onLoad:null}, // OnLoad property value -- event-handler function name. initParams:null, // initParams property value -- user-settable string for information passing. context:null}); // Context value -- passed to Silverlight.js onLoad event handlers.}

Page 16: Ruby & Python with Silverlight O RLY? YA RLY!

Programming a Silverlight-Based Application with a Dynamic Language• Root html page which calls your createSilverlight

method

• CreateSilverlight.js (implementation of parameterless createSilverlight method to start your application)

• Silverlight.js (defines createObject & createObjectEx methods)

• pageName.xaml (UI of your application)

• pageName.xaml.py (code behind the UI) Compiled & executed at runtime

Page 17: Ruby & Python with Silverlight O RLY? YA RLY!

DEMOS

Page 18: Ruby & Python with Silverlight O RLY? YA RLY!

The Future…

ExamplesCOUNT!!1HAI CAN HAS STDIO? I HAS A VAR IM IN YR LOOP UP VAR!!1 VISIBLE VAR IZ VAR BIGGER THAN 10? KTHXBYE IM OUTTA YR LOOP KTHXBYE

FILEZORZ: HAI CAN HAS STDIO? PLZ OPEN FILE "LOLCATS.TXT"? AWSUM THX VISIBLE FILE O NOES INVISIBLE "ERROR!" KTHXBYE