md2010 jl-wp7-sl-dev

33
Zagreb, 23. rujna 2010.

Upload: jose-millas

Post on 22-Apr-2015

1.356 views

Category:

Documents


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Md2010 jl-wp7-sl-dev

Zagreb, 23. rujna 2010.

Page 2: Md2010 jl-wp7-sl-dev

Developing WP7 Apps with Silverlight

José Luis LatorreMicrosoft MVP, UX Specialist & Brainsiders CEOhttp://silverlightguy.com

Page 3: Md2010 jl-wp7-sl-dev
Page 4: Md2010 jl-wp7-sl-dev

Generalni sponzori:

Glavni sponzori:

Sponzori:

Organizatori:

Medijski sponzori: Strateški partneri:

Službena PR agencija:

Generalni medijski sponzor:

Page 5: Md2010 jl-wp7-sl-dev

Application Framework details

Common Base Class Library

Collections ComponentModel Configuration

DiagnosticsReflection IO

Security Threading

Runtime Resources Globalization TextLocation Net

ServiceModel Linq

Application Object

Silverlight Presentation and Media

XNA Frameworks for Games

Windows Phone Frameworks

NavigationShapes Markup Media

Controls Drawing IsolatedStorage

AudioMedia GraphicsInput

Drawing GamerServices

Content

PhoneApplicationPage

PushNotification

WebBrowserControl

SensorsPhoneApplicationFra

me

CameraDevice

IntegrationLaunchers &

ChoosersWindows Phone

Controls

Page 6: Md2010 jl-wp7-sl-dev

What is Silverlight?

Powerful Development Platform

Engaging, Interactive User Experiences

Page 7: Md2010 jl-wp7-sl-dev

Silverligh capabilities

Inputs

• Keyboard• Mouse• Touch• Ink

Media

• Digital media capture & playback• VC1, WMA, MP3

Data• Language Integrated Query (LINQ)• LINQ to XML• XML• IsolatedStorageBase Class Library (BCL)• Generics• Collections• Cryptography• Threading

Windows Communication Foundation

• REST• RSS/ATOM• SOAP

XAMLUI Core• Vector• Animation• Text• Images

Page 8: Md2010 jl-wp7-sl-dev

What Silverlight version do we have?

Performance tuning

Input integration

H/W media and sensor integration

OS application model integration

Relaxed sandbox constraints

It is Silverlight 3 but adding:

Page 9: Md2010 jl-wp7-sl-dev

What makes Silverlight so Special?

MXeXtensible

A LApplication Markup Language

XML

Declarative Markup

<Grid> <TextBlock FontSize="48" Text="Hello world" /></Grid>

Page 10: Md2010 jl-wp7-sl-dev

What makes Silverlight so Special?

CodeXAML

XAML maps to code

Anything in XAML can be done in code

Page 11: Md2010 jl-wp7-sl-dev

Silverligth App Model - What’s a XAP?

Tools

Common format for all Windows Phone apps & games

Declarative, manifest-based installation

Integrated into security model of phone

myapp.xap

Page 12: Md2010 jl-wp7-sl-dev

An overview of a Silverlight app for WP7

Page 13: Md2010 jl-wp7-sl-dev

Windows Phone application

Application

Frame

Page 3Page 1 Page 2

Page 14: Md2010 jl-wp7-sl-dev

Silverlight Controls

• Conforming to Metro Design Guidelines.• Consistent Look & Feel.• Familiar to existing Silverlight developers.• They adapt to the current Theme.

Page 15: Md2010 jl-wp7-sl-dev

OUTPUT

Page 16: Md2010 jl-wp7-sl-dev

Media

• Media support– H/W decode– MediaStreamSource– PlayReady DRM

• XNA framework sound effect API– Supports polyphony and looping

• MediaElement– Only supports one MediaElement for page– VideoBrush is not supported

Page 17: Md2010 jl-wp7-sl-dev

XNA for Windows Phone 7

• Using XNA audio capabilities is needed– Using namespace Microsoft.Xna.Framework.Audio– Together with SoundEffect and SoundEffectInstance– Adding the Wav sound file as a content element to the

project.

// AudioSoundEffect soundEffect; string soundName = "kaboom";

// Loading and playing audiosoundEffect = contentManager.Load<SoundEffect>(soundName); soundEffect.Play();

Page 18: Md2010 jl-wp7-sl-dev

Vibration

• Makes the phone vibrate during a specific duration– Useful for giving a tactile response to the user.– To notify users of an update.

VibrateController vc = VibrateController.Default;vc.Start(TimeSpan.FromSeconds(3));

Microsoft.Devices.Sensors

Page 19: Md2010 jl-wp7-sl-dev

INPUT

Page 20: Md2010 jl-wp7-sl-dev

SIP I

• SIP Stands for Software Input Panel.• The TextBox Silverlight control integrates with SIP• SIP supports around 60 different InputScopes:

Page 21: Md2010 jl-wp7-sl-dev

SIP II

• SIP can be personalized with several versions of the keyboard that the user can select between.

• But the application can also show the optimum keyboard.

• We use InputScope to do that, for example:<TextBox Grid.Row="1" Name="tbNombre" Text=""> <TextBox.InputScope> <InputScope> <InputScopeName NameValue="PersonalGivenName"></InputScopeName> </InputScope> </TextBox.InputScope></TextBox>

Page 22: Md2010 jl-wp7-sl-dev

A Silverlight “Hello World” for WP7(link to demo)

Page 23: Md2010 jl-wp7-sl-dev

Accelerometer

• Measures force applied on each axis over time.

+Y

-Y

+X-X

+Z

-Z

Page 24: Md2010 jl-wp7-sl-dev

Accelerometer I

• Getting data from the Accelerometer1. Add a refference to Microsoft.Devices.Sensors2. Add the corresponding using

3. Declare the variable AccelerometerSensor

4. Get an instance of the AccelerometerSensor

using Microsoft.Devices.Sensors;

AccelerometerSensor accelerometer;

if (accelerometer == null) { sensor accelerometer = new AccelerometerSensor();}

+Y

-Y

+X-X

+Z

-Z

Page 25: Md2010 jl-wp7-sl-dev

Accelerometer II

• Getting data from the Accelerometer5. Suscribe to the event ReadingChanged

6. Create the event handler

7. Initialize the accelerometer

accelSensor.ReadingChanged += new EventHandler<AccelerometerReadingAsyncEventArgs>(AccelerometerReadingChanged);

public void AccelerometerReadingChanged(object sender, AccelerometerReadingAsyncEventArgs e){ accelReading.X = (float)e.Value.Value.X; accelReading.Y = (float)e.Value.Value.Y; accelReading.Z = (float)e.Value.Value.Z;}

Accelsensor.Start();

+Y

-Y

+X-X

+Z

-Z

Page 26: Md2010 jl-wp7-sl-dev

OS INTEGRATION

Page 27: Md2010 jl-wp7-sl-dev

Application Bar & Context Menu

• The «Application Bar» is a control system that provides a quick addition of a tool bar for our WP7 application.

• Apart from the Application Bar, applications can provide additional options like showing one or more menu elements.

Microsoft.Phone.Shell

Page 28: Md2010 jl-wp7-sl-dev

Application Bar & Context Menu

• By default we have a sample XAML Code for quickly enabling this features on our applications:

<phone:PhoneApplicationPage.ApplicationBar> <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True"> <shell:ApplicationBarIconButton IconUri=“/appbar_button1.png" Text="Button 1"/> <shell:ApplicationBarIconButton IconUri=“/appbar_button2.png" Text="Button 2"/> <shell:ApplicationBar.MenuItems> <shell:ApplicationBarMenuItem Text="MenuItem 1"/> <shell:ApplicationBarMenuItem Text="MenuItem 2"/> </shell:ApplicationBar.MenuItems> </shell:ApplicationBar></phone:PhoneApplicationPage.ApplicationBar>

Page 29: Md2010 jl-wp7-sl-dev

Navigation: Frame and Page

• Frame – Is the topmost container control.– PhoneApplicationFrame class.– Contains the page control and sytsem

elements, like System Tray, app bar, etc..

• Page– Fills the entire content region of the

Frame.– Derives from the class

PhoneApplicationPage.– Contains a title.– Can have its own application bar.

Page 30: Md2010 jl-wp7-sl-dev

Orientation

• In VS2010 we can add a Landscape Page or a Portrait Page.

• The only difference is on the property SupportedOrientation which can be:– Portrait– Landscape– PortraitOrLandscape

• We can’t change the page orientation in code.• But we can react to its changes through the

OrientationChanged event.

Page 31: Md2010 jl-wp7-sl-dev

Silverlight Toolkit(link to demo)

Page 32: Md2010 jl-wp7-sl-dev