Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introducing Silverlight 2. Agenda Silverlight architecture XAML CoreCLR The Silverlight Base Class Library Silverlight security Your first Silverlight.

Similar presentations


Presentation on theme: "Introducing Silverlight 2. Agenda Silverlight architecture XAML CoreCLR The Silverlight Base Class Library Silverlight security Your first Silverlight."— Presentation transcript:

1 Introducing Silverlight 2

2 Agenda Silverlight architecture XAML CoreCLR The Silverlight Base Class Library Silverlight security Your first Silverlight application Mouse and keyboard handling

3 Silverlight Formerly known as "WPF/E" Microsoft's platform for rich, highly interactive Web experiences and RIAs –Cross-platform (browsers and OSes) Windows, Mac OS, Linux ("Moonlight") Internet Explorer, Firefox, Safari, and more –XAML-based rendering (subset of WPF XAML) Implemented as browser plug-in –Quick, easy install experience

4 Versions Silverlight 1.0 –Shipped September 2007 –XAML rendering and JavaScript API Silverlight 2 –Beta 2 currently available –XAML,.NET Framework, managed code, dynamic languages (e.g., IronRuby) –Ships in 2008

5 Silverlight Architecture

6 XAML <Canvas Width="300" Height="300" xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Ellipse Canvas.Left="20" Canvas.Top="20" Height="200" Width="200" Stroke="Black" StrokeThickness="10" Fill="Yellow" /> <Ellipse Canvas.Left="80" Canvas.Top="80" Height="35" Width="25" Stroke="Black" Fill="Black" /> <Ellipse Canvas.Left="140" Canvas.Top="80" Height="35" Width="25" Stroke="Black" Fill="Black" /> <Path Data="M 70, 150 A 60, 60 0 0 0 170, 150" Stroke="Black" StrokeThickness="15" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />

7 XAML DOM...... Canvas TextBlock Other Objects Web page Silverlight control XAML objects

8 Naming XAML Objects Use x:Name attributes to assign names to XAML objects (analogous to IDs in ASP.NET) <Rectangle Canvas.Left="50" Canvas.Top="50" Fill="Yellow" Width="300" Height="200" Stroke="Black" StrokeThickness="10" x:Name="YellowRect" /> Object can now be referred to as "YellowRect" in code

9 The Silverlight 2 CLR ("CoreCLR") Refactored version of full-size CLR –Same core type system, JIT compiler, etc. –COM interop, remoting, binary serialization, server GC, and other features removed –CAS replaced with transparency model –Multiple CLR instances per process supported –Most globalization support pushed down to OS –Dynamic Language Runtime (DLR) added Small footprint (< 2MB), cross-platform

10 The CoreCLR Diet Replace CAS Remove code pages etc. Remove COM interop Remove remoting Remove server GC 293K 217K 188K 111K 33K

11 Core Base Class Library System.Windows System.Windows.Controls System.Windows.Input System.Windows.Interop System.Windows.Media System.Windows.Shapes System.Windows.Threading System.Windows.Browser System System.Collections System.Collections.Generic System.Diagnostics System.Globalization System.IO System.IO.- IsolatedStorage System.Reflection System.Security System.Security.Cryptography System.Text System.Threading System System.Collections.Generic System.ComponentModel System.Diagnostics System.Text.RegularExpressions System.Linq System.Linq.Expressions System.Runtime.CompilerServices System.Security.Cryptography System.Xml System.XmlSchema System.Xml.Serialization

12 Extended Base Class Library

13 Silverlight 2 Security All code is "sandboxed" Sandboxing built on transparency model –Transparent: user code (untrusted) –Security-critical: platform code (can P/Invoke) –Security-safe-critical: platform code (entry points into security-critical code) For more information: http://blogs.msdn.com/shawnfa/archive/2007/05/09/the-silverlight-security-model.aspx

14 Transparency Model Application SecurityTransparent Silverlight SecuritySafeCritical SecurityCritical Operating System All user code is untrusted and can only call into other ST code or SSC SSC layer provides gateway to SC code SC layer P/Invokes into underlying OS

15 Your First Silverlight Application

16 Input Events XAML objects input fire events –Mouse events –Keyboard events Most input events "bubble up" XAML DOM –Also known as "event routing" –Use RoutedEventArgs.Handled controls routing –RoutedEventArgs.Source refers to originator Handlers can be registered declaratively or programmatically

17 Mouse Events private void OnMouseLeftButtonDown(Object sender, MouseButtonEventArgs e) { double x = e.GetPosition(null).X); // X-coordinate double y = e.GetPosition(null).Y); // Y-coordinate }

18 Keyboard Events private void OnKeyDown(Object Sender, KeyEventArgs e) { HtmlPage.Window.Alert(e.Key.ToString()); // Display key code }

19 Declarative Handler Registration <Rectangle Canvas.Left="50" Canvas.Top="50" Fill="Yellow" Width="300" Height="200" Stroke="Black" StrokeThickness="10" MouseLeftButtonDown="OnClick" /> private void OnClick(Object sender, MouseButtonEventArgs e) { ((Rectangle)sender).Fill = new SolidColorBrush(Colors.Red); }

20 Mouse Wheel Events Silverlight doesn't fire mouse wheel events Mouse wheel events can be handled directly from browser (even in managed code) –Use Silverlight browser integration features Handle DOM events in managed code –Requires manual handling of differences in ways browsers report mouse wheel events Great for mouse wheel zooms and other features

21 Processing Mouse Wheel Input HtmlPage.Window.AttachEvent("DOMMouseScroll", OnMouseWheelTurned); HtmlPage.Window.AttachEvent("onmousewheel", OnMouseWheelTurned); HtmlPage.Document.AttachEvent("onmousewheel", OnMouseWheelTurned);... private void OnMouseWheelTurned(Object sender, HtmlEventArgs args) { double delta = 0; ScriptObject e = args.EventObject; if (e.GetProperty("wheelDelta") != null) // IE and Opera { delta = ((double)e.GetProperty("wheelDelta")); if (HtmlPage.Window.GetProperty("opera") != null) delta = -delta; } else if (e.GetProperty("detail") != null) // Mozilla delta = -((double)e.GetProperty("detail")); // delta > 0 if wheel rolled forward, delta < 0 if wheel rolled backward if (delta != 0) { args.PreventDefault(); e.SetProperty("returnValue", false); }

22 Event Handling

23 Discussion


Download ppt "Introducing Silverlight 2. Agenda Silverlight architecture XAML CoreCLR The Silverlight Base Class Library Silverlight security Your first Silverlight."

Similar presentations


Ads by Google