72

What Web Developers Need to Know to Develop Windows 8 Apps

Embed Size (px)

DESCRIPTION

You already have a Web app on the Internet and want to reach customers with a new, targeted experience on Windows 8. Come get practical guidance and best practices on how to reuse your Web assets. Come dive into the specifics of this exciting platform and see how you can use your Web skills to build deeply-integrated Windows apps. ◦You’ll discover how this mirrors or differs from traditional Web programming and how to harness the rich capabilities of Windows 8 through JavaScript and the Windows Runtime. ◦You'll learn practical techniques on how to access a web service, how to work with camera, and how to make live tiles, etc. ◦Expect a lot of code and demo. This session will jump start you with everything you need to know to start building Windows 8 apps with the skills you already have.

Citation preview

Page 1: What Web Developers Need to Know to Develop Windows 8 Apps
Page 2: What Web Developers Need to Know to Develop Windows 8 Apps

twitter #wins8camp http://bit.ly/wins8cheatsheet Blog http://blogs.msdn.com/dorischen

Who am I? Developer Evangelist at Microsoft based in Silicon Valley, CA

Blog: http://blogs.msdn.com/b/dorischen/

Twitter @doristchen

Email: [email protected]

Office Hours http://ohours.org/dorischen

Has over 15 years of experience in the software industry focusing on web technologies

Spoke and published widely at JavaOne, O'Reilly, Silicon Valley Code Camp, SD West, SD Forum and worldwide User Groups meetings

Doris received her Ph.D. from the University of California at Los Angeles (UCLA)

PAGE 2

Page 3: What Web Developers Need to Know to Develop Windows 8 Apps

Blog http://blogs.msdn.com/dorischen

Page 4: What Web Developers Need to Know to Develop Windows 8 Apps

As of March 2012, IDC

Page 5: What Web Developers Need to Know to Develop Windows 8 Apps

http://bit.ly/win8cards

Page 6: What Web Developers Need to Know to Develop Windows 8 Apps
Page 7: What Web Developers Need to Know to Develop Windows 8 Apps

twitter #wins8camp http://bit.ly/wins8cheatsheet Blog http://blogs.msdn.com/dorischen PAGE 8

Page 8: What Web Developers Need to Know to Develop Windows 8 Apps
Page 9: What Web Developers Need to Know to Develop Windows 8 Apps

Blog http://blogs.msdn.com/dorischen

Page 10: What Web Developers Need to Know to Develop Windows 8 Apps

demo

Page 11: What Web Developers Need to Know to Develop Windows 8 Apps
Page 12: What Web Developers Need to Know to Develop Windows 8 Apps

Blog http://blogs.msdn.com/dorischen PAGE

13

Page 13: What Web Developers Need to Know to Develop Windows 8 Apps

twitter #wins8camp http://bit.ly/wins8cheatsheet Blog http://blogs.msdn.com/dorischen PAGE 14

Page 14: What Web Developers Need to Know to Develop Windows 8 Apps

twitter #wins8camp http://bit.ly/wins8cheatsheet Blog http://blogs.msdn.com/dorischen PAGE 15

Page 15: What Web Developers Need to Know to Develop Windows 8 Apps
Page 16: What Web Developers Need to Know to Develop Windows 8 Apps

/* Re-arrange and hide/show content */

/* */

/* …*/

/* …*/

Full screen

Snap

Fill

Portrait

PAGE 18

Page 17: What Web Developers Need to Know to Develop Windows 8 Apps

demo

Page 18: What Web Developers Need to Know to Develop Windows 8 Apps
Page 19: What Web Developers Need to Know to Develop Windows 8 Apps

twitter #wins8camp http://bit.ly/wins8cheatsheet Blog http://blogs.msdn.com/dorischen PAGE 22

Page 20: What Web Developers Need to Know to Develop Windows 8 Apps

twitter #wins8camp http://bit.ly/wins8cheatsheet Blog http://blogs.msdn.com/dorischen PAGE 23

Page 21: What Web Developers Need to Know to Develop Windows 8 Apps
Page 22: What Web Developers Need to Know to Develop Windows 8 Apps

The development tools are FREE!

If you use a higher SKU, it just works!

Page 23: What Web Developers Need to Know to Develop Windows 8 Apps

demo

Page 24: What Web Developers Need to Know to Develop Windows 8 Apps
Page 25: What Web Developers Need to Know to Develop Windows 8 Apps

Blog http://blogs.msdn.com/dorischen PAGE

28

Page 26: What Web Developers Need to Know to Develop Windows 8 Apps

demo

Page 27: What Web Developers Need to Know to Develop Windows 8 Apps

There are ways to communicate across contexts, ways to give websites access to some web standards

features and ways to skip automatic filtering within a function.

Feature Local context Web context

Windows Runtime Yes No

Windows Library for JavaScript Yes Partial

JavaScript

URIs(attribute="javascript:code") No Yes

Data URIs ("data:" ) for fonts No Yes

External script references

(<script src="http://*" /> ) No Yes

window.close Yes No

Cross-domain XHR requests Yes No

Page 28: What Web Developers Need to Know to Develop Windows 8 Apps

http://blogs.msdn.com/b/dorischen/archive/2012/10/02/transform-your-html-css-javascript-apps-into-windows-8-application.aspx

http://github.com/appendto/jquery-win8

http://channel9.msdn.com/Events/Build/2012/3-130

http://msdn.microsoft.com/en-us/library/windows/apps/hh700404.aspx

Page 29: What Web Developers Need to Know to Develop Windows 8 Apps

twitter #devcamp lab setup: http://bit.ly/html5setup Blog http://blogs.msdn.com/dorischen PAGE 33

Page 30: What Web Developers Need to Know to Develop Windows 8 Apps

xhr//access a web service, cloud service, local resource

http://www.example.org/somedata.json

Page 31: What Web Developers Need to Know to Develop Windows 8 Apps

Blog http://blogs.msdn.com/dorischen PAGE

36

Page 32: What Web Developers Need to Know to Develop Windows 8 Apps
Page 33: What Web Developers Need to Know to Develop Windows 8 Apps
Page 34: What Web Developers Need to Know to Develop Windows 8 Apps
Page 35: What Web Developers Need to Know to Develop Windows 8 Apps

"Code for touch, get mouse and pen for free!"

Page 36: What Web Developers Need to Know to Develop Windows 8 Apps
Page 37: What Web Developers Need to Know to Develop Windows 8 Apps

function onLoad() {

...

var workSpaces = document.getElementsByClassName("workspace");

for (i = 0; i < workSpaces.length; i++) {

workSpaces[i].addEventListener("MSPointerDown", pointerDownHandler, false);

workSpaces[i].addEventListener("MSPointerMove", pointerMoveHandler, false);

workSpaces[i].addEventListener("MSPointerUp", pointerUpHandler, false);

workSpaces[i].addEventListener("MSManipulationStateChanged",

resetInteractions, false);

}

...

}

Page 38: What Web Developers Need to Know to Develop Windows 8 Apps

this.MSPointerDown = function(evt)

{

context.beginPath();

context.moveTo(evt.offsetX, evt.offsetY);

x = evt.offsetX;

y = evt.offsetY;

brush.started = true;

};

this.MSPointerUp = function(evt)

{

if (brush.started)

{

brush.MSPointerMove(evt);

context.closePath();

brush.started = false;

}

};

Page 39: What Web Developers Need to Know to Develop Windows 8 Apps
Page 40: What Web Developers Need to Know to Develop Windows 8 Apps
Page 41: What Web Developers Need to Know to Develop Windows 8 Apps

demo

Page 42: What Web Developers Need to Know to Develop Windows 8 Apps

// Application manifest capabilities required to access camera and microphone <Capabilities> <DeviceCapability Name="webcam" /> <DeviceCapability Name="microphone" /> </Capabilities>

Page 43: What Web Developers Need to Know to Develop Windows 8 Apps

id="message"

id="imagedisplay"

type="text/javascript">

// Step 1: Invoke the camera capture UI for snapping a photo

var captureUI = new Windows.Media.Capture.CameraCaptureUI();

captureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).

then(function (capturedItem) {

if (capturedItem) {

// Step 2: Display the photo

document.getElementById("imagedisplay").src = URL.createObjectURL(capturedItem);

} else {

document.getElementById("message").innerHTML = "User didn’t capture a photo";

}

});

Page 44: What Web Developers Need to Know to Develop Windows 8 Apps

id="message"

id="videoplayback"

type="text/javascript">

// Step 1: Invoke the camera capture UI for record a video

var dialog = new Windows.Media.Capture.CameraCaptureUI();

dialog.videoSettings.format = Windows.Media.Capture.CameraCaptureUIVideoFormat.mp4;

dialog.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.video).done(function (file) {

if (file) {

var videoBlobUrl = URL.createObjectURL(file, {oneTimeOnly: true});

document.getElementById("capturedVideo").src = videoBlobUrl;

}

});

Page 45: What Web Developers Need to Know to Develop Windows 8 Apps
Page 46: What Web Developers Need to Know to Develop Windows 8 Apps
Page 47: What Web Developers Need to Know to Develop Windows 8 Apps
Page 48: What Web Developers Need to Know to Develop Windows 8 Apps

demo

Page 49: What Web Developers Need to Know to Develop Windows 8 Apps

document.getElementById("pin").addEventListener("click", function (e) {

var uri = new Windows.Foundation.Uri("ms-appx:///" + item.tileImage);

var tile = new start.SecondaryTile(

item.key, // Tile ID

item.shortTitle, // Tile short name

item.title, // Tile display name

JSON.stringify(Data.getItemReference(item)), // Activation argument

start.TileOptions.showNameOnLogo, // Tile options

uri // Tile logo URI

);

})

return nav.navigate("/pages/itemDetail/itemDetail.html", { item: JSON.parse(args.detail.arguments) });

Page 50: What Web Developers Need to Know to Develop Windows 8 Apps
Page 51: What Web Developers Need to Know to Develop Windows 8 Apps
Page 52: What Web Developers Need to Know to Develop Windows 8 Apps

default.js:

// Register for push notifications var profile = net.NetworkInformation.getInternetConnectionProfile();

if (profile.getNetworkConnectivityLevel() === net.NetworkConnectivityLevel.internetAccess) { push.PushNotificationChannelManager.createPushNotificationChannelForApplicationAsync().then(function (channel) {

var buffer = wsc.CryptographicBuffer.convertStringToBinary(channel.uri, wsc.BinaryStringEncoding.utf8);

var uri = wsc.CryptographicBuffer.encodeToBase64String(buffer);

WinJS.xhr({ url: "http://ContosoRecipes8.cloudapp.net?uri=" + uri + "&type=tile" }).then(function (xhr) {

… }…

Page 53: What Web Developers Need to Know to Develop Windows 8 Apps
Page 54: What Web Developers Need to Know to Develop Windows 8 Apps
Page 55: What Web Developers Need to Know to Develop Windows 8 Apps
Page 56: What Web Developers Need to Know to Develop Windows 8 Apps

// Handle click events from the Reminder command

document.getElementById("remind").addEventListener("click", function (e) {

// Create a toast notifier

var notifier = notify.ToastNotificationManager.createToastNotifier();

// Make sure notifications are enabled

if (notifier.setting != notify.NotificationSetting.enabled) {…}

// Get a toast template and insert a text node containing a message

var template = notify.ToastNotificationManager.getTemplateContent(notify.ToastTemplateType.toastText01);

var element = template.getElementsByTagName("text")[0];element.appendChild(template.createTextNode("Reminder!"));

// Schedule the toast to appear 10 seconds from now

var date = new Date(new Date().getTime() + 10000);

var stn = notify.ScheduledToastNotification(template, date);

notifier.addToSchedule(stn); });

Page 57: What Web Developers Need to Know to Develop Windows 8 Apps
Page 58: What Web Developers Need to Know to Develop Windows 8 Apps
Page 59: What Web Developers Need to Know to Develop Windows 8 Apps
Page 60: What Web Developers Need to Know to Develop Windows 8 Apps
Page 61: What Web Developers Need to Know to Develop Windows 8 Apps
Page 62: What Web Developers Need to Know to Develop Windows 8 Apps
Page 63: What Web Developers Need to Know to Develop Windows 8 Apps

• Free open source cross platform framework for apps on mobile devices

• Renders UI using HTML5 and CSS; Web browser encased in a native app for each platform

• Build for Windows Phone and Port to Windows 8

HTML5/JS developers

Page 64: What Web Developers Need to Know to Develop Windows 8 Apps

HTML5/JS developers (Game): Construct 2 (Game)

Construct2 - cross platform game development for beginners

Page 65: What Web Developers Need to Know to Develop Windows 8 Apps

HTML5/JS developers (Game) GameMaker - family of products that caters to entry-level developers and seasoned game development professionals to create cross platform games

Page 66: What Web Developers Need to Know to Develop Windows 8 Apps

HTML5/JS developers (Game) GameSalad – create cross platform games rapidly with no code

Page 67: What Web Developers Need to Know to Develop Windows 8 Apps
Page 68: What Web Developers Need to Know to Develop Windows 8 Apps
Page 69: What Web Developers Need to Know to Develop Windows 8 Apps

Blog http://blogs.msdn.com/dorischen

http://bit.ly/2000Cash

Publish your app to the Windows Store and/or Windows Phone Store March 8, 2013 through June 30, 2013

Submit up to 10 published apps per Store and get a $100 Virtual Visa®

More: http://bit.ly/2000Cash

Page 70: What Web Developers Need to Know to Develop Windows 8 Apps

YOUR IDEA.

YOUR APP.

30 DAYS.

You can develop a Windows 8 app in 30 days—

and we’re here to help.

Week 1 App design

Week 2 Coding your app

Week 3 Making your app shine

Week 4 Get published

• Insider tips and tricks on Windows 8 application development.

• Personal on-the-phone access to a Windows 8 architect*.

• An exclusive one-on-one Metro style design consultation*.

• An opportunity to get expert help from a Microsoft Services Engineer at an App Excellence Lab.

Sign Up http://bit.ly/Win8GenApp

Page 71: What Web Developers Need to Know to Develop Windows 8 Apps

http://bit.ly/HTML5Wins8Camp

http://bit.ly/CampInBox

http://bit.ly/Wins8Download

http://Aka.ms/brockschmidtbook

http:/dev.windows.com PAGE

80

Page 72: What Web Developers Need to Know to Develop Windows 8 Apps

PAGE

81

• Responsive Web Design and CSS3

• http://bit.ly/CSS3Intro

• HTML5, CSS3 Free 1 Day Training

• http://bit.ly/HTML5DevCampDownload

• Using Blend to Design HTML5 Windows 8 Application (Part II): Style,

Layout and Grid

• http://bit.ly/HTML5onBlend2

• Using Blend to Design HTML5 Windows 8 Application (Part III): Style

Game Board, Cards, Support Different Device, View States

• http://bit.ly/HTML5onBlend3

• Feature-specific demos • http://ie.microsoft.com/testdrive/

• Real-world demos • http://www.beautyoftheweb.com/