Your SlideShare is downloading. ×
Ajax World 08 Silverlight2 Overview
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Ajax World 08 Silverlight2 Overview

867
views

Published on

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
867
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Note: this a very demo heavy talk, so I will not be going through All these slides… they are here for reference only Microsoft Silverlight cross-browser cross-platform cross-device Silverlight 2 Technical Overview Plug-in for building and delivering the next generation of .NET based Brad Abrams Product Unit Manager Microsoft media experiences BradA@Microsoft.com and http://blogs.msdn.com/BradA rich interactive applications for the Web Why Silverlight? Silverlight is a .NET technology Server, Desktop Services Server Desktop & Services .NET Devices, Devices, Browser Browser Mobile Mobile Rich Experiences Silverlight extends your .NET Reach. Silverlight Benefits Why Silverlight Matters at AjaxWorld? • Silverlight and Ajax – Many applications will use BOTH! • Silverlight: • Media • UX • Consistency between client/server programming models • Local storage, FileDialogs, cross-domain networking • Ajax: • Ajax code manipulating Silverlight UI elements • C#VB code in Silverlight manipulating HTML DOM elements © 2007 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.
  • 2. Silverlight Components Data Controls .NET for Silverlight Server Silverlight 1 Silverlight 2 LINQ LINQ-to-XML Extensible Controls Web Services ASP.NET AJAX Libs REST Legend Dynamic Languages BCL POX RSS <asp:xaml> JSON Ruby Python Generics Collections SOAP <asp:media> Common Language Runtime XAML Media and User Interface UI Core Inputs Media Controls DRM 2D Vectors Images Keyboard WMV / VC1 Layout Media Animation Transforms Mouse WMA Editing Text Ink MP3 Presentation Core Integrated DOM JavaScript Networking Installer Integration Engine Stack Browser Host Presentation Core – Graphics Presentation Core - Video Quality Interactivity • 2D Graphics •High Definition video •Video is a first class • Vector based •VC-1 codec citizen • Standard shapes and Paths •H.264 (Silverlight 3) •Media Markers • Masking and clipping •Adaptive streaming •Video brush • Transformations: skew, rotate, scale, translate, matrix Cost of ownership Formats •Windows Media Server • Animation Basics •Byte range seeking •Video: VC-1, WMV v7,v8,v9 • Time-based •Audio: WMA V7, V8, V9, •Windows Live Streaming • Support linear, discrete and spline animation MP3, WMA 10 Pro, H.264 •Throttling (with IIS7) • Animatable property types: • Double, Color, Point Content protection • Animations and graphics can be defined using XAML or code •PlayReady DRM for online • H.264 viewing IIS7 Media Pack Highlights Declarative Programming Through XAML Extensive Application Markup Language Bitrate Throttling Web Playlists • Toolable, declarative markup • Code and content are separate • Control how much media is • Client-side playlist with • Compatible with Windows Presentation Foundation sent to clients. server-side state. • Auto-detects encoded bitrate • Client cannot alter state. of video file. XAML C# VB.NET <Button Width=quot;100quot;> OK Button b1 = new Button(); Dim b1 As New Button <Button.Background> b1.Content = quot;OKquot;; b1.Content = quot;OKquot; LightBlue b1.Background = new b1.Background = New _ </Button.Background> SolidColorBrush(Colors.LightBlue); SolidColorBrush(Colors.LightBlue) </Button> b1.Width = 100; b1.Width = 100 © 2007 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.
  • 3. Controls Styling • Property bag setting to define look & feel • Microsoft ships the basic set of controls • Ship with source • Modeled after WPF controls • Extensible • Rich partner ecosystem for domain specific controls Templating Data Templates • Replace the ‘parts’ that define the look of a control to create a class Car completely different look, but behavior is the same. { string Image {get;set} string Model {get;set] } <DataTemplate x:Key=quot;carTemplatequot;> <Border BorderBrush=quot;Bluequot; BorderThickness=quot;2quot; Background=quot;LightGrayquot; Margin=quot;10quot; Padding=quot;15,15,15,5quot;> <StackPanel> <Image HorizontalAlignment=quot;Centerquot; Source=quot;{Binding Path=Image}quot; /> <Border HorizontalAlignment=quot;Centerquot; BorderBrush=quot;Navyquot; Background=quot;#DDF“ BorderThickness=quot;1quot; Margin=quot;10quot; Padding=quot;3quot;> <TextBlock FontSize=quot;18quot; TextContent=quot;{Binding Path=Model}quot; /> </Border> </StackPanel> </Border> </DataTemplate> Databinding DeepZoom • Two way data binding from User interface to business objects • Navigates images of any size and resolution optimizing • Notification via INotifyPropertyChanged network bandwidth and download size. • DataContext is inherited via Visual Tree • Seamless transitions as you zoom and pan. • From XAML • <TextBlock Text=quot;{Binding Nasdaq.Points, Mode=OneWay}quot;/> • From code Binding binding = new Binding(quot;Nasdaq.Pointsquot;); binding.Mode = BindingMode.OneWay; TextBlock tb = new TextBlock(); tb.SetBinding(TextBlock.TextProperty, binding); © 2007 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.
  • 4. Refactoring .NET .NET, Base Class Library, Dynamic CLR LINQ Dynamic Language Run-time • Open Source engine and languages • LINQ = Language INtegrated Query • Allows query expressions to benefit from compile-time syntax • Script Server (Chiron) for local development. checking, static typing & Intellisense • Debugging support • Works on any IEnumerable<T>-based source class App: def __init__(self): • Supports querying of in-memory data sources self.scene = Application.Current.LoadRootVisual(quot;app.xamlquot;) def start(self): • Other LINQ technologies forthcoming: self.scene.Message.Text = quot;Welcome to Silverlight and IronPython!quot; App().start() • XLINQ = LINQ for XML • DLINQ = LINQ for relational data class App def initialize @scene = System::Windows::Application.Current.LoadRootVisual quot;app.xamlquot; end Return all players with more than twenty home runs, sorted def start @scene.find_name('message').text = quot;Welcome to Silverlight and IronRuby!quot; end end App.new.start var filteredPlayers = from p in players where p.HomeRuns > 20 Import(quot;System.Windows.Applicationquot;) orderby p.HomeRuns descending function App() { this.scene = Application.Current.LoadRootVisual(quot;app.xamlquot;) } select p; App.prototype.start = function() { this.scene.Message.Text = quot;Welcome to Silverlight and Managed JScript!quot; } app = new App app.start() Networking • Asynchronous HTTP requests • GET/POST • Access to most headers, cookies, • Uses browser networking stack • Caching, authentication, proxy, compression Networking • Cross-domain support via policy file © 2007 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.
  • 5. Cross-domain support Web Services <?xml version=quot;1.0quot;?> • 2 formats: <!DOCTYPE cross-domain-policy SYSTEM • SOAP 1.1 • Flash policy file quot;http://www.macromedia.com/xml/dtds/cross-domain- • Basic profile policy.dtdquot;> • Silverlight policy file <cross-domain-policy> • A few restrictions (e.g. SOAP Faults not supported) <allow-access-from domain=quot;*quot; /> • Asynchronous invocation </cross-domain-policy> • Follows cross-domain policy restrictions Cross-domain.xml • Generated proxies support data binding <?xml version=quot;1.0quot;?> <access-policy> <cross-domain-access> <policy> <allow-from> <domain uri=quot;http://customers.shop.com”/>quot; <domain uri=quot;http://partner.com/app.xapquot;/> </allow-from> <grant-to> <grant path=quot;/sales/serialnumbers.xmlquot; /> <grant path=quot;/partnersquot; include-subpaths=quot;falsequot;/> </grant-to> </policy> </cross-domain-access> </access-policy> clientaccesspolicy.xml Sockets • TCP only • Asynchronous API • No explicit bind and no listen/accept support • Restricted ports ( 4502-4534) • For Beta1, site of origin only, cross-domain for RTW void Connect(AddressFamily family) { SocketAsyncEventArgs connectArgs = new SocketAsyncEventArgs(); Extending the Browser Sandbox (safely) connectArgs.RemoteEndPoint = new DnsEndPoint( Application.Current.Host.Source.Host, 4502); connectArgs.Completed += new EventHandler<SocketAsyncEventArgs>(OnConnectCompleted); socket = new Socket(family, SocketType.Stream, ProtocolType.Tcp); if (!socket.ConnectAsync(connectArgs)) OnConnectCompleted(socket, connectArgs); } OpenFileDialog Isolated Storage • Provides native OS experience • Stream based access to a private file/directory structure • Sandboxed API returns safe filename and readable stream • Patterned after .NET Framework IsolatedStorage classes • Read and write string or binary data • Support for multiple files • Store is per application XAP • Application code to request size increase • User prompt to accept quota increase • Quotas fall into predetermined size slots • Code must initiate increase size call from within user input/event // Create file dialog OpenFileDialog ofd= new OpenFileDialog(); ofd.Filter = quot;Text Files (*.txt)|*.txt|All files (*.*)|*.*quot;; if (ofd.ShowDialog() == DialogResult.OK) { © 2007 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.
  • 6. HTML/AJAX and .NET integration webpage HTML Silverlight HTML and Silverlight Integration webpage HTML + Silverlight Access the HTML DOM from Managed Working with HTML/Javascript Code HTML access available in new namespace ScriptObject using System.Windows.Browser; Static HtmlPage class provides entry point HtmlPage.Navigate(quot;http://www.microsoft.comquot;); HtmlObject String server = HtmlPage.DocumentUri.Host; Hookup events, call methods, or access properties HtmlElement HtmlElement myButton = HtmlPage.Document.GetElementByID(quot;myButtonIDquot;); myButton.AttachEvent(quot;onclickquot;, new EventHandler(this.myButtonClicked)); HtmlDocument HtmlWindow private void myButtonClicked(object sender, EventArgs e) { ... } Access Managed Code from JavaScript 1.- Mark a property, method or event as [Scriptable] [ScriptableMember] public void Search(string Name) { ... } 2.- Register a scriptable object HtmlPage.RegisterScriptableObject (quot;EntryPointquot;, this); Tooling and .NET platform 3.- Access the managed object from script var control = document.getElementById(quot;SilverlightControlquot;); control.Content.EntryPoint.Search(input.value); © 2007 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.
  • 7. Designer/Developer Collaboration Tooling Server Vista Desktop Server, Services XAML Designer Developer Look, behavior, brand, Function, deployment, data, and emotional connection security, operational integrity Media & RIA Silverlight Tools for Visual Studio 2008 -100% Free (as in free beer) -Full development experience (from data to Web Services to client UI to debugging) -Does not require Windows on the web server or on client OS Silverlight in the .NET platform Silverlight and ASP.NET/AJAX Integration Silverlight and WPF • Two ASP.NET server controls • Silverlight is a subset of WPF • Both ship in SDK: System.Web.Silverlight.dll • Plus a few extra web features and its own codecs • Deploys to /bin folder • Reuse strategy • Available at design-time within Visual Studio • Same skills • Corresponding AJAX types • Same tools • Both server controls provide client-side Javascript types as well • Same XAML and UI • Silverlight code should run on WPF with minor changes © 2007 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.
  • 8. More Information: http://silverlight.net Silverlight and .NET: Better Together • Highly productive development framework • Multi-language support • Latest developer innovations (e.g. LINQ, Generics) • AJAX integration • Great tools • Visual Studio • Expression Studio • Cross-platform & cross-browser plugin • Works with Safari, Firefox and Internet Explorer • Mac OS X and Windows • Any web server • Fast, easy install process • Securely extends your web browser’s sandbox • Off-line storage, OpenFileDialog, Sockets, cross-domain THANK YOU! © 2007 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. More details Content Protection © 2007 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.
  • 9. Isolated Storage Quota Byte-range Seeking Support // Use application for storage scope (EG URL where application is from www.microsoft.com/silverlight/app.xap and any DLLs loaded into this app domain) • Enables seeking to non-downloaded portions of a file stored IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication(); on *any* HTTP 1.1-enabled web server. // The application knows it needs at least 5MB of isolated storage space int spaceNeeded = 524288; // = 512K in bytes • Win-win for content distributors and viewers // Check to see how much space is remaining • Distributors save on bandwidth on non-viewed parts of media. if (isf.RemainingSize < spaceNeeded) { • Viewers get smaller latencies when seeking. // Request more quota space. This call will not work if not called from a WPF event • When Seek is called on the MediaElement if (!isf.IncreaseQuotaTo(isoStore.Quota + spaceNeeded)) { • New byte-range request is made, if needed; // The host did not allow the quota increase, meaning we do not have • Silverlight keeps track of downloaded portions of the file; // enough isolated storage space to do what we want; do not continue. • Playback continues from new position. return; } } • Supported almost everywhere. // We have at least 512K of isolated storage space available. // Proceed with using it... // NOTE it is possible the host allocated more than 512K of space // ... // Find out what the new quota is Debug.WriteLine(quot;New quota size quot; + isf.Quota.ToString() ); Microsoft Confidential Isolated Storage Dictionary WebClient • Dictionary access for settings • Wraps low level IsolatedStorage • Easy to use, events-based async • Values are serialized using the WCF Data Contract serializer • Download string, stream LocalSettings localSettings = new LocalSettings(); • Progress information //Add key, value pair localSettings.Add(“Title”,”Programming in Silverlight”); //Add key,value using indexer localSettings [“Price”] = 15; webClient.DownloadStringCompleted //Add key, value using Set method += new DownloadStringCompletedEventHandler(DownloadCompleted); localSettings.Set(“Price”, 15); webClient.DownloadProgressChanged //Confirm is a key exists and then retrieve its value += new DownloadProgressChangedEventHandler(DownloadProgressChanged); if(localSettings.Contains(Title)) webClient.DownloadStringAsync(quot;http://www.data.com/data.xmlquot;); title = (string) localSettings[“Title”]; ... //Remove key from store localSettings.Remove(“Price”) void DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) // Explicitly commit settings. Also committed when object goes out of { scope Stream stream = e.Result; localSettings.Save(); // Use stream Microsoft Confidential } HTTP Restrictions: Details HttpWebRequest/Response • HTTP GET and POST • No PUT, DELETE, … • Primary API for HTTP/HTTPS • Greater control (GET & POST, headers, etc) • Setting headers on HTTP GET: only same domain • Response headers: can only read Content-Type private void MakeAsyncRequest() { HttpWebRequest request = (HttpWebRequest) • Response codes: only success/fail WebRequest.Create(quot;http://foo.com/api?token=89quot;); • No 403/404/etc, no message body IAsyncResult asyncResult = request.BeginGetResponse( new AsyncCallback(ResponseCallback), request); • Redirects: Work (may be blocked in cross-domain) } private void ResponseCallback(IAsyncResult ar) • Cannot override the browser { • Can’t control / turn off caching HttpWebRequest request = ar.AsyncState as HttpWebRequest; WebResponse response = request.EndGetResponse(ar); • Can’t control HTTP Authentication credentials Stream responseStream = response.GetResponseStream(); • Can’t read/write cookies // Use stream • Can’t control HTTPS Client-Side Certificates } • Can’t read HTTPS Server-Side Certificates © 2007 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.
  • 10. Working with HTML/Javascript Working with HTML/Javascript • Scriptability • Scriptable type interoperability • Expose managed properties/methods/events to Javscript • Primitive types marshal by-value in both directions • ScriptableType and ScriptableMember indicate managed • Complex managed types are returned by-reference to Javascript entry points on a type • Javascript types usually must be copied into equivalent managed • HtmlPage.RegisterScriptableObject types prior to being passed in to managed code. • Name of the scriptable entry point • Uses JSON serialization • Managed instance that backs the entry point • Can pass Javascript types by-reference as instances of • Scriptable entry points are exposed off the Content property ScriptObject of your Silverlight control. • myControl.Content.CustomName.SomeManagedPropertyOrMethod Working with HTML/Javascript • Scriptable type interoperability • Can return HtmlWindow, HtmlDocument and HtmlElement instances directly to Javascript • Managed arrays act like Javascript arrays • Custom managed types act like Javascript objects • Custom managed dictionaries also act like Javascript objects • Converting Javascript object graphs to managed objects: • Use createManagedObject helper method that is automatically attached to each scriptable entry point © 2007 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.