Your SlideShare is downloading. ×
demo
demo
demo
// Application manifest capabilities required to access cameraand microphone<Capabilities>    <DeviceCapability Name="webc...
CameraCaptureUI dialog = new CameraCaptureUI();Size aspectRatio = new Size(16, 9);dialog.PhotoSettings.CroppedAspectRatio ...
demo
<Capabilities>  <Capability Name= "???_Library" /></Capabilities>StorageFile sampleFile = await          KnownFolders.Vide...
demo
<Extensions>  <Extension Category="windows.shareTarget"             Executable="SampleShareTarget.exe"             EntryPo...
protected override async voidOnShareTargetActivated(ShareTargetActivatedEventArgs args){    BlankPage shareTargetPage = ne...
public async Task ActivateAsync(ShareTargetActivatedEventArgs args){    if (args.Kind == ActivationKind.ShareTarget)    { ...
DataTransferManager                     DataTransferManager                                    new                   DataT...
private async void                 DataTransferManagerDataRequestedEventArgs       "Sample share source app"       "Spread...
Capabilities     Seamless      Performantdriven           data accessHigh isolation   Data          Native                ...
demo
ITileWideSmallImageAndText03 tileContent =        TileContentFactory.CreateTileWideSmallImageAndText03();tileContent.TextB...
IToastImageAndText02 templateContent =         ToastContentFactory.CreateToastImageAndText02();templateContent.TextHeading...
BadgeNumericNotificationContent badgeContent =        new BadgeNumericNotificationContent();badgeContent.Number = 23;Badge...
Uri logo = new Uri("ms-appx:///images/LoveIcon.png");Uri wideLogo = new Uri("ms-appx:///images/WideSecondary.png");Seconda...
ITileWideSmallImageAndText03 tileContent =        TileContentFactory.CreateTileWideSmallImageAndText03();tileContent.TextB...
1. Request Channel URI2. Register with your Cloud   Service3. Authenticate & Push   Notification
demo
var pushNotificationChannel = awaitPushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();var c...
private static Stream GetAccessToken(string sid, string secret){    string url = "https://login.live.com/accesstoken.srf";...
request.ContentLength = notificationMessage.Length;    using (Stream requestStream = request.GetRequestStream())        re...
private static HttpStatusCode Push(string pushUri, stringaccessToken, string type, string notificationData){    var subscr...
byte[] notificationMessage =           Encoding.Default.GetBytes(notificationData);    request.ContentLength = notificatio...
string pushUri = "https://db3.notify.windows.com/...";string secret = HttpUtility.UrlEncode("2A...");string sid = HttpUtil...
//Send Toast notificationstring tostNotification = "<?xml version=1.0 encoding=utf-8?><toast><visual><bindingtemplate="Toa...
//Send Tile notificationstring tileNotification = "<?xml version=1.0 encoding=utf-8?><tile><visual><bindingtemplate="TileW...
//Send Secondary Tile notificationpushUri = "https://db3.notify.windows.com/...";string secondaryTileNotification = "<?xml...
•    ••    ••    ••    •        alex@sela.co.il
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Windows 8 metro applications
Upcoming SlideShare
Loading in...5
×

Windows 8 metro applications

5,470

Published on

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

Published in: Technology, Art & Photos
3 Comments
7 Likes
Statistics
Notes
No Downloads
Views
Total Views
5,470
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
3
Likes
7
Embeds 0
No embeds

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 &amp; 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 of "Windows 8 metro applications"

    1. 1. demo
    2. 2. demo
    3. 3. demo
    4. 4. // Application manifest capabilities required to access cameraand microphone<Capabilities> <DeviceCapability Name="webcam" /> <DeviceCapability Name="microphone" /></Capabilities>
    5. 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. 6. demo
    7. 7. <Capabilities> <Capability Name= "???_Library" /></Capabilities>StorageFile sampleFile = await KnownFolders.VideosLibrary.GetFileAsync("vNext.txt");var doc = await XmlDocument.LoadFromFileAsync(sampleFile);
    8. 8. demo
    9. 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. 10. protected override async voidOnShareTargetActivated(ShareTargetActivatedEventArgs args){ BlankPage shareTargetPage = new BlankPage(); await shareTargetPage.ActivateAsync(args);}
    11. 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. 12. DataTransferManager DataTransferManager new DataTransferManager DataRequestedEventArgs//[OPTIONALLY] If application makes distinction between targetapplications, subscribe to this event//[OPTIONALLY] Force showing share UIDataTransferManager
    13. 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. 14. Capabilities Seamless Performantdriven data accessHigh isolation Data Native Roaming platform
    15. 15. demo
    16. 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. 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. 18. BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent();badgeContent.Number = 23;BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update( badgeContent.CreateNotification());
    19. 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. 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. 21. 1. Request Channel URI2. Register with your Cloud Service3. Authenticate & Push Notification
    22. 22. demo
    23. 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. 24. private static Stream GetAccessToken(string sid, string secret){ string url = "https://login.live.com/accesstoken.srf"; 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}&scope=notify.windows.com"; string data = string.Format(content, sid, secret); byte[] notificationMessage = Encoding.Default.GetBytes(data);
    25. 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. 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. 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. 28. string pushUri = "https://db3.notify.windows.com/...";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. 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. 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. 31. //Send Secondary Tile notificationpushUri = "https://db3.notify.windows.com/...";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">http://blogs.microsoft.co.il/blogs/alex_golesh/</text></binding></visual></tile>";status =Push(pushUri, accessToken, "wns/tile", secondaryTileNotification);
    32. 32. • •• •• •• • alex@sela.co.il

    ×