Introducing Silverlight 2 - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Introducing Silverlight 2

Description:

Windows, Mac OS, Linux ('Moonlight') Internet Explorer, Firefox, Safari, and more. XAML-based rendering (subset of WPF XAML) Implemented as browser plug-in ... – PowerPoint PPT presentation

Number of Views:64
Avg rating:3.0/5.0
Slides: 24
Provided by: downloadM
Category:

less

Transcript and Presenter's Notes

Title: Introducing Silverlight 2


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
ltCanvas Width"300" Height"300"
xmlns"http//schemas.microsoft.com/client/2007"
xmlnsx"http//schemas.microsoft.com/winfx/2006/
xaml"gt ltEllipse Canvas.Left"20"
Canvas.Top"20" Height"200" Width"200"
Stroke"Black" StrokeThickness"10" Fill"Yellow"
/gt ltEllipse Canvas.Left"80" Canvas.Top"80"
Height"35" Width"25" Stroke"Black"
Fill"Black" /gt ltEllipse Canvas.Left"140"
Canvas.Top"80" Height"35" Width"25"
Stroke"Black" Fill"Black" /gt ltPath Data"M
70, 150 A 60, 60 0 0 0 170, 150"
Stroke"Black" StrokeThickness"15"
StrokeStartLineCap"Round" StrokeEndLineCap"Round
" /gt lt/Canvasgt
7
XAML DOM
lthtmlgt ltbodygt ... ltdiv
id"SilverlightDiv"gt lt/divgt
... lt/bodygt lt/htmlgt
Web page
Silverlight control
Canvas
Canvas
TextBlock
XAML objects
Other Objects
8
Naming XAML Objects
  • Use xName attributes to assign names to XAML
    objects (analogous to IDs in ASP.NET)

ltRectangle Canvas.Left"50" Canvas.Top"50"
Fill"Yellow" Width"300" Height"200"
Stroke"Black" StrokeThickness"10"
xName"YellowRect" /gt
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 (lt 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.Wind
ows.Input System.Windows.Interop System.Windows.Me
dia System.Windows.Shapes System.Windows.Threading
System System.Collections System.Collections.Gener
ic System.Diagnostics System.Globalization System.
IO System.IO.- IsolatedStorage System.Reflection
System.Security System.Security.Cryptography Syst
em.Text System.Threading
System.- Windows
mscorlib
System.- Windows.- Browser
System.Windows.Browser
System
System.- Core
System.Linq System.Linq.Expressions System.Runtime
.CompilerServices System.Security.Cryptography
System.- Xml
System System.Collections.Generic System.Component
Model System.Diagnostics System.Text.RegularExpres
sions
System.Xml System.XmlSchema System.Xml.Serializati
on
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/t
he-silverlight-security-model.aspx
14
Transparency Model
Application
All user code is untrusted and can only call into
other ST code or SSC
SecurityTransparent
Silverlight
SSC layer provides gateway to SC code
SecuritySafeCritical
SC layer P/Invokes into underlying OS
SecurityCritical
Operating System
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
ltRectangle Canvas.Left"50" Canvas.Top"50"
Fill"Yellow" Width"300" Height"200"
Stroke"Black" StrokeThickness"10"
MouseLeftButtonDown"OnClick" /gt
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.Docum
ent.AttachEvent("onmousewheel",
OnMouseWheelTurned) ... private void
OnMouseWheelTurned(Object sender, HtmlEventArgs
args) double delta 0 ScriptObject e
args.EventObject if (e.GetProperty("wheel
Delta") ! 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 gt 0 if wheel rolled forward, delta
lt 0 if wheel rolled backward if (delta !
0) args.PreventDefault()
e.SetProperty("returnValue", false)
22
Event Handling
23
Discussion
Write a Comment
User Comments (0)
About PowerShow.com