Your SlideShare is downloading. ×
Windows 8 metro applications
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

Windows 8 metro applications


Published on

Presentation from vNext meeting at March 13 - Windows 8 Metro apps development using XAML/C#

Presentation from vNext meeting at March 13 - Windows 8 Metro apps development using XAML/C#

Published in: Technology, Art & Photos

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide
  • This slide is hidden.. Do start with a demo of Windows 8, but don’t show the slide. Demonstrate mostly the Windows Start Menu ( aka the shell ). Make sure you use touch … Highlight the following points Windows 8 Experience  Full screen apps Live tiles  Alive and in motion  Action: Drag & rearrange tiles  Semantic  Zoom in Start Menu Search  Personalize Windows  Swap across process Pin an app  Charms   
  • Create a Camera Capture UI demo. Seamless integration with devices and OS resources.
  • Installation process:From the store, you will trigger an install.. This pulls the bytes from the cloud, validates it, and installs it.. Installation is per user.. [windows traditionally has been per machine].. Behind the scenes, we have a single instance store.. So the apps are installed once.. The registration is per user.. Extension handlers.. System handles setup and uninstall automatically – allows us to guarantee that installed app will not be making permanent changes – nothing left after uninstall.Download app package (zip) goes to package manager
  • The app package (Appx) is abb OPC file ( a zip) The package It includes anything necessary to deploy or uninstall – It includes capabilities and declartions so we know the impact in the system. In the package you will see JS files etc. If in C++ see .dll files and what you would expect. Blockmap is a series of hashes for each block in your package. Combination of signature + blockmap verifies the package.. It can be validated as it comes off-the wire… we don’t have to download the whole thing..
  • Talking about appdata specifically, will talk about user data later when we look at skydrive, etc.Slide 8 from PLAT-475T
  • Key, app does not have to do much – whole infrastructure built for you.Writes local and system takes care of the rest – some limitations, we will cover later.Slide 8 from PLAT-475T
  • Transcript

    • 1. demo
    • 2. demo
    • 3. demo
    • 4. // Application manifest capabilities required to access cameraand microphone<Capabilities> <DeviceCapability Name="webcam" /> <DeviceCapability Name="microphone" /></Capabilities>
    • 5. CameraCaptureUI dialog = new CameraCaptureUI();Size aspectRatio = new Size(16, 9);dialog.PhotoSettings.CroppedAspectRatio = aspectRatio;StorageFile file = awaitdialog.CaptureFileAsync(CameraCaptureUIMode.Photo);if (file != null){ BitmapImage bitmapImage = new BitmapImage(); using (IRandomAccessStream fileStream = awaitfile.OpenAsync(Windows.Storage.FileAccessMode.Read)) bitmapImage.SetSource(fileStream); image.Source = bitmapImage;}
    • 6. demo
    • 7. <Capabilities> <Capability Name= "???_Library" /></Capabilities>StorageFile sampleFile = await KnownFolders.VideosLibrary.GetFileAsync("vNext.txt");var doc = await XmlDocument.LoadFromFileAsync(sampleFile);
    • 8. demo
    • 9. <Extensions> <Extension Category="windows.shareTarget" Executable="SampleShareTarget.exe" EntryPoint="SampleShareTarget.App"> <ShareTarget> <SupportedFileTypes> <SupportsAnyFileType /> </SupportedFileTypes> <DataFormat>text</DataFormat> <DataFormat>bitmap</DataFormat> <DataFormat>uri</DataFormat> <DataFormat>html</DataFormat> <DataFormat>Valentine-Love-Catcher</DataFormat> </ShareTarget> </Extension></Extensions>
    • 10. protected override async voidOnShareTargetActivated(ShareTargetActivatedEventArgs args){ BlankPage shareTargetPage = new BlankPage(); await shareTargetPage.ActivateAsync(args);}
    • 11. public async Task ActivateAsync(ShareTargetActivatedEventArgs args){ if (args.Kind == ActivationKind.ShareTarget) { shareOperation = args.ShareOperation; txtTitle.Text = shareOperation.Data.Properties.Title; txtDesc.Text = shareOperation.Data.Properties.Description; if (shareOperation.Data.Contains(StandardDataFormats.Text)) { string text = await this.shareOperation.Data.GetTextAsync(); if (text != null) { txtText.Text = text; } } }}
    • 12. DataTransferManager DataTransferManager new DataTransferManager DataRequestedEventArgs//[OPTIONALLY] If application makes distinction between targetapplications, subscribe to this event//[OPTIONALLY] Force showing share UIDataTransferManager
    • 13. private async void DataTransferManagerDataRequestedEventArgs "Sample share source app" "Spread the word about this lovely application" RandomAccessStreamReference new Uri "ms-appx:///Images/Love.png" "Sample text" RandomAccessStreamReference new Uri "ms-appx:///Images/test.png"
    • 14. Capabilities Seamless Performantdriven data accessHigh isolation Data Native Roaming platform
    • 15. demo
    • 16. ITileWideSmallImageAndText03 tileContent = TileContentFactory.CreateTileWideSmallImageAndText03();tileContent.TextBodyWrap.Text = "Main tile updated fromapplication!";tileContent.Image.Src = "ms-appx:///Images/Bouquet.png";tileContent.RequireSquareContent = false;TileUpdateManager.CreateTileUpdaterForApplication().Update( tileContent.CreateNotification());
    • 17. IToastImageAndText02 templateContent = ToastContentFactory.CreateToastImageAndText02();templateContent.TextHeading.Text = "Toast sample";templateContent.TextBodyWrap.Text = "Toast message fromapplication!";templateContent.Image.Src = "Images/NewYear.png";templateContent.Image.Alt = "Placeholder image";IToastNotificationContent toastContent = templateContent;ToastNotification toast = toastContent.CreateNotification();ToastNotificationManager.CreateToastNotifier().Show(toast);
    • 18. BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent();badgeContent.Number = 23;BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update( badgeContent.CreateNotification());
    • 19. Uri logo = new Uri("ms-appx:///images/LoveIcon.png");Uri wideLogo = new Uri("ms-appx:///images/WideSecondary.png");SecondaryTile secondaryTile = newSecondaryTile("LiveTilesAndToastsSample.SecondaryTile", "Secondary tile", "Secondary tile from app", "argumets=Alex,123", TileOptions.ShowNameOnWideLogo | TileOptions.ShowNameOnLogo, logo, wideLogo);bool isPinned = await secondaryTile.RequestCreateForSelectionAsync( new Rect(10,10,100,100));
    • 20. ITileWideSmallImageAndText03 tileContent = TileContentFactory.CreateTileWideSmallImageAndText03();tileContent.TextBodyWrap.Text = "Secondary tile updated fromapplication!";tileContent.Image.Src = "ms-appx:///Images/NewYear.png";tileContent.RequireSquareContent = false;TileUpdateManager.CreateTileUpdaterForSecondaryTile( "LiveTilesAndToastsSample.SecondaryTile").Update( tileContent.CreateNotification());
    • 21. 1. Request Channel URI2. Register with your Cloud Service3. Authenticate & Push Notification
    • 22. demo
    • 23. var pushNotificationChannel = awaitPushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();var channelUri = pushNotificationChannel.Uri;//Optional channel for Secondary tileif (SecondaryTile.Exists(SecondaryTileID)){ var secondaryPushNotificationChannel = awaitPushNotificationChannelManager.CreatePushNotificationChannelForSecondaryTileAsync(SecondaryTileID); var secondaryChannelUri = secondaryPushNotificationChannel.Uri;}
    • 24. private static Stream GetAccessToken(string sid, string secret){ string url = ""; var request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; string content ="grant_type=client_credentials&client_id={0}&client_secret={1}&"; string data = string.Format(content, sid, secret); byte[] notificationMessage = Encoding.Default.GetBytes(data);
    • 25. request.ContentLength = notificationMessage.Length; using (Stream requestStream = request.GetRequestStream()) requestStream.Write(notificationMessage, 0, notificationMessage.Length); var response = (HttpWebResponse)request.GetResponse(); Stream result = response.GetResponseStream(); return result;}
    • 26. private static HttpStatusCode Push(string pushUri, stringaccessToken, string type, string notificationData){ var subscriptionUri = new Uri(pushUri); var request = (HttpWebRequest)WebRequest.Create(subscriptionUri); request.Method = "POST"; request.ContentType = "text/xml"; request.Headers = new WebHeaderCollection(); request.Headers.Add("X-WNS-Type", type); request.Headers.Add("Authorization", "Bearer " + accessToken);
    • 27. byte[] notificationMessage = Encoding.Default.GetBytes(notificationData); request.ContentLength = notificationMessage.Length; using (Stream requestStream = request.GetRequestStream()) requestStream.Write(notificationMessage, 0, notificationMessage.Length); var response = (HttpWebResponse)request.GetResponse(); return response.StatusCode;}
    • 28. string pushUri = "";string secret = HttpUtility.UrlEncode("2A...");string sid = HttpUtility.UrlEncode("ms-app://s-...");var obj =System.Json.JsonObject.Load(GetAccessToken(sid, secret));string accessToken = obj["access_token"].ToString();//Send Badge notificationstring badgeNotification = "<?xml version=1.0 encoding=utf-8?><badge value="13"/>";HttpStatusCode status =Push(pushUri, accessToken, "wns/badge", badgeNotification);
    • 29. //Send Toast notificationstring tostNotification = "<?xml version=1.0 encoding=utf-8?><toast><visual><bindingtemplate="ToastImageAndText02"><image id="1"src="Assets/Logo.png" alt="Placeholder image"/><textid="1">Urgent news</text><text id="2">New vNext meetupscheduled!</text></binding></visual></toast>";status = Push(pushUri, accessToken, "wns/toast",tostNotification);
    • 30. //Send Tile notificationstring tileNotification = "<?xml version=1.0 encoding=utf-8?><tile><visual><bindingtemplate="TileWideSmallImageAndText03"><image id="1"src="ms-appx:///Images/Meetup.png"/><text id="1">New vNextmeetup scheduled!</text></binding></visual></tile>";status =Push(pushUri, accessToken, "wns/tile", tileNotification);
    • 31. //Send Secondary Tile notificationpushUri = "";string secondaryTileNotification = "<?xml version=1.0encoding=utf-8?><tile><visual lang="en-US"><bindingtemplate="TileWidePeekImage05"><image id="1" src="ms-appx:///Images/Blog.png"/><image id="2" src="ms-appx:///Images/Avatar.png"/><text id="1">Visit myblog!</text><textid="2"></text></binding></visual></tile>";status =Push(pushUri, accessToken, "wns/tile", secondaryTileNotification);
    • 32. • •• •• •• •