<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Jean-Sébastien Dupuy</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/jdupuy/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/jdupuy/feed.xml</link>
    <description>Tech Evangelist - Mobile Development &amp;amp; IoT</description>
    <lastBuildDate>Tue, 16 Apr 2019 05:11:28 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Visual Layer : Redonnez le pouvoir à votre GPU</title>
      <link>https://docs.microsoft.com/archive/blogs/jdupuy/visual-layer</link>
      <pubDate>Mon, 07 Mar 2016 09:28:25 GMT</pubDate>
      <dc:creator><![CDATA[Jean-Sébastien Dupuy [Microsoft]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jdupuy/?p=201</guid>
      <description><![CDATA[Back to the roots
Introduit par Windows Vista sous le nom Desktop Windows Manager (DWM), le moteur...]]></description>
      <content:encoded><![CDATA[<h3 align="justify">Back to the roots</h3>
<p align="justify">Introduit par Windows Vista sous le nom <strong>Desktop Windows Manager </strong>(DWM), le moteur de composition (<strong>Windows Composition)</strong> n’est pas totalement récent en soit. Il a notamment été mis en place pour proposer l’expérience “Windows Aero”, assurant les fameux effets de perspective 3D et de semi transparence sur les fenêtres de Windows Vista.</p>
<a href="https://msdnshared.blob.core.windows.net/media/2016/03/vista_flip3d.jpg"><img class="aligncenter wp-image-241" src="https://msdnshared.blob.core.windows.net/media/2016/03/vista_flip3d.jpg" alt="vista_flip3d" width="600" height="438" /></a>
<h3 align="justify">Un peu de contexte technico-historique</h3>
<p align="justify">Sous Windows XP, chaque application écrivait dans un buffer d’affichage commun pour effectuer le rendu à l’écran. Avec l’arrivée de DWM, une révolution silencieuse fait son apparition : chaque application dispose désormais d’un buffer séparé (le grand luxe) ! Ces snapshots sont ensuite récupérés puis (éventuellement) retravaillés par le moteur de composition pour effectuer le rendu à l’écran.</p>

<blockquote>
<p style="text-align: left" align="center">On passe donc d’une collocation sympa mais un peu désorganisé à des appartements séparés avec un propriétaire qui veille au grain</p>
</blockquote>
<p align="justify">Ce moteur connaît l’état de chaque buffer et il maintient un arbre visuel (<strong>visual tree</strong>) des différentes sources ;  assurer les effets de transparence ou de perspectives entre les différents visuels (en résumé les fenêtres) est désormais <em>presque</em> un jeu d’enfant. Naturellement, il s’appuie sur DirectX, les opérations de composition sont effectuées par le GPU – libérant au passage le CPU de toute surcharge de travail non méritée.</p>
<p align="justify">L’histoire aurait pu en rester la - mais les équipes (depuis Windows 8) ont eu la bonne idée de doter ce moteur d’une API : <strong>DirectComposition</strong> (qui, comme son nom l’indique est liée intimement à DirectX).</p>
<p align="justify">Pourquoi ne pas prolonger l’arbre visuel avec des éléments graphiques qui appartiennent directement à mon application ? Comme DWM se charge déjà d’afficher le rendu de mon application et qu’il accède au GPU, autant en profiter pour lui déléguer des tâches (animations, effets) qui vampirise les ressources à mon thread UI. Et bien, c’est tout l’intérêt de ce jeu d’API !</p>

<h3 align="justify">What’s new pour la plateforme universelle ?</h3>
<p align="justify">La nouveauté, c’est que l’API <strong>DirectComposition </strong>est désormais nativement proposée par WinRT (depuis la build 1511 du SDK) sous la terminologie <strong>Visual Layer</strong> (disponible dans le namespace Windows.UI.Composition).</p>

<blockquote>
<p align="justify">En résumé, le Visual Layer va nous aider à créer des interfaces attrayantes, fluides et ainsi améliorer l'expérience de nos utilisateurs.</p>
</blockquote>
<p align="justify">Le but n’est pas de remplacer les autres frameworks, mais de vous offrir un nouvel accès, plus proche du GPU, sans avoir besoin de mettre les mains dans DirectX (enfin presque). Xaml et le Visual Layer sont capables de coopérer main dans la main, rendez-vous en fin d’article sur ce point !</p>
<a href="https://msdnshared.blob.core.windows.net/media/2016/03/layers.png"><img class="aligncenter wp-image-243" src="https://msdnshared.blob.core.windows.net/media/2016/03/layers-1024x578.png" alt="layers" width="600" height="338" /></a>
<h3 align="justify"></h3>
<h3 align="justify">Comment débuter ?</h3>
<p align="justify">Dans un premier temps, je vous propose de nous passer totalement de code Xaml (Rassurez-vous, ce n’est que temporaire).</p>

<ol>
	<li>
<div align="justify">Créez une <strong>Application vide (Windows universel)</strong> puis supprimer les fichiers App.xaml, App.xaml.cs, MainPage.xaml, MainPage.xaml.cs. On fait du vide !</div></li>
	<li>
<div align="justify">Ajoutez une classe DefaultView.cs à votre projet et copiez le code suivant :</div></li>
</ol>
<script src="https://gist.github.com/dupuyjs/5b7dbaede0eb5dc1bcf7.js"></script>

Compilez, et lancez l’application. Si tout se passe bien, vous avez une fenêtre vide devant vos yeux émerveillés.

Le seul point à regarder en détail c’est la méthode <strong>SetWindow</strong>. Le reste du code permet d’instancier la fenêtre et de gérer correctement la boucle des messages.

Terminologie pour comprendre le reste du code :

<ul>
	<li><strong>Compositor</strong> : Classe principale, qui va permettre la communication entre le moteur de composition et l’application.</li>
	<li><strong>CompositionTarget</strong> : Représente la surface d’affichage de notre application.</li>
</ul>
<h3>Composition : Les basiques</h3>

Le Visual Layer travaille sur un arbre de composition formé de <strong>Visual</strong>. Les nœuds sont constitués des objets suivants :

<ul>
	<li><strong>CompositionObject </strong>: Classe de base.</li>
	<li><strong>Visual </strong>: Hérite de CompositionObject et implémente toutes les opérations principales.</li>
	<li><strong>ContainerVisual </strong>: Identique à la classe Visual mais dispose d'une propriété Children additionnelle.</li>
	<li><strong>SpriteVisual</strong> : Identique à la classe ContainerVisual mais permet d'associer un objet Brush au Visual.</li>
</ul>

Copiez le code suivant pour alimenter notre arbre de composition avec deux objets SpriteVisual nommée foreground/backround, respectivement en cyan/indigo.

<script src="https://gist.github.com/dupuyjs/4912cbd6dfa038210897.js"></script>

<a href="https://msdnshared.blob.core.windows.net/media/2016/03/spritevisual1.png"><img class="aligncenter size-large wp-image-261" src="https://msdnshared.blob.core.windows.net/media/2016/03/spritevisual1-1024x749.png" alt="spritevisual" width="600" height="438" /></a>
<h3>Animations</h3>
Le moteur de composition met à disposition deux types d'animations.
<p style="text-align: justify"><strong>KeyFrame Animation</strong> : Animation traitée sur une durée de temps. On définie des positions clés (au minimum une position de départ et une position de fin) - on laisse ensuite le moteur interpoler toutes les positions intermédiaires pour chaque frame affichée à l'écran.</p>
<p style="text-align: justify">Le code suivant permet de faire tourner linéairement l'objet foreground ; un tour complet (360°) est effectuée toutes les 3 secondes.</p>
<p style="text-align: justify"><script src="https://gist.github.com/dupuyjs/6f00e63fff5468ba1b04.js"></script><strong>Expression Animation </strong>: Animation qui n'est pas dépendante du temps ; on calcule explicitement la position pour chaque frame, basée sur un calcul mathématique (une expression). 

Le code suivant permet d'effectuer une translation de l'objet background ; l'expression utilise une condition basée sur l'animation précédente  : l'angle de rotation de l'objet foreground.

La méthode <strong>SetReferenceParameter </strong>permet à l'expression de faire référence aux propriétés des objets Visual.

<script src="https://gist.github.com/dupuyjs/54c6eca3065216e837fd.js"></script></p>
<p style="text-align: justify">Pour aller plus loin : <a href="https://msdn.microsoft.com/en-us/windows/uwp/graphics/composition-animation">compositions animations</a></p>

<div style="text-align: center">

[video width="600" height="477" align="center" mp4="https://msdnshared.blob.core.windows.net/media/2016/03/animations.mp4" preload="auto" autoplay="true" loop="true"][/video]

</div>
<h3>Effets</h3>
<p style="text-align: justify">Jusqu'à maintenant, on a utilisé un <strong>CompositionColorBrush</strong> pour 'remplir' le Visual avec une couleur fixe. Avant d'appliquer un effet, je vous propose de charger une image dans un Visual, on bascule désormais sur un <strong>CompositionSurfaceBrush</strong>. L'étape pour charger une image dans ce type d'objet n'est pas directement pris en charge dans Windows.UI.Composition, vous devez faire appel à <a href="https://github.com/Microsoft/composition/tree/master/SDK10586_NOV_UPDATE_RTM/Microsoft.UI.Composition.Toolkit">Microsoft.UI.Composition.Toolkit</a> (ou utiliser le package nugget <a href="https://www.nuget.org/packages/Robmikh.Util.CompositionImageLoader">CompositionImageLoader</a>) pour vous aider dans cette démarche. Le code suivant fait le reste (il faut adapter un peu le code si vous utilisez le package nugget):</p>
<script src="https://gist.github.com/dupuyjs/2e2b86fc15e34f20ac74.js"></script>

<a href="https://msdnshared.blob.core.windows.net/media/2016/03/visualimage.png"><img class="aligncenter size-large wp-image-292" src="https://msdnshared.blob.core.windows.net/media/2016/03/visualimage-1024x817.png" alt="visualimage" width="600" height="438" /></a>

Pour aller plus loin sur les objets Brush proposés par le Visual Layer : <a href="https://msdn.microsoft.com/en-us/windows/uwp/graphics/composition-brushes">composition brushes </a>

<h4>Saturation</h4>

La définition des effets s'appuie sur le même namespace que Win2D : <a href="http://microsoft.github.io/Win2D/html/N_Microsoft_Graphics_Canvas_Effects.htm">Microsoft.Graphics.Canvas.Effects</a>. Les effets non supportés actuellement par le le moteur de composition (il faut bien l'avouer c'est la majorité actuellement) sont listés avec l'attribut [<strong>NoComposition</strong>]. Même (si de ma compréhension) Win2D n'est pas utilisé directement pour faire le rendu de l'effet, il est nécessaire d'installer le nugget Win2D pour accéder aux déclarations des effets.

Pour la suite, voici comment effectuer un effet de (dé)saturation sur l'image :

<script src="https://gist.github.com/dupuyjs/e9213e02f254fe4114c3.js"></script>

<a href="https://msdnshared.blob.core.windows.net/media/2016/03/saturation.png"><img class="aligncenter size-large wp-image-282" src="https://msdnshared.blob.core.windows.net/media/2016/03/saturation-1024x817.png" alt="saturation" width="600" height="438" /></a>

Pour aller plus loin : <a href="https://msdn.microsoft.com/en-us/windows/uwp/graphics/composition-effects">compositions effects</a>
<h3>Et le code Xaml dans tout ca ?</h3>
<p style="text-align: justify">La classe <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.hosting.elementcompositionpreview.aspx">ElementCompositionPreview </a>nous vient en aide, elle permet de récupérer un <strong>Visual</strong> depuis un élément du Framework Xaml. Vous pouvez dès lors utiliser les connaissances précédentes pour appliquer une animation sur cet élément, comme dans le code ci-dessous :</p>
<script src="https://gist.github.com/dupuyjs/aeda88cfcea613aab577.js"></script>

<script src="https://gist.github.com/dupuyjs/6a3ad242832493b73c66.js"></script>
<h3>Conclusion</h3>
<p style="text-align: justify">Prometteur pour assurer de la fluidité à nos interfaces de demain, il manque cependant encore quelques briques pour que le Visual Layer prenne toutes ses lettres de noblesse (notamment des effets comme le blur et le drop shadow). Cette version laisse toutefois entrevoir de nouvelles possibilités et sans doutes quelques surprises dans les prochaines versions.</p>
<p style="text-align: justify">What's next ? Je vous invite à regarder les exemples proposés par <a href="https://github.com/Microsoft/composition">https://github.com/Microsoft/composition</a> et la documentation <a href="https://msdn.microsoft.com/fr-fr/windows/uwp/graphics/visual-layer">msdn</a>. N'hésitez pas à suivre <a href="https://twitter.com/WinComposition">@wincomposition</a> pour vous tenir informé des prochaines nouveautés.</p>]]></content:encoded>
    </item>
    <item>
      <title>.net native : améliorez la performance de vos applications universelles</title>
      <link>https://docs.microsoft.com/archive/blogs/jdupuy/net-native-amliorez-la-performance-de-vos-applications-universelles</link>
      <pubDate>Mon, 07 Sep 2015 00:00:00 GMT</pubDate>
      <dc:creator><![CDATA[Jean-Sébastien Dupuy [Microsoft]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jdupuy/2015/09/07/net-native-amliorez-la-performance-de-vos-applications-universelles/</guid>
      <description><![CDATA[Vous avez profité des vacances pour vous reposer et couper toute communication avec le monde...]]></description>
      <content:encoded><![CDATA[<p align="justify">Vous avez profité des vacances pour vous reposer et couper toute communication avec le monde extérieur ? Je ne peux que vous féliciter ! Je me permets donc de vous annoncer que <strong>Windows 10</strong> est désormais disponible depuis le <strong>29 juillet</strong>. Une bonne nouvelle ne venant jamais seule, les outils de développement, ainsi que le <strong>Windows Dev Center</strong> ont également fait peau neuve avec leur lot de nouveautés.<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/1307.Windows-10-Ninja-Cat-TRex_4E34DD0B.gif"><img class=" aligncenter" style="float: none;margin-left: auto;margin-right: auto" title="Windows-10-Ninja-Cat-TRex" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/0676.Windows-10-Ninja-Cat-TRex_thumb_03661791.gif" alt="Windows-10-Ninja-Cat-TRex" width="480" height="480" /></a></p>
<p align="justify">Comme nous sommes tous frais et reposés en cette belle rentrée (meuh si) ; je vous propose d’étudier plus en détails les nouveautés de la plateforme universelle (UWP) disponible avec <strong>Windows 10</strong>. Comme il faut bien commencer par un sujet, je débute aujourd’hui par un sujet lié aux performances de vos applications C# et VB : .<strong>NET Native !</strong></p>

<h2>.NET Native</h2>
<p align="justify">Alors un peu de contexte pour démystifier le sujet : historiquement, quand vous compilez du code qui repose sur le <strong>Framework</strong> <strong>.NET </strong>(C# ou VB dans le cadre du Windows Store), Visual Studio génère pour vous un package en code <strong>MSIL</strong> (Microsoft Intermediate Language). Ce code intermédiaire est ensuite lui même recompilé en code natif lors de l’exécution de l’application sur le poste cible (on utilise le terme <strong>JIT</strong> alias Just-In-Time compilation pour définir cette opération).</p>
<p align="justify">Cette gestion a ses avantages (il permet notamment de de fournir le même package indépendamment de l’architecture cible : x86, x64 ou ARM)  mais a pour désagrément d’impacter les performances (principalement au démarrage de l’application).</p>
Alors quoi de neuf pour UWP ? Et bien toutes les applications universelles pour <strong>Windows 10</strong> - écrites en C# et VB - sont désormais compilées en code natif (via .<strong>NET Native</strong>) <span style="text-decoration: underline">avant</span> de transférer le package sur le poste cible. Plus besoin de compilation <strong>JIT</strong> pour convertir le code MSIL vers du natif ; le gain en performance est donc significatif.
<ul>
	<li><strong>Jusqu’à 60% pour un démarrage à froid </strong></li>
	<li><strong>Jusqu’à 40% pour un démarrage à chaud</strong></li>
</ul>
<p align="justify">Les dépendances au code .NET sont également injectés en statique au code de l’application – .Net native en profite pour supprimer les types/fonctions qui ne seront pas utilisés par votre code, l’empreinte mémoire est du coup plus faible, on peut donc espérer gagner jusqu'à <strong>30 % de la consommation mémoire</strong> habituelle. Toutes ses valeurs restent théoriques mais pour résumer simplement : vous aller forcément gagner en performance !</p>
<p align="justify">Si vous avez toujours des doutes, vous pouvez tester par vous même votre gain de performance : <a href="https://msdn.microsoft.com/fr-fr/library/dn643729(v=vs.110).aspx">Mesure de l'amélioration du démarrage avec .NET Native</a>.</p>
<p align="justify">Le passage du code IL vers le code machine passe par les rouages d’une série d’outils, vous trouverez donc souvent la terminologie<strong> .NET Native tool chain</strong> dans les différentes documentations. Si le sujet vous passionne et que vous avez l’envie de soulever le capot,  l’article <a href="http://blogs.msdn.com/b/dotnet/archive/2014/05/09/the-net-native-tool-chain.aspx">The .NET Native Tool-Chain</a> est un bon point de départ.</p>
<p align="justify">Bon, <em>ca rocks sérieusement du poney</em> (David Catuhe 2015©) mais à quel moment se déclenche cette optimisation ? Attention, moment émotion :</p>

<h2 align="justify">Debug versus Release</h2>
<p align="justify">Visual Studio s’adapte à ce changement de paradigme. En mode <strong>debug</strong>, la compilation <strong>.NET Native</strong> est désactivée par défaut. Visual Studio génère donc du code <strong>MSIL</strong> et mon package dépend toujours des librairies du <strong>Framework .NET</strong>. On ne gagne pas en performance mais msbuild compile votre solution rapidement (et ce point à son importance). Il est toutefois possible d’activer <strong>.NET Native</strong> au besoin dans les options de compilation.</p>
<p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/7411.netnative_0814AA8E.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="netnative" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/2570.netnative_thumb_220AFB61.png" alt="netnative" width="642" height="250" border="0" /></a></p>
<p align="justify">Pour le mode <strong>release</strong> c’est une autre histoire, <strong>.NET Native</strong> compile votre projet en natif (cette fois-ci par défaut). Visual Studio prend donc son temps pour faire les choses bien et optimiser aux petits oignions votre code ! Vous pourrez profiter de ce moment délicieux pour faire une ou deux pause cafés bien méritées (bref, <em>Sit back and Relax</em>). A noter que <strong>AnyCPU</strong> est une option qui n’a plus lieu d’être car la compilation cible une architecture spécifique (du moins pour les applications, il reste toujours possible de l’utiliser si vous développez une librairie).</p>

<h2 align="justify">Le déploiement sur le Windows Store</h2>
<p align="justify">Votre application est finalisée, voici venu le moment tant espéré de la publication.</p>
<p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/6253.packages_66A6BF72.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border-width: 0px" title="packages" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/1106.packages_thumb_46221071.png" alt="packages" width="589" height="482" border="0" /></a></p>
<p align="justify">L’assistant vous propose de sélectionner les architectures que vous souhaitez supporter, Visual Studio s’occupe du reste. La pause café terminée, vous obtenez le résultat suivant:</p>
<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/3264.appxupload_3BF306B5.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border-width: 0px" title="appxupload" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/4774.appxupload_thumb_76DA397E.png" alt="appxupload" width="642" height="131" border="0" /></a>

- ou, si vous activez l’option bundle -

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/1172.appxuploadbundle_62577AB1.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border-width: 0px" title="appxuploadbundle" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/5226.appxuploadbundle_thumb_245DE9F3.png" alt="appxuploadbundle" width="642" height="54" border="0" /></a>
<p align="justify">Pourquoi un répertoire Test !? Et bien ce répertoire contient l’application optimisé avec <strong>.NET Native</strong>, il sert principalement (comme son nom l’indique) pour effectuer des tests en local - ou - si vous souhaitez déployer votre application en mode <strong>sideloading</strong> (sans passer par le Windows Store).</p>
<p align="justify">Le fichier <strong>.appxupload</strong> contient quand à lui votre application à destination du <strong>Windows Dev Center</strong> (ou les différents fichiers <strong>.appxupload</strong> spécifiques à chaque architecture si vous n’êtes pas en mode bundle).</p>

<h2 align="justify">La compilation made in cloud</h2>
<p align="justify">Petit point déstabilisant au premier abord, le fichier <strong>.appxupload</strong> n’est pas optimisé avec la <strong>.NET Native tool chain</strong>, (à cet instant, vous devez ne plus rien comprendre à ce que je viens de vous raconter précédemment, <em>don’t panic</em>).</p>
<p align="justify"><strong>.appxupload</strong> contient simplement du code <strong>MSIL</strong> ainsi que la version des outils utilisés par la <strong>tool chain</strong> pour compiler votre application (pour les curieux, cette liste est référencée dans le fichier <strong>AppxManifest.xml </strong>, disponible dans les répertoires de compilation).</p>
<p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/3034.image_3F2A0FFF.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/3073.image_thumb_10D31B03.png" alt="image" width="642" height="214" border="0" /></a></p>
<p align="justify">L’étape suivant se déroule <em>in the cloud</em>, le <strong>Windows Store</strong> prend le relais et va se charger de recompiler l’application en code natif lorsque vous soumettez votre package. L’intérêt ne saute pas aux yeux tout de suite mais l’initiative permet au store une  petite liberté : il va recompiler votre application (de manière transparente pour vous) si des optimisations ou correctifs sont effectués dans les outils de la <strong>.NET Native tool chain</strong>. Ce petit détail implique deux choses pour vous.</p>

<ol>
	<li>
<div align="justify"><strong>Vous n’avez désormais plus accès au numéro de révision de l’application</strong> (les trois premiers chiffres du numéro de version vous appartiennent toujours, c’est simplement le dernier qui est préempté par le store – il sera incrémenté à chaque recompilation made in cloud).</div></li>
	<li>
<div align="justify">Comme l’application n’est pas compilée localement,<strong> les symboles de debug (*.pdb) sont générés également pour vous.</strong> Vous pouvez les télécharger depuis le <strong>Windows Dev Center</strong> dans la rubrique packages actuels.</div></li>
</ol>
<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/1778.symbols_29D17BF9.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="symbols" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/8662.symbols_thumb_18ECD809.png" alt="symbols" width="642" height="291" border="0" /></a>
<p align="justify">J’espère que ces quelques lignes vous seront bénéfiques, n’hésitez pas à me contacter - via ce blog ou twitter (<a href="https://twitter.com/dupuyjs">@dupuyjs</a>) - pour tout commentaire ou question.</p>]]></content:encoded>
    </item>
    <item>
      <title>#Zone61 : Guide pour configurer votre carte Arduino Yún</title>
      <link>https://docs.microsoft.com/archive/blogs/jdupuy/zone61-guide-pour-configurer-votre-carte-arduino-yn</link>
      <pubDate>Thu, 22 Jan 2015 07:40:54 GMT</pubDate>
      <dc:creator><![CDATA[Jean-Sébastien Dupuy [Microsoft]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jdupuy/2015/01/22/zone61-guide-pour-configurer-votre-carte-arduino-yn/</guid>
      <description><![CDATA[Avant de vous lancer dans le code et l’électronique de votre projet #Zone61 ; voici quelques...]]></description>
      <content:encoded><![CDATA[<p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/2110.sticker_218A64C1.png"><img class=" alignright" style="float: right;padding-top: 0px;padding-left: 0px;margin: 0px 0px 0px 20px;padding-right: 0px;border: 0px" title="sticker" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/8308.sticker_thumb_1EE439C1.png" alt="sticker" width="265" height="265" align="right" border="0" /></a>
Avant de vous lancer dans le code et l’électronique de votre projet <a href="http://zone61.bemyapp.com/">#Zone61</a> ; voici quelques étapes pour vérifier que tout fonctionne bien entre votre ordinateur et la carte Yún ! Et comme cet évènement s’appuie également sur Microsoft Azure, vous apprécierez certainement une petite explication de texte sur la configuration WiFi ce cette même carte.</p>
<p align="justify">Bref, comment débuter avec votre carte Arduino Yún?</p>

<h2>Logiciels</h2>
<p align="justify">Télécharger la version intitulée <strong>Arduino 1.5.8 BETA (with support for Arduino Yún and Arduino Due boards)</strong> depuis <a title="http://arduino.cc/en/main/software" href="http://arduino.cc/en/main/software">http://arduino.cc/en/main/software</a>. Comme son nom l’indique cette version est la seule à supporter actuellement les cartes Yún et Due.</p>

<h2>Shield de base Grove</h2>
<p align="justify">Pour débuter et vérifier que tout fonctionne correctement, positionnez le <strong>Shield</strong> de base Grove sur la carte <strong>Arduino</strong>.</p>

<blockquote>
<p align="justify"><strong>Attention:</strong> les connecteurs du Shield risquent de toucher le port Ethernet de la carte Arduino, assurez vous qu’ils ne rentrent pas en contact <span style="text-decoration: underline">avant</span> d’alimenter la carte. Placez un carton entre les deux ou un autre isolant si vous souhaitez garantir la pérennité de votre matériel ^^ (oui, c’est aussi l’esprit makers, on bricole déjà la carte).</p>
</blockquote>
<p align="justify">Commencez par le support LED avec votre couleur préférée en évitant de confondre les bornes positives et négatives. :)</p>
<p align="justify">Reliez ensuite le support LED à la base Grove en utilisant une des fiches de D2 à D8 ; ce sont les entrées/sorties numériques. Dans mon exemple, j’utiliserai la fiche D6.</p>
<p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/3022.WP_20150121_17_35_11_Pro_648B5490.jpg"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="WP_20150121_17_35_11_Pro" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/2308.WP_20150121_17_35_11_Pro_thumb_21AF1016.jpg" alt="WP_20150121_17_35_11_Pro" width="642" height="362" border="0" /></a></p>

<h2>Alimentation de la Yún</h2>
<p align="justify">Pour alimenter la carte Yún, il est simplement nécessaire de raccorder celle-ci à votre ordinateur à l’aide d’un câble <a href="http://fr.wikipedia.org/wiki/Universal_Serial_Bus#Les_premiers_connecteurs_:_les_types_A_et_B">USB micro-B</a> (théoriquement le type de câble que vous utilisez pour charger vos smartphones). Il servira également à transmettre les données sur la carte Yùn depuis l’IDE Arduino</p>
<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/4863.YunParts_1855DB93.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="YunParts" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/5481.YunParts_thumb_682E90CF.png" alt="YunParts" width="640" height="426" border="0" /></a>
<h2>Premiers pas</h2>
<p align="justify">Lancez maintenant l’IDE Arduino et assurez-vous que la carte Arduino Yún est bien sélectionnée dans le menu [<strong>Tools</strong>][<strong>Board</strong>] comme ci-dessous.</p>
<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/3757.image_658865CF.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/8004.image_thumb_473DAED9.png" alt="image" width="617" height="480" border="0" /></a>
<p align="justify">De même, assurez-vous que <strong>COMx</strong><strong> (Arduino Yún)</strong> est bien sélectionnée dans le menu [<strong>Port</strong>]. Si ce menu n’est pas disponible, il est probable que le câble utilisé soit défectueux ou de type A.</p>
<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/6371.image_16AA3121.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/7713.image_thumb_3B3E4F56.png" alt="image" width="617" height="480" border="0" /></a>
<p align="justify">Le menu [<strong>File</strong>][<strong>Examples</strong>] a la délicate attention de nous proposer des programmes prêt à l’emploi ; pour respecter la typologie Arduino, ces programmes seront nommés des Sketchs dans le reste de l’article. Pour s’assurer que tout fonctionne bien, sélectionnez le sketch <strong>Blink</strong> dans la section <strong>01.Basics</strong>.</p>
<p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/8311.image_0AAAD19E.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/6116.image_thumb_7EA8E169.png" alt="image" width="502" height="316" border="0" /></a></p>
La structure d’un Sketch est très <span style="color: #424242">simple et comprend deux fonctions:</span>
<ul>
	<li><strong>Setup </strong>qui s’exécute une unique fois lorsque le sketch est téléchargé ou lors d’un arrêt/redémarrage de la carte. Ce point d’entrée permet donc d’initialiser les capteurs et vos variables.</li>
	<li><strong>Loop</strong><span style="color: #333333">, comme son nom l’indique, exécute ensuite du code en boucle.</span></li>
</ul>
Le Sketch Blink propose de faire clignoter votre LED toutes les secondes. Modifiez simplement le Sketch pour utiliser la borne 6 au lieu de la 13.

Les bornes D2 à D8 sont configurables en entrée ou sortie. La fonction <span style="color: #009bc2">pinMode </span>permet donc de préciser que D6 sera utilisée en sortie. <span style="color: #009bc2">digitalWrite </span>change ensuite la valeur de notre sortie chaque seconde.
<code></code>
<div id="codeSnippetWrapper" class="csharpcode-wrapper">
<pre id="codeSnippet">// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 6 as an output.
  pinMode(6, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(6, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(6, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}</pre>
</div>
<p align="justify">Le langage utilisé par <strong>Arduino</strong> est une version simplifiée de C/C++ qui s’appuie sur <strong>Wiring</strong> (même si les initiatives sont désormais séparées). Pour accéder à l’ensemble des primitives, je vous invite à consulter <a title="http://arduino.cc/en/pmwiki.php?n=Reference/HomePage" href="http://arduino.cc/en/pmwiki.php?n=Reference/HomePage">Language Reference</a>.</p>

<p align="justify">Il ne reste plus qu’à télécharger le Sketch sur la carte; et si tout se passe sans accros … la diode clignote. On vient au moins de déterminer que les basiques fonctionnent parfaitement !</p>
<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/4744.image_144EB3F4.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/2110.image_thumb_582578FC.png" alt="image" width="240" height="38" border="0" /></a>
<p align="justify">Malgré tout le bien que je pense des outils <strong>Arduino</strong>, on peut regretter que l'IntelliSense ne soit pas présent - ainsi que de pouvoir positionner quelques breakpoints dans notre code (en tout ca je n’ai pas trouvé l’option). Et bien il existe une solution pour palier à ce problème – un plugin Visual Studio nommé Visual Micro répond parfaitement à cette demande. Et il s’installe parfaitement avec l’édition <a href="http://www.visualstudio.com/fr-fr/downloads/download-visual-studio-vs.aspx">Visual Studio Community 2013</a> !</p>
<p align="justify">Certes, cette solution est payante mais une version d’évaluation est disponible sur le site suivant:</p>
<a title="http://www.visualmicro.com/page/Arduino-Visual-Studio-Downloads.aspx" href="http://www.visualmicro.com/page/Arduino-Visual-Studio-Downloads.aspx">http://www.visualmicro.com/page/Arduino-Visual-Studio-Downloads.aspx</a>

Et cerise sur le gâteau, j’ai quelques clés d’activation à vous faire gagner pendant le Hackathon.
<p align="justify"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/1715.image_thumb_2D88BD8D.png" alt="image" width="642" height="468" border="0" /></p>
&nbsp;
<h2>Réseau / Configuration du WiFi</h2>
<p align="justify">La carte Yún a l’avantage de supporter deux options pour vous connecter au réseau : Ethernet et le WiFi. Usine.IO ne sera pas câblé en filaire, donc vraisemblablement, le choix du WiFi va vite s’imposer :).</p>
<p align="justify">Lors du démarrage de la carte, elle va déclarer automatiquement un réseau WiFi intitulé Arduino Yun-XXXXXXXXXXXX. Connectez vous à ce réseau depuis votre ordinateur ou votre smartphone.</p>
<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/7651.image_5FF4882F.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/4370.image_thumb_723FDFA2.png" alt="image" width="292" height="482" border="0" /></a>
<p align="justify">Là où ca se complique, c’est lorsque 30 cartes se déclarent comme réseau WiFi en même temps ^^. Pour vous y retrouver, lancer le Sketch <strong>WiFiStatus</strong> disponible via [<strong>File</strong>][<strong>Examples</strong>][<strong>Bridge</strong>]. Après quelques secondes d’attente, la console <strong>Serial Monitor</strong> dans [<strong>Tools</strong>] affiche le nom de votre réseau (<strong>SSID</strong>).</p>
<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/0272.image_53F528AC.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/0647.image_thumb_5CE4BAEB.png" alt="image" width="640" height="313" border="0" /></a>
<p align="justify">Une fois connecté au réseau WiFi, naviguez vers <a href="http://arduino.local">http://arduino.local</a> -ou- directement <a href="http://192.168.240.1">http://192.168.240.1</a> si la première option ne fonctionne pas.</p>
<p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/5857.image_13556CEE.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/2642.image_thumb_5C0EE5B2.png" alt="image" width="640" height="356" border="0" /></a></p>
Le mot de passe par défaut est <strong>arduino</strong>.

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/2185.image_72648AF7.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/0407.image_thumb_5419D401.png" alt="image" width="620" height="480" border="0" /></a>

Vous pouvez dès lors configurer le réseau WiFi et changer le nom de votre carte. Appuyez sur “Configure &amp; Restart” pour finaliser l’opération et redémarrer la Yun !

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/7367.image_5173A901.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/0842.image_thumb_67C94E46.png" alt="image" width="640" height="324" border="0" /></a>

Vous pouvez relancer ensuite le Sketch WiFiStatus pour vous assurez que le WiFi est bien configuré.

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/0702.image_40FDC8B7.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/5047.image_thumb_070E85CB.png" alt="image" width="500" height="300" border="0" /></a>
<p align="justify">Si les choses se compliquent et que vous souhaitez revenir à la configuration usine du WiFi : pressez le bouton WLAN RST pendant au minimum <strong>5 secondes</strong> (mais surtout moins de <strong>30 secondes</strong> – dans ce cas vous restaurez l’environnement linux). Plus d’information concernant cette procédure sur le site <a title="http://arduino.cc/en/Main/ArduinoBoardYun" href="http://arduino.cc/en/Main/ArduinoBoardYun">http://arduino.cc/en/Main/ArduinoBoardYun</a>.</p>
<img class=" aligncenter" style="float: none;margin-left: auto;margin-right: auto" title="" src="http://arduino.cc/en/uploads/Main/YunResetIllustrations.png" alt="" width="500" />

&nbsp;

Tout fonctionne ? Right. On est fin prêt pour passer aux choses sérieuses.
<h2>Se connecter au monde (et notamment à Microsoft Azure)</h2>
<p align="justify">La carte Yun a une particularité, le microcontrôleur ATmega 32U4 est complété par un processeur Atheros AR9331 qui permet de faire tourner une distribution de Linux basée sur OpenWrt. Pour faire cohabiter les deux mondes, Arduino met à disposition plusieurs librairies; et notamment &lt;Process.h&gt; qui permet de lancer des commandes <strong>curl</strong> linux sans se soucier des deux environnements.</p>
<p align="justify">Par exemple, le sketch suivant effectue une requête HTTP GET pour télécharger le logo Arduino en mode ASCII.</p>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
<pre id="codeSnippet" class="csharpcode"><span class="preproc">#include</span> &lt;Process.h&gt;

<span class="kwrd">void</span> setup() {
   <span class="rem">// Initialize Bridge</span>
   Bridge.begin();

   <span class="rem">// Initialize Serial</span>
   Serial.begin(9600);

   <span class="rem">// Wait until a Serial Monitor is connected.</span>
   <span class="kwrd">while</span> (!Serial);

   <span class="rem">// run various example processes</span>
   runCurl();
}

<span class="kwrd">void</span> loop() {
   <span class="rem">// Do nothing here.</span>
}

<span class="kwrd">void</span> runCurl() {
   <span class="rem">// Launch "curl" command and get Arduino ascii art logo from the network</span>
   <span class="rem">// curl is command line program for transferring data using different internet protocols</span>
   Process p;        <span class="rem">// Create a process and call it "p"</span>
   p.begin(<span class="str">"curl"</span>);  <span class="rem">// Process that launch the "curl" command</span>
   p.addParameter(<span class="str">"http://arduino.cc/asciilogo.txt"</span>); <span class="rem">// Add the URL parameter to "curl"</span>
   p.run();      <span class="rem">// Run the process and wait for its termination</span>

   <span class="rem">// Print arduino logo over the Serial</span>
   <span class="rem">// A process output can be read with the stream methods</span>
   <span class="kwrd">while</span> (p.available()&gt;0) {
     <span class="kwrd">char</span> c = p.read();
     Serial.print(c);
   }
   <span class="rem">// Ensure the last bit of data is sent.</span>
   Serial.flush();
}</pre>
&nbsp;

</div>
Vous pouvez ensuite ouvrir la fenêtre <strong>Serial Monitor</strong> et lancer le Sketch !

<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/2437.image_5A515A3C.png"><img class=" aligncenter" style="float: none;padding-top: 0px;padding-left: 0px;margin-left: auto;padding-right: 0px;margin-right: auto;border: 0px" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/7673.image_thumb_2951A98F.png" alt="image" width="255" height="480" border="0" /></a>
<p align="justify">En utilisant le même mécanisme, Thomas Conté (<a href="https://twitter.com/tomconte">@tomconte</a>) a publié plusieurs articles pour connecter la Yun aux services Microsoft Azure. #Zone61 n’impose pas d’architecture spécifique pour Azure, c’est à vous de faire le choix - héberger un web service - transmettre les données à un service de stockage - utiliser Event Hubs - sont tous des choix légitimes selon vos besoins.</p>
<p align="justify"><a href="http://hypernephelist.com/2014/08/19/https_on_arduino_yun.html">Securing communications with HTTPS on the Arduino Yun</a>
<a href="https://github.com/dx-ted-emea/iot-labs/blob/master/lab1-temperature%20sensor/yun-to-event-hub.md">Connecting the Arduino Yun to Azure Event Hubs</a></p>

<h2>Pour aller plus loin</h2>
<a href="http://arduino.cc/">Site officiel Arduino</a>
<a href="http://arduino.cc/en/Guide/ArduinoYun">Communicating with OpenWrt-Yun via Bridge</a>
<a href="http://arduino.cc/en/Tutorial/Bridge">Bridge</a>
<a href="http://www.seeedstudio.com/wiki/Grove_-_Starter_Kit_v3">Grove - Starter Kit v3</a>
<a href="https://github.com/Seeed-Studio/Sketchbook_Starter_Kit_V2.0">Grove – Starter Kit </a>
<a href="https://github.com/Seeed-Studio/Sketchbook_Starter_Kit_V2.0">SketchBook</a>

Documentation <a href="http://www.visualmicro.com/">Visual Micro</a> (si vous utiliser le plug-in)

Et bien évidemment <a href="http://azure.microsoft.com/fr-fr/">Microsoft Azure</a> :)

Maintenant à vous de jouer ! Bon courage à tous.]]></content:encoded>
    </item>
    <item>
      <title>TechDays 2015 : A la découverte du parcours développement applications mobiles.</title>
      <link>https://docs.microsoft.com/archive/blogs/jdupuy/techdays-2015-a-la-dcouverte-du-parcours-dveloppement-applications-mobiles</link>
      <pubDate>Mon, 19 Jan 2015 04:28:00 GMT</pubDate>
      <dc:creator><![CDATA[Jean-Sébastien DUPUY]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jdupuy/2015/01/19/techdays-2015-a-la-dcouverte-du-parcours-dveloppement-applications-mobiles/</guid>
      <description><![CDATA[Nous voilà en approche de l’édition 2015 des TechDays ! Besoin d’un peu d’aide pour vous y...]]></description>
      <content:encoded><![CDATA[<p><img style="float: none; margin-left: auto; display: block; margin-right: auto" src="https://techdays.microsoft.fr/images/2015/logos/logo_mstechdays.png" /></p>  <p align="justify">Nous voilà en approche de l’édition 2015 des <a href="https://techdays.microsoft.fr/">TechDays</a> ! Besoin d’un peu d’aide pour vous y retrouver dans le parcours développement d’applications ? Voici l’intégralité des sessions qui seront proposées. </p>  <p align="justify">Toutefois, développeurs, avant de vous plonger dans ces sessions, notez que d’autres parcours connexes seront également susceptible de vous intéresser et ne sont pas listés dans ce billet. C’est le cas du <a href="https://techdays.microsoft.fr/programmes/2015/recherche-sessions.aspx?#d=64c3a46f-bd2b-4f7e-8d33-3c95277f51cb&amp;Page=1">Design</a>, de l’<a href="https://techdays.microsoft.fr/programmes/2015/recherche-sessions.aspx?#d=41f791c4-1e00-401a-8a31-b9796964fdf4&amp;Page=1">Architecture, Outils, Plateformes &amp; Langages</a>, du <a href="https://techdays.microsoft.fr/programmes/2015/recherche-sessions.aspx?#d=a28813e8-010d-42b1-af92-84a739f83702&amp;Page=1">Développement Web</a>, et du parcours <a href="https://techdays.microsoft.fr/programmes/2015/recherche-sessions.aspx?#d=eee1f10d-d999-4acd-b737-72508ab5eeb5&amp;Page=1">DevOps</a>. Des sessions sur l’IoT et ciblant les Makers sont également au programme tout au long des 3 jours !&#160; </p>  <p align="justify">La première journée débutera comme à son habitude par une Keynote consacrée aux développeurs - <a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=08273927-e7e6-4004-a492-79d16f219158">new Keynote() { cloudFirst=true, mobileFirst=true }.Connect();</a> - bien évidemment à ne pas manquer. </p>  <p align="justify">Plusieurs nouveautés font leur apparition cette année, notamment&#160; l’arrivée de sessions en mode HOL (Hands On Labs) pour directement mettre les mains dans le code ; ainsi que des “keynote secondaires” en guise d’introduction et de synthèse pour les thèmes principaux.&#160; Le parcours développement d’applications mobile n’échappe pas à la règle : cette keynote parlera bien évidemment d’applications universelles pour développer des applications Windows Store ; mais également de l’outillage présenté lors de l’évènement <a href="https://channel9.msdn.com/Events/Visual-Studio/Connect-event-2014">Connect()</a> pour cibler du multi plateformes. </p>  <p align="justify">Cette session sera animée par :</p>  <ul>   <li>     <div align="justify"><strong>Rudy Hyun</strong> (6Studio) pour parler des applications universelles en C#/Xaml, et de la monétisation. </div>   </li>    <li>     <div align="justify"><strong>Guillaume Leborgne</strong> (MCNECT) effectuera ensuite la transition pour présenter les nouveautés de WinJS ainsi que de Cordova.</div>   </li>    <li>     <div align="justify"><strong>Cyril Cathala</strong> (Soat) terminera sur une note de Xamarin !</div>   </li>    <li>     <div align="justify"><strong>Sébastien Pertus</strong> et moi-même animeront le reste de la session pour vous donner un maximum de visibilité sur les dernières nouveautés et peut-être quelques surprises. </div>   </li> </ul>  <p align="justify">   <br />Rendez-vous ensuite sur les différentes sessions pour approfondir et détailler cette keynote. Comme promis, voici le guide des sessions.</p>  <p align="justify"><font color="#9b00d3" size="4">La keynote : une synthèse du parcours pour passer en revue toutes les nouveautés.</font></p>  <p align="justify"><font color="#9b00d3" size="3"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=17d0b510-16f0-4a79-8c4f-0ddc1a4b87c2">Keynote développement mobile : les solutions pour Windows (Phone), Android et iOS</a></font></p>  <p align="justify">Développeurs Windows &amp; Windows Phone : partagez un maximum de code pour vos développements en optant pour les applications universelles. Besoin d'une solution pour cibler également Android et iOS ? Visual Studio s'enrichit chaque jour de nouvelles fonctionnalités pour le développement multi plateformes. Au programme de cette session : applications universelles, Cordova, Xamarin, Unity et Visual C++ for Cross-Platform Mobile Development.</p>  <p align="justify"><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=c2cd7851-f980-4b43-8af3-6c65a7b0f4b2">Rudy Huyn</a> (6Studio), <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=d4c54fc3-4363-43cd-8ef4-6cfa6cf867bc">Guillaume LEBORGNE</a> (MCNEXT), <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=d84223fd-1bee-47e8-a80d-f9c6dca9547b">Cyril Cathala</a> (Soat), <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=5dddfd75-6e13-40bc-b272-7cd96d585c02">Sébastien Pertus</a> (Microsoft) &amp; <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=a79c9be4-064b-4e17-ae15-04b6f5618ab8">Jean-Sébastien Dupuy</a> (Microsoft)</p>  <p align="justify"><font color="#333333" size="4"></font></p>  <p align="justify"><font color="#9b00d3" size="4">L’univers Windows Store : les applications universelles !</font></p>  <p align="justify"><font color="#9b00d3" size="3"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=301f882c-2114-4dc9-ae53-12de37c1bf16">Introduction aux applications universelles</a></font></p>  <p align="justify">Il n'y a plus aucun doute quant au fait que les applications universelles représentent le futur des applications pour l'OS de Microsoft. Pouvoir créer une seule application capable de fonctionner sur son PC, sa tablette Windows, son Windows Phone, et pourquoi pas sur XBox ou d'autres périphériques n'est plus une idée utopique, mais quasiment une réalité. C'est en tout cas la stratégie de Microsoft aujourd'hui. Nous vous proposons de voir ensemble les bases pour bien démarrer son application universelle, les ressources à connaître, mais aussi les particularités et autres concepts liés à ce développement, les émulateurs .... Bref, de la création de votre application à sa publication</p>    <p><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=2619e732-3696-4050-a73b-34d8a5e81f97">Florian Rousselet</a> (Soat) &amp; <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=eadb6cec-2c9e-41eb-bd0f-c59a8e530a7c">Sébastien Thevenin</a> (Soat)</p>  <p><font color="#9b00d3" size="3"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=a24d11b3-c658-45e5-a490-1c5fba6723ae">Windows Phone: Migrez de Silverlight vers Universal App, Préparez vous à Windows 10</a></font></p>  <p align="justify">Les différences entre les Silverlight apps et Universal apps sont grandes et vous avez peur de repartir de zéro ? Venez découvrir les astuces et les outils indispensables pour faciliter cette migration et passer d'une technologie à l'autre rapidement tout en préparant vos applications à Windows 10 !</p>  <p><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=299d49b1-12b5-47b4-b6a3-36d994fdfb51">Julien Lo Presti</a> (Soat) &amp; <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=c2cd7851-f980-4b43-8af3-6c65a7b0f4b2">Rudy Huyn</a> (6Studio)</p>  <p><font color="#9b00d3" size="3"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=7aa4c099-6a39-4eff-968d-21587982d9ed">Développer des applications Windows Store pour l'entreprise</a></font></p>  <p align="justify">Les applications métier développées pour les besoins d'entreprise (encore appelées applications Line of Business – LOB), ont des caractéristiques particulières qui les distinguent des applications grand public. Nous aborderons dans cette session les impacts que cela peut avoir sur le développement, en terme d'architecture et d'intégration avec des backends.    <br />Nous discuterons aussi de l'intégration entre les mondes Modern UI et Desktop sur Windows 8.1, et de la réutilisation de code issu de Windows Mobile, et bien sur des problématiques de déploiement des applications en dehors des stores Microsoft.</p>    <p><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=919aeec7-7eda-43ce-826f-4e7dd4fcb189">Michael Durand</a> (Avanade) &amp; <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=7f8a275d-e954-4e7b-81ac-515c5d7e75a8">Thomas Lebrun</a> (Infinite Square)</p>  <p><font color="#00749e" size="3">Créer une application Windows (Phone) sans toucher une ligne de code avec Windows App Studio</font></p>  <p align="justify">Le Windows App Studio est un service en ligne gratuit permettant de créer des applications mobiles pour Windows Phone et Windows. Après une rapide introduction, nous nous lancerons ensemble dans la création d’une application. Cette session est principalement destinée aux débutants qui n’ont pas de compétence de développement mais qui souhaitent se lancer dans l’aventure de la création d’application mobile. En effet, grâce au Windows App Studio, nous n’aurons pas besoin de toucher à une seule ligne de code !</p>  <p align="justify"> <strong>Nouveau format pour cette édition des TechDays : cette session sera délivrée sous forme de lab !</strong></p>  <p>Anthony Virapin (Microsoft), Sherley Frydman (Microsoft)</p>  <p>&#160;</p>  <p align="justify"><font color="#9b00d3" size="4">Besoin de cibler également Android &amp; iOS : la création d’applications multi plateformes.</font></p>  <p align="justify"><font color="#9b00d3" size="3"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=202764f7-18b0-4bd0-a9a2-e57ee0c3b21e">Applications multi plateformes avec Cordova, HTML5 et Javascript</a></font></p>  <p align="justify">A travers Microsoft Open Technologies, Microsoft participe à de nombreux projets open source comme par exemple Apache Cordova. Nous vous présenterons comme tirer le meilleurs parti des outils Microsoft pour développer une application sur iOS, Android et Windows en utilisant HTML, Javascript et Cordova. Au menu : les outils en ligne de commandes, Visual Studio, un émulateur Android qui booste et du débug à distance sur un Mac !</p>  <p><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=c262f2da-5c77-4f9f-9c35-a035bbf70dac">Eric Mittelette</a> (Microsoft) &amp; <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=abeda148-4086-4c37-82be-d14c9be5a55e">Etienne Margraff</a> (Microsoft)</p>  <p><font color="#9b00d3" size="3"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=dc451e3b-fbb4-4431-a02f-14fcbf831243">Développement cross-plateforme sans compromis avec Xamarin</a></font></p>  <p align="justify">Après une rapide introduction à Xamarin, l'outil de création d'applications multi plateformes natives en C#, nous verrons comment (ré)organiser une application pour partager un maximum de code entre les plateformes. Nous exposerons les différentes possibilités et mettrons l'accent sur Xamarin.Forms, allant jusqu'à créer nos propres composants visuels. <strong>Cette session sera délivrée en anglais.</strong></p>  <p><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=8aaf17ff-57c5-4b56-932b-03b951835053">Alex Danvy</a> (Microsoft) &amp; <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=5fe396e8-a74f-44c9-9835-932120cb47b3">Mike James</a> (Xamarin)</p>  <p><font color="#00749e" size="3">Développez vos jeux multiplateformes grâce à Unity3D avec Visual Studio en C#</font></p>  <p>Dans cette session, vous découvrirez comment il est possible de créer un jeu-vidéo avec Unity3D. Vous apprendrez à utiliser l’éditeur et ses différents modules, le moteur physique, le scripting, les scènes, la caméra et plus encore ! Finalement, nous créerons des packages Android, iOS et Windows prêts à être déployés sur les différents Stores !</p>  <p><strong>Nouveau format pour cette édition des TechDays : cette session sera délivrée sous forme de lab !</strong></p>  <p>Jonathan Antoine (Infinite Square) &amp; Maxime Frappat (Infinite Square)</p>  <p>&#160;</p>  <p align="justify"><font size="4"><font color="#9b00d3">Cortana, Capptain, Azure Mobile Services … des fonctionnalités, du back office et des retours d’expérience pour inspirer vos applications mobiles</font>.</font></p>  <p align="justify"><font color="#9b00d3" size="3"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=5c0af911-c6d8-4148-a976-010e75eff0a6">Fonctions vocales sous Windows Phone : intégrez votre application à Cortana !</a></font></p>  <p align="justify">Cortana a pris des cours de français ! Elle est désormais disponible en version alpha sous Windows Phone. Profitez de ce lancement pour mettre à jour vos applications et les intégrer simplement à Cortana. Au programme : Cortana, les fonctions vocales (Commandes, Reconnaissance, Synthèse) et le contextual awareness. En bref, donnez la parole à vos applications !</p>  <p align="justify"><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=4590fe5d-653d-468d-8442-d0dc8465904f">Caroline Constantin</a> (Microsoft) &amp; <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=a79c9be4-064b-4e17-ae15-04b6f5618ab8">Jean-Sébastien Dupuy</a> (Microsoft)</p>  <p align="justify"><font color="#9b00d3" size="3"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=a8fe7c20-1f18-46fc-991f-2733d534a5c9">Bluetooth Low Energy dans les applications Windows</a></font></p>  <p align="justify">Le Bluetooth Low Energy est un des protocoles clé de l'Internet des objets. Montres, bracelets, ampoules et autres portes clés l'exploitent à merveille. Venez en comprendre ses principes, son fonctionnement et sa mise en oeuvre au sein d'une application Windows Universelle au travers d'un exemple très simple que vous pourrez reproduire chez vous à moindre frais. Nous développerons une station météo connectées avec l'application mobile qui l'accompagne.</p>  <p align="justify"><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=fac26de2-a5ec-402a-a138-5c56b161bd8a">Stéphane Sibué</a> (GUYZMO)</p>  <p align="justify"><font color="#9b00d3" size="3"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=0ba7d667-3ded-4473-9eba-11297dedb08f">Faites comme Netflix, voire mieux : diffuser de la VOD et du Live dans le monde entier avec Azure et les Frameworks Clients pour atteindre n'importe quels devices !</a></font></p>  <p align="justify">Venez voir nos experts et apprendre comment vous pouvez créer votre propre Netflix sécurisé dans Azure grâce à une combinaison subtile d'Azure Media Services, d'Azure Mobile Services, SQL Database, Azure Active Directory &amp; Notification Hubs d'un point de vue cloud. Mais pas que, nous verrons également les Frameworks clients (HTML5 avec les extensions MSE &amp; EME, Player Framework, JWPlayer et Cordova) permettant de jouer des flux vidéos sur les différentes plateformes clients (iOS, Android, Windows…).</p>  <p align="justify"><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=6f04d8f3-a933-4796-ac3a-fa9a0c37e4ce">Julien Corioland</a> (Infinite Square), <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=64e473dd-47c3-48d1-a58e-2d7e4a381c46">Frédéric Le Coquil</a> (Microsoft) &amp; <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=d9d8580c-e8c0-41ba-9886-7e9e2d4c5d96">Benjamin Moulès</a> (Microsoft)</p>  <p align="justify"><font color="#9b00d3" size="3"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=16e560a7-11ef-45de-aea7-6d6de5d18686">Lumia Imaging SDK &amp; Win2D : Entre gestion d'images et création d'interfaces graphiques complexes</a></font></p>  <p align="justify">La manipulation d'image peut être une opération très couteuse en performances et qui ne pardonne pas si elle est mal employée. Les API Win2D ou le Lumia Imaging SDK, utilisables avec du C# ou du C++, permettent d'optimiser de façon drastique, les performances qui peuvent y être associés grâce à la puissance de l'accélération matérielle.    <br />Nous vous proposons pendant cette session de découvrir Win2D et la dernière version du SDK Imaging de Nokia, de survoler les différences entre GPU &amp; CPU et voir comment, il est possible de créer une application nécessitant du traitement d'images performant. Puis, Enfin, nous verrons comment créer des interfaces graphiques impossible à réaliser en XAML via Win2D</p>  <p align="justify"><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=4031ccb3-2bb1-4969-b62e-0cc062405539">Christopher Maneu</a> (Deezer) &amp; <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=4031a158-f486-46b7-944d-b5bf008fa212">David Poulin</a> (Soat)</p>  <p align="justify"><font color="#9b00d3" size="4"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=2debf52f-a9db-4112-bb7b-1caa05688479">Personnaliser et piloter l'expérience client sur les applications mobile avec Capptain</a></font></p>  <p align="justify">Les dernières années ont vu fleurir la mise en place des collectes de données, qui deviennent de plus en plus fructueuses. Au coeur de ces évolutions qui mêlent marketing et technologie, Capptain est la solution qui compte dans l'écosystème du Big Data et son exploitation par le marketing. Venez apprendre comment faire parler la data et utiliser le mobile comme un nouveau canal d'engagement stratégique pour les entreprises. </p>  <p align="justify"><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=ed3f2d50-057a-40df-9244-16b6723c9f9e">Youssef Faury</a> (Microsoft)</p>  <p><font color="#9b00d3" size="3"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=6b7ca77d-25ee-4530-91f3-aff85b625cce">Back Office pour applications mobiles</a></font></p>  <p align="justify">Marre de l'intégration graphique ? Lassé d'enchainer les formulaires de saisie de données ? Le prochain qui vient vous parler du 17ème changement de couleur du bouton de validation va passer un sale quart d'heure ?    <br />C'est le moment de changer de vie et de découvrir comment l'utilisation d'Azure Mobile Services permet aux développeurs back-end de faire le gros du travail en quelques minutes : stockage de données, synchronisation des data hors-ligne, authentification multiple (Facebook, Twitter, Azure Active Directory, etc.), gestion des push notif, etc.     <br />Evidemment, ça fonctionne en multiplateforme, gère le cache et adapte sa consommation en fonction de la charge. La cerise sur le gâteau ? C'est en production depuis deux ans et continue d'intégrer de nouvelles fonctionnalités tous les trimestres. Alors sautez le pas et venez découvrir cette plateforme qui connectera votre prochaine application au cloud Azure.</p>  <p align="justify"><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=a2910d26-b27d-49dd-8811-51818b0a655e">Audrey Petit</a> (Microsoft) &amp; <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=1fac76e6-9460-4adc-b0f3-94ea54060f97">Nicolas Clerc</a> (Microsoft)</p>  <p align="justify"><font color="#9b00d3" size="4"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=041abd96-50da-4f80-afbb-205baa19def4">Stratégie mobile de Meetic sur Windows</a></font></p>  <p align="justify">Les usages d'aujourd'hui sont en passe de devenir majoritairement mobiles. Leader européen des sites de rencontres, Meetic est un pionner du web français. Historiquement orientée vers le Desktop, l'entreprise se transforme en profondeur pour s'adapter aux nouveaux usages. Je vous propose une immersion au coeur de cette mutation. On parlera de l'histoire de Windows chez Meetic. Comment l'équipe s'est organisée autour de l'agilité, de quelle manière nous construisons nos applications avec des tests et une industrialisation complète des applications Phone et Universelle. Enfin nous parlerons des métriques autour de la qualité sur les technologies mobiles Microsoft.</p>  <p align="justify"><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=c30d9a5f-c8e5-4880-904d-48d199f3798b">Thomas Salandre</a> (Meetic) &amp; <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=b63b1249-0f43-42b9-855a-6fd1eec31bcc">Jean-Loup Yu</a> (Meetic)</p>  <p align="justify"><font color="#9b00d3" size="3"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=fdf9aa8f-6258-42bf-b709-c3fcd77af355">Val d'Isère</a></font></p>  <p align="justify">Les experts SQLI ont réinventé l'expérience de la station Val d'Isère en réalisant une application mobile qui permet la récupération de&#160; toute la data des vacanciers pour mieux servir et enrichir l'expérience Client.</p>    <p>Celle-ci offre en outre de multiples fonctionnalités telles que :</p>  <ul>   <li>des itinéraires sur mesure en fonction du profil du skieur</li>    <li>l’« Augmented Skiing », un service inédit pour l’orientation et le guidage sur le domaine skiable</li>    <li>la smart alarm, qui vous réveille en fonction de la météo la plus favorable</li>    <li>la digitalisation des points de vente avec des bornes Beacon</li>    <li>de la gamification</li>    <li>des reporting permettant de connaître votre performance en temps réel et de la partager sur les réseaux sociaux</li>    <li>un selfski : le selfie du ski</li> </ul>  <p>   <br /><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=538b2da8-03f7-4c60-91d9-718fa113f1f0">Thomas Gayet</a> (SQLI)</p>  <p align="justify"><font color="#9b00d3" size="4">Bonus Track</font></p>  <p align="justify">Et si vous arrivez à la fin de ce parcours, vous aurez probablement besoin de vous détendre les neurones. Parfait, j’ai les sessions qu’il vous faut !</p>  <p align="justify"><font size="3"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=6b2a4b61-2f29-49cb-b428-72e3956501a7">Coding4Fun</a></font></p>  <p align="justify">La session Coding4Fun est une session à part. L'objectif est de se rassembler autour de notre passion : le code, mais dans un grand moment de n'importe quoi. Cette année plusieurs speakers (et non des moindres !) se relayeront pour vous faire partager leur passion avec des démos funs, puissantes et bigarées. Inscrivez-vous le plus rapidement possible afin que l'on puisse dimensionner la salle en fonction, car l'année dernière nous avons encore refusé du monde !!!</p>  <p align="justify"><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=8c50da64-2fe3-4910-80eb-1f5b01c8192f">Mitsu Furuta</a> (Sensorit), <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=a17dd15b-6b5c-46f4-afc9-72fa2e3d57d6">Pierre Lagarde</a> (Microsoft), <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=0c64e1d8-3000-4314-911d-79cbd946ee85">David Catuhe</a> (Microsoft), <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=338ceeb2-939f-4055-88bc-9371f17e6c31">David Rousset</a> (Microsoft) &amp; <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=abeda148-4086-4c37-82be-d14c9be5a55e">Etienne Margraff</a> (Microsoft)</p>  <p align="justify"><a href="https://techdays.microsoft.fr/programmes/2015/fiche-session.aspx?ID=74426b9c-3037-4d4c-b8ee-a79e510ffee9"><font size="4">Geek is in da {new} House</font></a></p>  <p>Cette année nos geeks ont presque tous déménagé. Nouveaux logements --&gt; Nouveaux projets et nouveaux défis pour &quot;gadgetiser&quot; la maison et le jardin toujours en intégrant la dimension WAF.    <br />C'est dans une chaude ambiance et de la bonne humeur que nous vous accueillerons dans cette 4ème édition de Geek in da House avec comme chaque année de la geekerie de qualité française !</p>  <p><a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=0c64e1d8-3000-4314-911d-79cbd946ee85">David Catuhe</a> (Microsoft), <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=74beb304-21d7-4af6-9fc0-a54b38a73885">Stanislas Quastana</a> (Microsoft), <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=e82c8aa1-81ff-4df5-9ffe-d3d19456e496">Arnaud Lheureux</a> (Microsoft), <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=03fec3e3-6112-49f5-a2aa-e3b1f287019e">Sébastien Warin</a> (Microsoft) &amp; <a href="https://techdays.microsoft.fr/speakers/2015/fiche-intervenant.aspx?s=226d643b-e028-4762-bee9-e5a7134a8c98">Laurent Ellerbach</a> (Microsoft)</p>]]></content:encoded>
    </item>
    <item>
      <title>Trois étapes pour intégrer facilement votre application Windows Phone à Cortana</title>
      <link>https://docs.microsoft.com/archive/blogs/jdupuy/trois-tapes-pour-intgrer-facilement-votre-application-windows-phone-cortana</link>
      <pubDate>Fri, 05 Dec 2014 04:00:00 GMT</pubDate>
      <dc:creator><![CDATA[Jean-Sébastien DUPUY]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jdupuy/2014/12/05/trois-tapes-pour-intgrer-facilement-votre-application-windows-phone-cortana/</guid>
      <description><![CDATA[Bonjour, je suis Cortana.  C’était promis depuis son lancement à l’évènement //build/ en avril...]]></description>
      <content:encoded><![CDATA[<p><font color="#9b00d3" size="3">Bonjour, je suis Cortana.</font></p>  <p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/7416.Cortana_FirstRun_Hello_01_15x9_fr-fr_55F19BF6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/7416.Cortana_5F00_FirstRun_5F00_Hello_5F00_01_5F00_15x9_5F00_fr_2D00_fr_5F00_55F19BF6.png"><img title="Cortana_FirstRun_Hello_01_15x9_fr-fr" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: right; padding-top: 0px; padding-left: 0px; border-left: 0px; margin: 0px 5px 0px 20px; display: inline; padding-right: 0px" border="0" alt="Cortana_FirstRun_Hello_01_15x9_fr-fr" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/1070.Cortana_FirstRun_Hello_01_15x9_fr-fr_thumb_0138C3AF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/1070.Cortana_5F00_FirstRun_5F00_Hello_5F00_01_5F00_15x9_5F00_fr_2D00_fr_5F00_thumb_5F00_0138C3AF.png" width="189" align="right" height="354" /></a>C’était promis depuis son lancement à l’évènement <a href="https://channel9.msdn.com/Events/Build/2014/KEY01">//build/</a> en avril dernier, Cortana a pris des cours de français et <a href="http://blogs.windows.com/bloggingwindows/2014/12/05/cortana-arrives-in-france-italy-germany-and-spain-as-a-preview/">arrive sur notre vieux continent</a>. Elle est disponible depuis le 5 décembre, en version Alpha, pour la <strong>France</strong>, l’Espagne, l’Italie et l’Allemagne. Cette mise à jour est principalement adressée aux développeurs pour 1/ participer à l’amélioration du service et nous proposer vos retours et 2/ en profiter pour intégrer vos applications avec Cortana. Pour découvrir la voix française&#160; de Cortana et bénéficier de ses services, il suffit simplement d’être inscrit au programme <a href="http://dev.windows.com/fr-fr/develop/devpreview">Windows Phone Preview pour les développeurs</a> que vous connaissez déjà certainement ! </p>  <p><font color="#9b00d3" size="3">Version alpha ?</font></p>  <p align="justify">Pour développer Cortana, nous utilisons des techniques d’apprentissage automatique (machine learning) afin de construire des modèles de reconnaissance vocale et de compréhension de langage naturel. Pour les améliorer, nous avons besoin d’utilisateurs comme vous pour discuter avec Cortana ; qu’elle suive, en quelque sorte, des cours accélérés de français.</p>  <p align="justify">Cortana ne s’améliorera que si vous interagissez avec elle. En apprenant à vous connaitre au fil du temps, Cortana vous fera des suggestions de plus en plus pertinentes et précises et vous offrira une expérience personnalisée. Si vous souhaitez en découvrir davantage sur Cortana et ses services, rendez-vous sur <a href="http://www.windowsphone.com/fr-fr/how-to/wp8/cortana/meet-cortana">Découvrez Cortana</a>.</p>  <p align="justify">Votre avis compte, n’hésitez pas à nous transmettre vos commentaires : <a href="http://cortana.uservoice.com/">http://cortana.uservoice.com/</a>.</p>  <p><font color="#9b00d3" size="3">Quel rapport avec les développeurs ?</font></p>  <p align="justify">Windows Phone propose des <strong>commandes vocales</strong>. Cette fonctionnalité n’est pas récente, elle a été introduite sous Windows Phone 8.0 et permettait le lancement de votre application par reconnaissance vocale. Même si quelques applications ont joué le jeu, le concept n’a pas forcément été des plus suivi par la communauté et la majorité des applications n’utilisait simplement pas (ou mal) cette fonctionnalité. </p>  <p align="justify"><font color="#424242"><strong>Pour quelles raisons ?</strong></font> Et bien il faut avouer que pour l’utilisateur, la fonctionnalité manquait un peu de visibilité : si un appui long sur le bouton Windows permettait bien de lancer la reconnaissance vocale, ce n’était clairement pas très intuitif. L’activation de nos commandes vocales était donc un peu difficile à dénicher. </p>  <p align="justify">Cortana change la donne, elle prend désormais directement les opérations en main.&#160; Et elle ne se cache pas ! Elle est accessible&#160; par une <strong>vignette dynamique</strong> ou directement par le <strong>bouton recherche </strong>du téléphone, elle devient donc la nouvelle interface pour accéder aux données de Bing. A noter au passage que Cortana n’est pas une assistante uniquement <strong>vocale</strong>, vous pouvez la questionner ou interagir avec elle en mode <strong>textuel</strong> si vous préférez plus d’intimité ^^. </p>  <p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/2210.image_5E07DE7D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/2210.image_5F00_5E07DE7D.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: left; padding-top: 0px; padding-left: 0px; margin: 0px 20px 0px 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/4380.image_thumb_3429FAF9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/4380.image_5F00_thumb_5F00_3429FAF9.png" width="225" align="left" height="340" /></a>Mais revenons aux applications. Cortana permet d’actionner simplement, et en langage naturel, les principales fonctionnalités du téléphone (passer un appel, prendre une note, créer une alarme, …). Et bien vous pouvez dès aujourd’hui étendre ces scénarios et lancer votre application par le biais de nos fameuses commandes vocales.</p>  <p align="justify">Dans le principe, les commandes vocales se mettent en place très rapidement en passant par les trois étapes suivantes: </p>  <table cellspacing="0" cellpadding="2" width="467" border="0"><tbody>     <tr>       <td width="32"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/5488.image_3CAD5A43.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/5488.image_5F00_3CAD5A43.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/5633.image_thumb_57E5B344.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/5633.image_5F00_thumb_5F00_57E5B344.png" width="40" height="40" /></a></td>        <td width="433">1. Création d’un fichier pour définir les commandes vocales </td>     </tr>      <tr>       <td width="32"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/0523.image_654BC64A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/0523.image_5F00_654BC64A.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/3000.image_thumb_3590AE7C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/3000.image_5F00_thumb_5F00_3590AE7C.png" width="40" height="40" /></a></td>        <td width="433">2. Enregistrer les commandes vocales au démarrage de l’application </td>     </tr>      <tr>       <td width="32"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/6242.image_74EE620C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/6242.image_5F00_74EE620C.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/1376.image_thumb_3041C7CB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/1376.image_5F00_thumb_5F00_3041C7CB.png" width="40" height="40" /></a></td>        <td width="433">3. Gérer l’activation des commandes vocales </td>     </tr>   </tbody></table>    <p><font color="#9b00d3" size="3"></font></p>  <p><font color="#9b00d3" size="3">Etape 1. Création d’un fichier pour définir les commandes vocales</font></p>  <p>Ajouter un nouvel élément de type ‘Définition des commandes vocales’ à votre projet.</p>  <p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/6825.image_336F2598.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/6825.image_5F00_336F2598.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; display: block; padding-right: 0px; border-top-width: 0px; margin-right: auto" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/7701.image_thumb_42A58E65.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/7701.image_5F00_thumb_5F00_42A58E65.png" width="640" height="444" /></a></p>  <p align="justify">Que vous développiez en Silverlight 8.1 ou en Windows Runtime 8.1 (Application Universelle), la structure du fichier est identique. </p>  <div>   <pre id="codeSnippet" class="csharpcode"><span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">=&quot;1.0&quot;</span> <span class="attr">encoding</span><span class="kwrd">=&quot;utf-8&quot;</span>?<span class="kwrd">&gt;</span><br /><span class="kwrd">&lt;</span><span class="html">VoiceCommands</span> <span class="attr">xmlns</span><span class="kwrd">=&quot;http://schemas.microsoft.com/voicecommands/1.1&quot;</span><span class="kwrd">&gt;</span><br />  <span class="kwrd">&lt;</span><span class="html">CommandSet</span> <span class="attr">xml:lang</span><span class="kwrd">=&quot;en-us&quot;</span><span class="kwrd">&gt;</span><br />    <span class="kwrd">&lt;</span><span class="html">CommandPrefix</span><span class="kwrd">&gt;</span>tickets<span class="kwrd">&lt;/</span><span class="html">CommandPrefix</span><span class="kwrd">&gt;</span><br />    <span class="kwrd">&lt;</span><span class="html">Example</span><span class="kwrd">&gt;</span>show tonight's events at Olympia<span class="kwrd">&lt;/</span><span class="html">Example</span><span class="kwrd">&gt;</span><br /><br />    <span class="kwrd">&lt;</span><span class="html">Command</span> <span class="attr">Name</span><span class="kwrd">=&quot;showEventsAt&quot;</span><span class="kwrd">&gt;</span><br />      <span class="kwrd">&lt;</span><span class="html">Example</span><span class="kwrd">&gt;</span>show tonight's events at Olympia<span class="kwrd">&lt;/</span><span class="html">Example</span><span class="kwrd">&gt;</span><br />      <span class="kwrd">&lt;</span><span class="html">ListenFor</span><span class="kwrd">&gt;</span> [Show] {eventsViews} at {eventsLocations} <span class="kwrd">&lt;/</span><span class="html">ListenFor</span><span class="kwrd">&gt;</span><br />      <span class="kwrd">&lt;</span><span class="html">Feedback</span><span class="kwrd">&gt;</span> Showing {eventsViews} at {eventsLocations} <span class="kwrd">&lt;/</span><span class="html">Feedback</span><span class="kwrd">&gt;</span><br />      <span class="kwrd">&lt;</span><span class="html">Navigate</span> <span class="attr">Target</span><span class="kwrd">=&quot;HomePage.xaml&quot;</span><span class="kwrd">/&gt;</span><br />    <span class="kwrd">&lt;/</span><span class="html">Command</span><span class="kwrd">&gt;</span><br /><br />    <span class="kwrd">&lt;</span><span class="html">Command</span> <span class="attr">Name</span><span class="kwrd">=&quot;showEventsFrom&quot;</span><span class="kwrd">&gt;</span><br />      <span class="kwrd">&lt;</span><span class="html">Example</span><span class="kwrd">&gt;</span>show tonight's events from Shaka Ponk<span class="kwrd">&lt;/</span><span class="html">Example</span><span class="kwrd">&gt;</span><br />      <span class="kwrd">&lt;</span><span class="html">ListenFor</span><span class="kwrd">&gt;</span> [Show] {eventsViews} from {eventsArtists} <span class="kwrd">&lt;/</span><span class="html">ListenFor</span><span class="kwrd">&gt;</span><br />      <span class="kwrd">&lt;</span><span class="html">Feedback</span><span class="kwrd">&gt;</span> Showing {eventsViews} from {eventsArtists} <span class="kwrd">&lt;/</span><span class="html">Feedback</span><span class="kwrd">&gt;</span><br />      <span class="kwrd">&lt;</span><span class="html">Navigate</span> <span class="attr">Target</span><span class="kwrd">=&quot;HomePage.xaml&quot;</span><span class="kwrd">/&gt;</span><br />    <span class="kwrd">&lt;/</span><span class="html">Command</span><span class="kwrd">&gt;</span><br /><br />    <span class="kwrd">&lt;</span><span class="html">PhraseList</span> <span class="attr">Label</span><span class="kwrd">=&quot;eventsViews&quot;</span><span class="kwrd">&gt;</span><br />      <span class="kwrd">&lt;</span><span class="html">Item</span><span class="kwrd">&gt;</span> tonight's events <span class="kwrd">&lt;/</span><span class="html">Item</span><span class="kwrd">&gt;</span><br />      <span class="kwrd">&lt;</span><span class="html">Item</span><span class="kwrd">&gt;</span> best sellers <span class="kwrd">&lt;/</span><span class="html">Item</span><span class="kwrd">&gt;</span><br />    <span class="kwrd">&lt;/</span><span class="html">PhraseList</span><span class="kwrd">&gt;</span><br /><br />    <span class="kwrd">&lt;</span><span class="html">PhraseList</span> <span class="attr">Label</span><span class="kwrd">=&quot;eventsLocations&quot;</span><span class="kwrd">&gt;</span><br />      <span class="kwrd">&lt;</span><span class="html">Item</span><span class="kwrd">&gt;</span> Olympia <span class="kwrd">&lt;/</span><span class="html">Item</span><span class="kwrd">&gt;</span><br />      <span class="kwrd">&lt;</span><span class="html">Item</span><span class="kwrd">&gt;</span> Bercy <span class="kwrd">&lt;/</span><span class="html">Item</span><span class="kwrd">&gt;</span><br />    <span class="kwrd">&lt;/</span><span class="html">PhraseList</span><span class="kwrd">&gt;</span><br /><br />    <span class="kwrd">&lt;</span><span class="html">PhraseTopic</span> <span class="attr">Label</span><span class="kwrd">=&quot;eventsArtists&quot;</span> <span class="attr">Scenario</span><span class="kwrd">=&quot;Natural Language&quot;</span><span class="kwrd">&gt;</span><br />      <span class="kwrd">&lt;</span><span class="html">Subject</span><span class="kwrd">&gt;</span>Music<span class="kwrd">&lt;/</span><span class="html">Subject</span><span class="kwrd">&gt;</span><br />      <span class="kwrd">&lt;</span><span class="html">Subject</span><span class="kwrd">&gt;</span>Artist<span class="kwrd">&lt;/</span><span class="html">Subject</span><span class="kwrd">&gt;</span><br />    <span class="kwrd">&lt;/</span><span class="html">PhraseTopic</span><span class="kwrd">&gt;</span><br />  <span class="kwrd">&lt;/</span><span class="html">CommandSet</span><span class="kwrd">&gt;</span><br /><br />  <span class="rem">&lt;!-- Other CommandSets for other languages --&gt;</span><br /><span class="kwrd">&lt;/</span><span class="html">VoiceCommands</span><span class="kwrd">&gt;</span></pre>
</div>

<div align="justify">Pour faire rapide, voici les principaux éléments qui composent la structure du fichier. Si vous préférez une documentation de référence, ça se passe <a href="http://msdn.microsoft.com/fr-fr/library/dn630431.aspx">ici</a>. </div>

<div align="justify">&#160;</div>

<ul>
  <li>
    <div align="justify"><font color="#9b00d3">CommandSet</font> : Liste les commandes vocales pour une langue spécifique. Spécifiez l’attribut <font color="#9b00d3">xml:lang=”fr-fr”</font> pour supporter le français. Il est possible de supporter <strong>15 langues</strong> différentes.</div>
  </li>

  <li>
    <div align="justify"><font color="#9b00d3">CommandPrefix</font> : Par défaut, vous pouvez lancer l’application directement par son nom. Toutefois, si le nom est trop compliqué ou trop long, vous pouvez lui attribuer un diminutif plus convivial à utiliser.</div>
  </li>

  <li>
    <div align="justify"><font color="#9b00d3">Command</font> : Définie chaque commande vocale individuelle que l’application supporte. Vous pouvez enrichir l’application avec un maximum de 100 commandes. Ces commandes sont elles mêmes définies par les éléments enfants suivants: </div>

    <ul>
      <li>
        <div align="justify"><font color="#9b00d3">ListenFor</font> : Expression qui va être reconnue par Cortana, et actionner l’interaction avec l’application. La syntaxe <font color="#9b00d3">[…]</font> définie un terme optionnel, alors que la syntaxe <font color="#9b00d3">{…} <font color="#333333">pointe sur un label de type <font color="#9b00d3">PhraseList</font> ou <font color="#9b00d3">PhraseTopic (nouveauté en 8.1)</font>. </font></font></div>
      </li>

      <li>
        <div align="justify"><font color="#333333"><font color="#9b00d3">Feedback </font>: Définie comment Cortana doit répondre à l’utilisateur pendant le lancement de l’application.</font></div>
      </li>

      <li>
        <div align="justify"><font color="#333333"><font color="#9b00d3">Navigate</font> :&#160; Précise la page que l’on souhaite afficher au lancement de l’application quand cette commande est invoquée. Ce point est obligatoire en Silverlight, optionnel en Universal. </font></div>
      </li>
    </ul>
  </li>

  <li>
    <div align="justify"><font color="#9b00d3">PhraseList</font> : Une liste de termes pour aider à la compréhension. Un dictionnaire de 2000 éléments peut être renseigné. Comme c’est généralement fastidieux, je vous rassure, ces termes peuvent être <a href="http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn792133.aspx">dynamiquement ajoutés par code</a>.</div>
  </li>

  <li>
    <div align="justify"><font color="#9b00d3">PhraseTopic</font> : C’est la nouveautés de Windows Phone 8.1. La commande vocale peut s’appuyer sur un label plus ouvert qu’un dictionnaire. Vous demander à Cortana/Bing de reconnaître simplement le mot. Comme la reconnaissance d’un terme est souvent lié à son contexte, je vous invite à préciser l’attribut <font color="#9b00d3">Scenario</font> et les enfants <font color="#9b00d3">Subject</font> pour faciliter le travail de reconnaissance et obtenir un résultat pertinent.</div>
  </li>
</ul>

<p align="justify">
  <br />Pour résumer, mon exemple propose donc deux commandes, <strong>showEventAt</strong> et <strong>showEventFrom</strong>, dont le but est de lister les évènement musicaux par lieux et par artistes. Mes lieux sont définis par un dictionnaire fermé, alors que les artistes sont interprétés directement par le couple Cortana/Bing, dans un mode plus ouvert. </p>

<p align="justify"><font color="#9b00d3" size="3">Etape 2. Enregistrer les commandes vocales au démarrage de l’application </font></p>

<p align="justify">L’application doit s’exécuter au moins une fois pour enregistrer les commandes et le rendre disponibles auprès de Cortana. Les quelques lignes suivantes suffisent à enregistrer le fichier vcd.xml et les commandes associées.</p>

<p align="justify">Projet Windows Phone 8.1 Xaml/C# (Universal):</p>

<div id="codeSnippetWrapper">
  <div>
    <pre id="codeSnippet" class="csharpcode"><span class="kwrd">private</span> async <span class="kwrd">void</span> RegisterVoiceCommands()<br />{<br />    Uri uriVoiceCommands = <span class="kwrd">new</span> Uri(<span class="str">&quot;ms-appx:///vcd.xml&quot;</span>, UriKind.Absolute);<br />    StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uriVoiceCommands);<br />    await VoiceCommandManager.InstallCommandSetsFromStorageFileAsync(file);<br />}</pre>
  </div>

  <div><u>Prérequis:</u> N’oubliez pas d’activer la capacité <strong>Microphone</strong> dans le fichier Package.appxmanifest. </div>

  <div>
    <br />Projet Windows Phone Silverlight 8.1: </div>
</div>

<div>
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">private</span> async <span class="kwrd">void</span> RegisterVoiceCommands()<br />{<br />    Uri uriVoiceCommands = <span class="kwrd">new</span> Uri(<span class="str">&quot;ms-appx:///vcd.xml&quot;</span>, UriKind.Absolute));<br />    await VoiceCommandService.InstallCommandSetsFromFileAsync(uriVoiceCommands);<br />}</pre>
</div>

<div align="justify"><u>Prérequis:</u> N’oubliez pas d’activer les capacités <strong>ID_CAP_SPEECH_RECOGNITION</strong>, <strong>ID_CAP_MICROPHONE</strong>, et <strong>ID_CAP_NETWORKING</strong> dans le fichier WMAppManifest.xml. </div>

<div align="justify">&#160;</div>

<p align="justify"><font color="#9b00d3" size="3">Etape 3. Gérer l’activation des commandes vocales </font></p>

<p align="justify">Une fois la commande reconnue et interprétée par le système. Cortana se charge de lancer l’application et en profite pour transmettre les informations vocales dictées par l’utilisateur. C’est sur ce point que l’architecture Silverlight vs Universal est la plus différente.</p>

<p align="justify">Projet Windows Phone Silverlight 8.1: </p>

<p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/0724.image_266ABAF9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/0724.image_5F00_266ABAF9.png"><img title="image" style="background-image: none; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; display: block; padding-right: 0px; margin-right: auto" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/5556.image_thumb_134C1EFE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/5556.image_5F00_thumb_5F00_134C1EFE.png" width="536" height="180" /></a></p>

<div>
  <ol>
    <li>
      <div align="justify">Le système lance l’application et affiche la page précisée dans l’élément <font color="#9b00d3">Navigate</font> du fichier de commandes vocales.</div>
    </li>

    <li>
      <div align="justify">Toutes les infos vocales sont transmises par Query String dans le contexte de navigation. Vous pouvez donc extraire ces infos dans la page et proposer un rendu approprié.</div>
    </li>
  </ol>
</div>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">protected</span> <span class="kwrd">override</span> <span class="kwrd">void</span> OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)<br />{<br />  <span class="kwrd">base</span>.OnNavigatedTo(e);<br /><br />  <span class="rem">// Is this a new activation or a resurrection from tombstone?</span><br />  <span class="kwrd">if</span> (e.NavigationMode == System.Windows.Navigation.NavigationMode.New)<br />  {<br /><br />    <span class="rem">// Was the app launched using a voice command?</span><br />    <span class="kwrd">if</span> (NavigationContext.QueryString.ContainsKey(<span class="str">&quot;voiceCommandName&quot;</span>))<br />    {<br /><br />      <span class="rem">// If so, get the name of the voice command.</span><br />      <span class="kwrd">string</span> voiceCommandName <br />        = NavigationContext.QueryString[<span class="str">&quot;voiceCommandName&quot;</span>];<br /><br />      <span class="rem">// Define app actions for each voice command name.</span><br />      <span class="kwrd">switch</span> (voiceCommandName)<br />      {<br />        <span class="kwrd">case</span> <span class="str">&quot;showWidgets&quot;</span>:<br />          <span class="kwrd">string</span> viewWidget = NavigationContext.QueryString[<span class="str">&quot;widgetViews&quot;</span>];<br />                   <br />          <span class="rem">// Add code to display specified widgets.</span><br />          <span class="kwrd">break</span>;<br /> <br />        <span class="rem">// Add cases for other voice commands. </span><br />        <span class="kwrd">default</span>:<br /><br />          <span class="rem">// There is no match for the voice command name.</span><br />          <span class="kwrd">break</span>;<br />      }<br />    }<br />  }<br />}</pre>

  <br /></div>

<p align="justify">&#160;</p>

<p align="justify">Projet Windows Phone 8.1 Xaml/C# (Universal):</p>

<p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/3348.image_1BCF7E48.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/3348.image_5F00_1BCF7E48.png"><img title="image" style="background-image: none; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; display: block; padding-right: 0px; margin-right: auto" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/7506.image_thumb_3FF76988.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/7506.image_5F00_thumb_5F00_3FF76988.png" width="617" height="180" /></a></p>

<p align="justify">Contrairement à Silverlight, les informations peuvent être interceptés directement dans la classe <strong>App</strong> via l’évènement <strong>OnActivated </strong>avant d’être transmise à la page (d’où le caractère optionnel de l’élément <font color="#9b00d3">Navigate</font> dans le fichier de commandes vocales). C’est donc à vous de rediriger l’utilisateur vers la page de votre choix !</p>

<p align="justify"><font color="#9b00d3">IActivatedEventArgs</font> permet de vérifier 1/ si l’activation de notre application provient bien de Cortana (args.Kind == ActivationKind.VoiceCommand) et 2/ d’extraire toutes les infos vocales dans un bel objet tout propre (plus classe qu’une Query String quand même) : <font color="#9b00d3">SpeechRecognitionResult</font>.</p>

<p align="justify">Code App.xaml.cs</p>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">protected</span> <span class="kwrd">override</span> <span class="kwrd">void</span> OnActivated(IActivatedEventArgs args)<br />{<br />    <span class="kwrd">base</span>.OnActivated(args);<br /><br />    Frame rootFrame = Window.Current.Content <span class="kwrd">as</span> Frame;<br /><br />    <span class="rem">// Was the app activated by a voice command?</span><br />    <span class="kwrd">if</span> (args.Kind == ActivationKind.VoiceCommand)<br />    {<br />        var commandArgs = args <span class="kwrd">as</span> VoiceCommandActivatedEventArgs;<br />        SpeechRecognitionResult speechRecognitionResult = commandArgs.Result;<br /><br />        <span class="rem">// If so, get the name of the voice command, the actual text spoken, and the value of Command/Navigate@Target.</span><br />        <span class="kwrd">string</span> voiceCommandName = speechRecognitionResult.RulePath[0];<br />        <span class="kwrd">string</span> textSpoken = speechRecognitionResult.Text;<br />        <span class="kwrd">string</span> navigationTarget = speechRecognitionResult.SemanticInterpretation.Properties[<span class="str">&quot;NavigationTarget&quot;</span>][0];<br /><br />        <span class="kwrd">switch</span> (voiceCommandName)<br />        {<br />            <span class="kwrd">case</span> <span class="str">&quot;showEventsAt&quot;</span>:<br />                rootFrame.Navigate(<span class="kwrd">typeof</span>(HomePage), commandArgs.Result);<br />                <span class="kwrd">break</span>;<br /><br />            <span class="kwrd">case</span> <span class="str">&quot;showEventsFrom&quot;</span>:<br />                rootFrame.Navigate(<span class="kwrd">typeof</span>(HomePage), commandArgs.Result);<br />                <span class="kwrd">break</span>;<br /><br />            <span class="rem">// Cases for other voice commands.</span><br />            <span class="kwrd">default</span>:<br />                <span class="rem">// There is no match for the voice command name.</span><br />                <span class="kwrd">break</span>;<br />        }<br />    }<br />}</pre>

  <br /></div>

<div id="codeSnippetWrapper">Code HomePage.xaml.cs</div>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <pre id="codeSnippet" class="csharpcode"><span class="rem">/// &lt;summary&gt;</span><br /><span class="rem">/// Invoked when this page is about to be displayed in a Frame.</span><br /><span class="rem">/// &lt;/summary&gt;</span><br /><span class="rem">/// &lt;param name=&quot;e&quot;&gt;Event data that describes how this page was reached.</span><br /><span class="rem">/// This parameter is typically used to configure the page.&lt;/param&gt;</span><br /><span class="kwrd">protected</span> async <span class="kwrd">override</span> <span class="kwrd">void</span> OnNavigatedTo(NavigationEventArgs e)<br />{<br />    <span class="kwrd">base</span>.OnNavigatedTo(e);<br /><br />    ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);<br />    RegisterVoiceCommands();<br /><br />    <span class="rem">// Get recognition result from parameter passed in frame.Navigate call</span><br />    SpeechRecognitionResult speechRecognitionResult = e.Parameter <span class="kwrd">as</span> SpeechRecognitionResult;<br /><br />    <span class="kwrd">if</span> (speechRecognitionResult != <span class="kwrd">null</span>)<br />    {<br />        <span class="kwrd">string</span> commandMode = speechRecognitionResult.SemanticInterpretation.Properties[<span class="str">&quot;commandMode&quot;</span>][0];<br /><br />        <span class="kwrd">if</span> (commandMode == <span class="str">&quot;voice&quot;</span>) <span class="rem">// Did the user speak or type the command?</span><br />        {<br />            <span class="rem">//SpeakText(audioPlayer, String.Format(&quot;MSDN app heard you say {0}&quot;, vcResult.Text));</span><br />            HandleCommand(speechRecognitionResult);<br />        }<br />        <span class="kwrd">else</span> <span class="kwrd">if</span> (commandMode == <span class="str">&quot;text&quot;</span>)<br />        {<br />            <span class="rem">//messageTextBox.Text = string.Format(&quot;Working on your request \&quot;{0}\&quot;&quot;, vcResult.Text);</span><br />            HandleCommand(speechRecognitionResult);<br />        }<br />    }<br /><br />    SongkickService service = <span class="kwrd">new</span> SongkickService();<br />    ContentResponse response = await service.EventSearch(48.856930, 2.341200);<br /><br />    lstLocations.ItemsSource = response.resultsPage.results.events;<br />}<br /><br /><span class="kwrd">private</span> <span class="kwrd">void</span> HandleCommand(SpeechRecognitionResult speechRecognitionResult)<br />{<br />    <span class="kwrd">string</span> voiceCommandName = speechRecognitionResult.RulePath[0];<br />    <span class="kwrd">string</span> textSpoken = speechRecognitionResult.Text;<br />    <span class="kwrd">string</span> navigationTarget = speechRecognitionResult.SemanticInterpretation.Properties[<span class="str">&quot;NavigationTarget&quot;</span>][0];<br /><br />    <span class="kwrd">string</span> eventsViews = speechRecognitionResult.SemanticInterpretation.Properties[<span class="str">&quot;eventsViews&quot;</span>][0];<br />    <br />    <span class="kwrd">switch</span> (voiceCommandName)<br />    {<br />        <span class="kwrd">case</span> <span class="str">&quot;showEventsAt&quot;</span>:<br />            <span class="kwrd">string</span> eventsAt = speechRecognitionResult.SemanticInterpretation.Properties[<span class="str">&quot;eventsLocations&quot;</span>][0];<br />            <span class="kwrd">break</span>;<br /><br />        <span class="kwrd">case</span> <span class="str">&quot;showEventsFrom&quot;</span>:<br />            <span class="kwrd">string</span> eventsFrom = speechRecognitionResult.SemanticInterpretation.Properties[<span class="str">&quot;eventsArtists&quot;</span>][0];<br />            <span class="kwrd">break</span>;<br /><br />        <span class="rem">// Cases for other voice commands.</span><br />        <span class="kwrd">default</span>:<br />            <span class="rem">// There is no match for the voice command name.</span><br />            <span class="kwrd">break</span>;<br />    }<br />}</pre>

  <br /></div>

<p><font color="#9b00d3" size="3">Ressources</font></p>

<ul>
  <li><a href="https://channel9.msdn.com/Blogs/One-Dev-Minute/Integrating-Cortana-with-your-App">Channel 9: Integrating Cortana with your App (video: 99 seconds)</a> </li>

  <li><a href="https://channel9.msdn.com/Events/Build/2014/2-530">Channel 9: Integrating your App into the Speech and Natural Language experience in WP 8.1 (BUILD session)</a> </li>

  <li><a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/dn630430.aspx">MSDN : Commandes vocales (XAML) - démarrage rapide</a> </li>

  <li><a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206959%28v=vs.105%29.aspx">MSDN: Voice commands for Windows Phone 8 (Silverlight)</a> </li>

  <li><a href="https://code.msdn.microsoft.com/MSDN-Voice-Search-for-95c16d92">Exemple: MSDN Voice Search for Windows Phone 8.1</a> </li>

  <li><a href="http://blogs.bing.com/search/2014/04/14/integrating-store-apps-with-cortana-in-windows-phone-8-1/">Bing : Integrating Store Apps with Cortana in Windows Phone 8.1</a> </li>
</ul>

<p>&#160;</p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/6874.circlelogo_64CEDD24.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/6874.circlelogo_5F00_64CEDD24.jpg"><img title="circlelogo" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; display: block; padding-right: 0px; border-top-width: 0px; margin-right: auto" border="0" alt="circlelogo" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/3107.circlelogo_thumb_148C85A4.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/3107.circlelogo_5F00_thumb_5F00_148C85A4.jpg" width="70" height="70" /></a></p>]]></content:encoded>
    </item>
    <item>
      <title>Xbox Music Service: Ajouter de la musique dans votre application Windows Phone ou Windows Store</title>
      <link>https://docs.microsoft.com/archive/blogs/jdupuy/xbox-music-service-ajouter-de-la-musique-dans-votre-application-windows-phone-ou-windows-store</link>
      <pubDate>Fri, 03 Jan 2014 07:47:55 GMT</pubDate>
      <dc:creator><![CDATA[Jean-Sébastien DUPUY]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jdupuy/2014/01/03/xbox-music-service-ajouter-de-la-musique-dans-votre-application-windows-phone-ou-windows-store/</guid>
      <description><![CDATA[Xbox Music Platform API  Xbox Music, c’est avant tout une plateforme musicale qui permet d’écouter...]]></description>
      <content:encoded><![CDATA[<h3><font style="font-weight: normal;" color="#9b00d3" size="3">Xbox Music Platform API</font></h3>  <p align="justify"><a href="http://www.xbox.com/music">Xbox Music</a>, c’est avant tout une plateforme musicale qui permet d’écouter <strong>gratuitement en streaming</strong> votre musique (en mode <a href="http://music.xbox.com/">web</a> et sur Windows 8) ou d’emporter votre musique avec vous sur l’ensemble des plateformes en s’abonnant au Xbox Music Pass (vous pouvez <strong>télécharger</strong> les musiques localement sur votre périphérique). Des applications dédiées sont disponibles sur Windows 8, <a href="http://www.windowsphone.com/s?appid=d2b6a184-da39-4c9a-9e0a-8b589b03dec0">Windows Phone</a>, Xbox et également sur l’<a href="https://itunes.apple.com/fr/app/xbox-music/id669515221?mt=8">App Store</a> et <a href="https://play.google.com/store/apps/details?id=com.microsoft.xboxmusic">Google Play</a>. </p>  <p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/5635.image_509DC712.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/5635.image_5F00_509DC712.png"><img title="image" style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/1121.image_thumb_070E7915.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/1121.image_5F00_thumb_5F00_070E7915.png" width="700" height="237" /></a></p>  <p align="justify">La bonne nouvelle, c’est que les équipes de développement viennent d’ouvrir le catalogue aux développeurs sous forme de web services. Vous pouvez donc donner une nouvelle dimension à votre application ou votre site web en consommant les millions de <strong>titres</strong>, d’<strong>albums</strong> et d’<strong>artistes</strong> disponibles sur Xbox Music. En résumé, une base de données musicale facile d’accès ! Les APIs vont s’étoffer progressivement dans les prochaines semaines, je vous propose toutefois de découvrir les éléments proposés dans cette première mouture:</p>  <ul>   <li>     <div align="justify">Obtenez tous les <strong>détails</strong> d'un album, d’un artiste ou d’une chanson si vous connaissez son <strong>identifiant</strong> (ID).</div>   </li>    <li>     <div align="justify">Rechercher par <strong>mot clés</strong> n'importe quel album, artiste, ou titre, par exemple, &quot;Madonna hang out&quot;.</div>   </li>    <li>     <div align="justify">Obtenez les <strong>meilleurs titres</strong> (top tracks) et les albums les plus récents d’un artiste.</div>   </li>    <li>     <div align="justify">Obtenez un <strong>deep link</strong> qui redirige l’utilisateur vers les applications Xbox Music, que ce soit sur ​​le web, sur Windows Phone, Windows 8.x ou d'une autre plateforme.</div>   </li>    <li>     <div align="justify">Récupérez les<strong> couvertures d'albums</strong> et les <strong>images de l’artiste</strong> en haute définition.</div>   </li> </ul>  <p align="justify">   <br />En complément, si votre application redirige vers l’application Xbox Music et permet de générer une vente (Xbox Music Pass ou achat d’un titre .mp3), <strong>vous pouvez également gagner des revenus</strong> en profitant d’un <strong>programme d’affiliation</strong>.</p>  <!--more-->  <h3 align="justify"><font style="font-weight: normal;" color="#9b00d3" size="3">Comment utiliser les API ?</font></h3>  <p align="justify">Avant de s’attaquer au code, il est nécessaire de s’inscrire sur <a href="http://go.microsoft.com/fwlink/p/?LinkId=389224">Windows Azure Marketplace</a> pour récupérer un identifiant (ID client) et une clé (Secret du client) qui permettra à votre application (ou site web) de s’authentifier auprès du service. A noter que ce service est totalement gratuit et le nombre de transactions est illimité.</p>  <p align="justify">La procédure complète pour s’enregistrer est disponible depuis l’article <a href="http://msdn.microsoft.com/en-us/library/dn546686.aspx">Obtaining a Developer Access Token</a> mais voici les différentes étapes:</p>  <ol>   <li>     <div align="justify"><strong>Connectez-vous</strong> sur <a href="https://datamarket.azure.com">https://datamarket.azure.com</a> avec votre compte Microsoft.</div>   </li>    <li>     <div align="justify">Ajoutez les informations (nom et prénom) sur votre nouveau compte <strong>Windows Azure Marketplace</strong>, puis acceptez les conditions d’utilisation.</div>   </li>    <li>     <div align="justify">Enregistrez ensuite votre nouvelle application en passant par l’interface (depuis <strong>Mon compte</strong>, dans la section <strong>Développeurs</strong>) ou en allant directement sur <a href="https://datamarket.azure.com/developer/applications">https://datamarket.azure.com/developer/applications</a>.</div>      <p align="justify">       <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/8741.image_2BA2974A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/8741.image_5F00_2BA2974A.png"><img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/5141.image_thumb_61A71657.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/5141.image_5F00_thumb_5F00_61A71657.png" width="642" height="472" /></a>         <br />        <br />Le formulaire génère automatiquement une <strong>clé</strong>, conservez cette information ainsi que l’<strong>identifiant client</strong> que vous aurez saisi.</p>   </li>    <li>     <div align="justify">Et, dernier point des plus importants, abonnez-vous à <a href="https://datamarket.azure.com/dataset/xboxmusic/XboxMusicPlatform">Xbox Music Plaform API</a> pour accéder au catalogue de données.</div>   </li> </ol>  <h3><font size="3"><font style="font-weight: normal;" color="#9b00d3">Et le code dans tout ca?</font></font></h3>  <p align="justify">Je vous propose une <strong>Portable Class Library</strong> pour intégrer facilement <strong>Xbox Music API</strong> dans vos applications <strong>Windows Phone</strong> et <strong>Windows Store</strong>. Et en cadeau l’application Windows Phone 8 qui utilise la librairie. Ok, l’idéal serait un petit package nugget, je vais m’y atteler prochainement :) Vous pouvez télécharger la solution depuis le lien <a href="https://blogmedia.blob.core.windows.net/files/XboxMusicDemo.zip">suivant</a>.</p>  <p align="center"><video id="XboxMusic" class="video-js vjs-default-skin" autoplay="true" loop="true" preload="auto" width="229" height="400" data-setup="{}"><source type="video/mp4" src="https://blogmedia.blob.core.windows.net/videos/XboxMusic.mp4"></source>&#160;</video></p> <font color="#9b00d3"></font>  <p align="justify">Si vous souhaitez utiliser directement l’exemple, ajoutez simplement votre ClientId/ClientSecret dans la classe <strong>App</strong>.</p> <font size="3"><font color="#9b00d3"><font style="font-weight: normal;" size="2">       <h3 id="codeSnippetWrapper">         <div id="codeSnippet" class="csharpcode">           <pre class="alt"><span class="kwrd">public</span> <span class="kwrd">partial</span> <span class="kwrd">class</span> App : Application</pre>
<!--CRLF-->

          <pre class="alteven">{</pre>
<!--CRLF-->

          <pre class="alt">   <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">string</span> ClientId { get { <span class="kwrd">return</span> <span class="str">&quot;MyClientId&quot;</span>; } }</pre>
<!--CRLF-->

          <pre class="alteven">   <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">string</span> ClientSecret { get { <span class="kwrd">return</span> <span class="str">&quot;MyClientSecret&quot;</span>; } }</pre>
<!--CRLF-->

          <pre class="alt">&#160;</pre>
<!--CRLF-->

          <pre class="alteven">   [...]</pre>
<!--CRLF-->

          <pre class="alt">}</pre>
<!--CRLF--></div>
      </h3>

      <h3><font size="3"><font style="font-weight: normal;" color="#9b00d3">Les différentes fonctionnalités</font></font></h3>
    </font></font></font>

<h3 align="justify"><font size="3"><font color="#9b00d3"><font style="font-weight: normal;" size="2">1. Récupérer le token d’identification.</font></font><font style="font-weight: normal;"> </font></font></h3>

<p align="justify">GetAccessToken utilise simplement votre <strong>ClientId</strong> et de votre <strong>ClientSecret </strong>pour générer un token d’authentification<strong>&#160;</strong>, pas grand-chose de bien méchant. Attention, ce token a une validité de 10 minutes, vous devez donc rafraichir régulièrement celui-ci ^^</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);">
  <div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">
    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(0, 128, 0);">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 128, 0);">/// Get a developer authentication Access Token obtained from Azure Data Market.</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(0, 128, 0);">/// Used to identify the third-party application using the Xbox Music RESTful API.</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 128, 0);">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(0, 128, 0);">/// &lt;param name=&quot;clientId&quot;&gt;&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 128, 0);">/// &lt;param name=&quot;clientSecret&quot;&gt;&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(0, 128, 0);">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">public</span> async Task&lt;<span style="color: rgb(0, 0, 255);">string</span>&gt; GetAccessToken(<span style="color: rgb(0, 0, 255);">string</span> clientId, <span style="color: rgb(0, 0, 255);">string</span> clientSecret)</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">{</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    <span style="color: rgb(0, 0, 255);">string</span> token = <span style="color: rgb(0, 0, 255);">string</span>.Empty;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    <span style="color: rgb(0, 0, 255);">const</span> <span style="color: rgb(0, 0, 255);">string</span> service = <span style="color: rgb(0, 96, 128);">&quot;https://datamarket.accesscontrol.windows.net/v2/OAuth2-13&quot;</span>;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    <span style="color: rgb(0, 0, 255);">const</span> <span style="color: rgb(0, 0, 255);">string</span> scope = <span style="color: rgb(0, 96, 128);">&quot;http://music.xboxlive.com&quot;</span>;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    <span style="color: rgb(0, 0, 255);">const</span> <span style="color: rgb(0, 0, 255);">string</span> grantType = <span style="color: rgb(0, 96, 128);">&quot;client_credentials&quot;</span>;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    <span style="color: rgb(0, 0, 255);">using</span> (HttpClient proxy = <span style="color: rgb(0, 0, 255);">new</span> HttpClient())</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    {</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        var postData = <span style="color: rgb(0, 0, 255);">new</span> Dictionary&lt;<span style="color: rgb(0, 0, 255);">string</span>, <span style="color: rgb(0, 0, 255);">string</span>&gt;();</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">        postData[<span style="color: rgb(0, 96, 128);">&quot;client_id&quot;</span>] = clientId;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        postData[<span style="color: rgb(0, 96, 128);">&quot;client_secret&quot;</span>] = clientSecret;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">        postData[<span style="color: rgb(0, 96, 128);">&quot;scope&quot;</span>] = scope;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        postData[<span style="color: rgb(0, 96, 128);">&quot;grant_type&quot;</span>] = grantType;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        HttpContent content = <span style="color: rgb(0, 0, 255);">new</span> FormUrlEncodedContent(postData);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        <span style="color: rgb(0, 128, 0);">// Authentication Request</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">        HttpResponseMessage response = await proxy.PostAsync(<span style="color: rgb(0, 0, 255);">new</span> Uri(service), content);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        <span style="color: rgb(0, 0, 255);">string</span> responseContent = await response.Content.ReadAsStringAsync();</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        <span style="color: rgb(0, 0, 255);">if</span> (response.IsSuccessStatusCode)</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">        {</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">            <span style="color: rgb(0, 128, 0);">// Parsing content to extract the token</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">            token = ExtractTokenFromJson(responseContent);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        }</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    }</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    <span style="color: rgb(0, 0, 255);">return</span> token;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">}</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">private</span> <span style="color: rgb(0, 0, 255);">string</span> ExtractTokenFromJson(<span style="color: rgb(0, 0, 255);">string</span> json)</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">{</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    <span style="color: rgb(0, 0, 255);">string</span> token = <span style="color: rgb(0, 0, 255);">string</span>.Empty;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    Match match = Regex.Match(json, <span style="color: rgb(0, 96, 128);">&quot;.*\&quot;access_token\&quot;:\&quot;(?&lt;token&gt;.*?)\&quot;.*&quot;</span>, RegexOptions.IgnoreCase);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    <span style="color: rgb(0, 0, 255);">if</span> (match.Success)</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    {</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">        token = match.Groups[<span style="color: rgb(0, 96, 128);">&quot;token&quot;</span>].Value;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    }</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    <span style="color: rgb(0, 0, 255);">return</span> token;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">}</pre>
<!--CRLF--></div>
</div>

<p>Utilisation de cette méthode:</p>

<div id="codeSnippetWrapper">
  <pre id="codeSnippet" class="csharpcode">MusicHelper helper = <span class="kwrd">new</span> MusicHelper();<br /><span class="kwrd">string</span> token = await helper.GetAccessToken(App.ClientId, App.ClientSecret);</pre>
</div>

<h3><font size="2"><font style="font-weight: normal;" color="#9b00d3">2. Récupération du catalogue (recherche par mots clés).</font></font></h3>

<p align="justify"><strong>SearchMediaCatalog</strong> permet de rechercher par mots clés dans le catalogue. Par défaut, la recherche est effectuée dans tous les éléments. Un filtre en argument permet donc de préciser si vous souhaitez filtrer sur une ou des sous-sections comme <strong>Albums</strong>, <strong>Artists</strong>, <strong>Tracks</strong>.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 200px; background-color: rgb(244, 244, 244);">
  <div id="codeSnippet" style="padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">
    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(0, 128, 0);">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 128, 0);">/// Search for a potentially large number of items from a media catalog.</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(0, 128, 0);">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 128, 0);">/// &lt;param name=&quot;token&quot;&gt;Required. A valid developer authentication Access Token obtained from Azure Data Market, used to identify the third-party application using the Xbox Music RESTful API.&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(0, 128, 0);">/// &lt;param name=&quot;query&quot;&gt;Required. The search query.&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 128, 0);">/// &lt;param name=&quot;maxitems&quot;&gt;Optional. Positive integer from 1 to 25, inclusive. The maximum number of results that should be returned in the response. If this parameter is not set, the response will be limited to a maximum of 25 results. There is no guarantee that all search results will be returned in a single response; the response may contain a truncated list of responses and a continuation token.&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(0, 128, 0);">/// &lt;param name=&quot;filters&quot;&gt;A subcategory of item types, in case the client is interested in only one or more specific types of items. If this parameter is not provided, the search will be performed in all categories.&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 128, 0);">/// &lt;param name=&quot;culture&quot;&gt;Optional. The standard two-letter code that identifies the country/region of the user. If not specified, the value defaults to the geolocated country/region of the client's IP address. Responses will be filtered to provide only those that match the user's country/region.&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;"><span style="color: rgb(0, 128, 0);">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">public</span> async Task&lt;Music&gt; SearchMediaCatalog(<span style="color: rgb(0, 0, 255);">string</span> token, <span style="color: rgb(0, 0, 255);">string</span> query, <span style="color: rgb(0, 0, 255);">uint</span> maxitems = 25, Filters[] filters = <span style="color: rgb(0, 0, 255);">null</span>, Culture culture = <span style="color: rgb(0, 0, 255);">null</span>)</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">{</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    <span style="color: rgb(0, 0, 255);">const</span> <span style="color: rgb(0, 0, 255);">string</span> scope = <span style="color: rgb(0, 96, 128);">&quot;https://music.xboxlive.com/1/content/music/search&quot;</span>;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    Music search = <span style="color: rgb(0, 0, 255);">null</span>;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    <span style="color: rgb(0, 128, 0);">// Formatting filters argument</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    StringBuilder filtersbuilder = <span style="color: rgb(0, 0, 255);">new</span> StringBuilder();</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    <span style="color: rgb(0, 0, 255);">if</span> (filters != <span style="color: rgb(0, 0, 255);">null</span>)</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    {</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">        <span style="color: rgb(0, 0, 255);">for</span> (<span style="color: rgb(0, 0, 255);">int</span> cpt = 0; cpt &lt; filters.Length; cpt++)</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        {</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">            <span style="color: rgb(0, 0, 255);">if</span> (cpt != 0) filtersbuilder.Append(<span style="color: rgb(0, 96, 128);">&quot;+&quot;</span>); filtersbuilder.Append(filters[cpt].ToString().ToLower());</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        }</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    }</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    <span style="color: rgb(0, 0, 255);">else</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    {</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        filtersbuilder.Append(<span style="color: rgb(0, 96, 128);">&quot;music&quot;</span>);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    }</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    <span style="color: rgb(0, 0, 255);">using</span> (HttpClient proxy = <span style="color: rgb(0, 0, 255);">new</span> HttpClient())</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">    {</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">        StringBuilder service = <span style="color: rgb(0, 0, 255);">new</span> StringBuilder();</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        service.Append(scope);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">        service.Append(<span style="color: rgb(0, 96, 128);">&quot;?q=&quot;</span>);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        service.Append(WebUtility.UrlEncode(query));</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">        service.Append(<span style="color: rgb(0, 96, 128);">&quot;&amp;maxitems=&quot;</span>);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        service.Append(maxitems.ToString());</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">        service.Append(<span style="color: rgb(0, 96, 128);">&quot;&amp;filter=&quot;</span>);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        service.Append(filtersbuilder.ToString());</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">        service.Append(<span style="color: rgb(0, 96, 128);">&quot;&amp;accessToken=Bearer+&quot;</span>);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        service.Append(WebUtility.UrlEncode(token));</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        <span style="color: rgb(0, 0, 255);">if</span> (culture != <span style="color: rgb(0, 0, 255);">null</span>)</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">        {</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">            service.Append(<span style="color: rgb(0, 0, 255);">string</span>.Format(<span style="color: rgb(0, 96, 128);">&quot;&amp;language={0}&quot;</span>, culture.Language));</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">            service.Append(<span style="color: rgb(0, 0, 255);">string</span>.Format(<span style="color: rgb(0, 96, 128);">&quot;&amp;country={0}&quot;</span>, culture.Country));</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        }</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        <span style="color: rgb(0, 128, 0);">// Authentication Request</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">        HttpResponseMessage response = await proxy.GetAsync(<span style="color: rgb(0, 0, 255);">new</span> Uri(service.ToString()));</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        <span style="color: rgb(0, 0, 255);">string</span> responseContent = await response.Content.ReadAsStringAsync();</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        <span style="color: rgb(0, 0, 255);">if</span> (response.IsSuccessStatusCode)</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">        {</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">            <span style="color: rgb(0, 128, 0);">// Parsing Content to populate Music object</span></pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">            search = Music.PopulateObject(responseContent);</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">        }</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    }</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">&#160;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: white;">    <span style="color: rgb(0, 0, 255);">return</span> search;</pre>
<!--CRLF-->

    <pre style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">}</pre>
<!--CRLF--></div>
</div>

<p>Utilisation de cette méthode:</p>

<div>
  <pre id="codeSnippet" class="csharpcode">MusicHelper helper = <span class="kwrd">new</span> MusicHelper();<br /><span class="kwrd">string</span> token = await helper.GetAccessToken(App.ClientId, App.ClientSecret);<br /><br />Filters[] filters = <span class="kwrd">new</span> Filters[] { Filters.Music };<br /><span class="kwrd">string</span> keywords = <span class="str">&quot;Daft Punk&quot;</span>;<br />Music music = await helper.SearchMediaCatalog(token, keywords, 25, filters, <span class="kwrd">new</span> Culture(<span class="str">&quot;fr&quot;</span>, <span class="str">&quot;FR&quot;</span>));</pre>
</div>

<div align="justify">Toutes les données <strong>json</strong> sont sérialisées dans des classes respectives <strong>Artist</strong>, <strong>Album</strong> et <strong>Track</strong>. Et la classe <strong>Music</strong> regroupe l’ensemble des entités récupérées. A noter que chaque appel retourne au maximum <strong>25</strong> éléments. Si d’autres éléments sont disponibles, un <strong>ContinuationToken</strong> est mis à disposition pour récupérer les éléments suivants (j’aborde ce point plus bas dans le post).</div>

<div id="codeSnippetWrapper">
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> Music<br />{<br />    <span class="rem">// A paginated list of Artists that matched the request criteria.</span><br />    <span class="kwrd">public</span> Artists Artists { get; set; }<br />    <span class="rem">// A paginated list of Albums that matched the request criteria.</span><br />    <span class="kwrd">public</span> Albums Albums { get; set; }<br />    <span class="rem">// A paginated list of Tracks that matched the request criteria.</span><br />    <span class="kwrd">public</span> Tracks Tracks { get; set; }<br />}</pre>
  <font color="#9b00d3" size="2">3. Recherche par Id.</font></div>

<div></div>

<div>Chaque élément du catalogue est identifié par un <strong>Id</strong> unique. Vous pouvez donc récupérer le détail de ces éléments par l’appel de cette méthode LookupMediaCatalog.</div>

<div>
  <div id="codeSnippetWrapper" class="csharpcode-wrapper">
    <div id="codeSnippet" class="csharpcode">
      <pre class="alt"><span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

      <pre class="alteven"><span class="rem">/// Access a small number of items from a media catalog.</span></pre>
<!--CRLF-->

      <pre class="alt"><span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

      <pre class="alteven"><span class="rem">/// &lt;param name=&quot;token&quot;&gt;Required. A valid developer authentication Access Token obtained from Azure Data Market, used to identify the third-party application using the Xbox Music RESTful API.&lt;/param&gt;</span></pre>
<!--CRLF-->

      <pre class="alt"><span class="rem">/// &lt;param name=&quot;namespaceids&quot;&gt;Required. The ID or IDs to be looked up. Each ID is prefixed by a namespace and &quot;.&quot;. You can specify from 1 to 10 IDs in your request.&lt;/param&gt;</span></pre>
<!--CRLF-->

      <pre class="alteven"><span class="rem">/// &lt;param name=&quot;extras&quot;&gt;Optional. List of extra fields that can be optionally requested (at the cost of performance).&lt;/param&gt;</span></pre>
<!--CRLF-->

      <pre class="alt"><span class="rem">/// &lt;param name=&quot;culture&quot;&gt;Optional. The standard two-letter code that identifies the country/region of the user. If not specified, the value defaults to the geolocated country/region of the client's IP address. Responses will be filtered to provide only those that match the user's country/region.&lt;/param&gt;</span></pre>
<!--CRLF-->

      <pre class="alteven"><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<!--CRLF-->

      <pre class="alt"><span class="kwrd">public</span> async Task&lt;Music&gt; LookupMediaCatalog(<span class="kwrd">string</span> token, <span class="kwrd">string</span>[] namespaceids, Extras[] extras = <span class="kwrd">null</span>, Culture culture = <span class="kwrd">null</span>)</pre>
<!--CRLF-->

      <pre class="alteven">{</pre>
<!--CRLF-->

      <pre class="alt">    <span class="kwrd">const</span> <span class="kwrd">string</span> scope = <span class="str">&quot;https://music.xboxlive.com/1/content/{0}/lookup&quot;</span>;</pre>
<!--CRLF-->

      <pre class="alteven">    Music lookup = <span class="kwrd">null</span>;</pre>
<!--CRLF-->

      <pre class="alt">    </pre>
<!--CRLF-->

      <pre class="alteven">    <span class="rem">// Formatting namespace ids argument</span></pre>
<!--CRLF-->

      <pre class="alt">    StringBuilder idsbuilder = <span class="kwrd">new</span> StringBuilder();</pre>
<!--CRLF-->

      <pre class="alteven">    <span class="kwrd">for</span>(<span class="kwrd">int</span> cpt = 0; cpt &lt; namespaceids.Length; cpt++)</pre>
<!--CRLF-->

      <pre class="alt">    {</pre>
<!--CRLF-->

      <pre class="alteven">        <span class="kwrd">if</span> (cpt != 0) idsbuilder.Append(<span class="str">&quot;+&quot;</span>); idsbuilder.Append(namespaceids[0]);</pre>
<!--CRLF-->

      <pre class="alt">    }</pre>
<!--CRLF-->

      <pre class="alteven">&#160;</pre>
<!--CRLF-->

      <pre class="alt">    <span class="rem">// Formatting extras argument</span></pre>
<!--CRLF-->

      <pre class="alteven">    StringBuilder extrasbuilder = <span class="kwrd">new</span> StringBuilder();</pre>
<!--CRLF-->

      <pre class="alt">    <span class="kwrd">if</span> (extras != <span class="kwrd">null</span>)</pre>
<!--CRLF-->

      <pre class="alteven">    {</pre>
<!--CRLF-->

      <pre class="alt">        <span class="kwrd">for</span> (<span class="kwrd">int</span> cpt = 0; cpt &lt; extras.Length; cpt++)</pre>
<!--CRLF-->

      <pre class="alteven">        {</pre>
<!--CRLF-->

      <pre class="alt">            <span class="kwrd">if</span> (cpt != 0) extrasbuilder.Append(<span class="str">&quot;+&quot;</span>); extrasbuilder.Append(extras[cpt].ToString());</pre>
<!--CRLF-->

      <pre class="alteven">        }</pre>
<!--CRLF-->

      <pre class="alt">    }</pre>
<!--CRLF-->

      <pre class="alteven">&#160;</pre>
<!--CRLF-->

      <pre class="alt">    <span class="rem">// Formatting lookup request Uri</span></pre>
<!--CRLF-->

      <pre class="alteven">    StringBuilder service = <span class="kwrd">new</span> StringBuilder();</pre>
<!--CRLF-->

      <pre class="alt">    service.Append(<span class="kwrd">string</span>.Format(scope, idsbuilder.ToString()));</pre>
<!--CRLF-->

      <pre class="alteven">&#160;</pre>
<!--CRLF-->

      <pre class="alt">    service.Append(<span class="str">&quot;?accessToken=Bearer+&quot;</span>);</pre>
<!--CRLF-->

      <pre class="alteven">    service.Append(WebUtility.UrlEncode(token));</pre>
<!--CRLF-->

      <pre class="alt">&#160;</pre>
<!--CRLF-->

      <pre class="alteven">    <span class="kwrd">if</span> (extras != <span class="kwrd">null</span>) </pre>
<!--CRLF-->

      <pre class="alt">    {</pre>
<!--CRLF-->

      <pre class="alteven">        service.Append(<span class="kwrd">string</span>.Format(<span class="str">&quot;&amp;extras={0}&quot;</span>, extrasbuilder.ToString()));</pre>
<!--CRLF-->

      <pre class="alt">    }</pre>
<!--CRLF-->

      <pre class="alteven">&#160;</pre>
<!--CRLF-->

      <pre class="alt">    <span class="kwrd">if</span> (culture != <span class="kwrd">null</span>)</pre>
<!--CRLF-->

      <pre class="alteven">    {</pre>
<!--CRLF-->

      <pre class="alt">        service.Append(<span class="kwrd">string</span>.Format(<span class="str">&quot;&amp;language={0}&quot;</span>, culture.Language));</pre>
<!--CRLF-->

      <pre class="alteven">        service.Append(<span class="kwrd">string</span>.Format(<span class="str">&quot;&amp;country={0}&quot;</span>, culture.Country));</pre>
<!--CRLF-->

      <pre class="alt">    }</pre>
<!--CRLF-->

      <pre class="alteven">&#160;</pre>
<!--CRLF-->

      <pre class="alt">    <span class="kwrd">using</span> (HttpClient proxy = <span class="kwrd">new</span> HttpClient())</pre>
<!--CRLF-->

      <pre class="alteven">    {</pre>
<!--CRLF-->

      <pre class="alt">        <span class="rem">// Lookup Request - Look up a small number of items from a media catalog.</span></pre>
<!--CRLF-->

      <pre class="alteven">        HttpResponseMessage response = await proxy.GetAsync(<span class="kwrd">new</span> Uri(service.ToString()));</pre>
<!--CRLF-->

      <pre class="alt">        <span class="kwrd">string</span> responseContent = await response.Content.ReadAsStringAsync();</pre>
<!--CRLF-->

      <pre class="alteven">&#160;</pre>
<!--CRLF-->

      <pre class="alt">        <span class="kwrd">if</span> (response.IsSuccessStatusCode)</pre>
<!--CRLF-->

      <pre class="alteven">        {</pre>
<!--CRLF-->

      <pre class="alt">            <span class="rem">// Parsing Content to populate Music object</span></pre>
<!--CRLF-->

      <pre class="alteven">            lookup = Music.PopulateObject(responseContent);</pre>
<!--CRLF-->

      <pre class="alt">        }</pre>
<!--CRLF-->

      <pre class="alteven">    }</pre>
<!--CRLF-->

      <pre class="alt">&#160;</pre>
<!--CRLF-->

      <pre class="alteven">    <span class="kwrd">return</span> lookup;</pre>
<!--CRLF-->

      <pre class="alt">}</pre>
<!--CRLF--></div>
  </div>
Utilisation de cette méthode:</div>

<div>
  <pre id="codeSnippet" class="csharpcode">MusicHelper helper = <span class="kwrd">new</span> MusicHelper();<br /><span class="kwrd">string</span> token = await helper.GetAccessToken(App.ClientId, App.ClientSecret);<br /><br /><span class="kwrd">string</span>[] namespaceids = <span class="kwrd">new</span> <span class="kwrd">string</span>[] { <span class="str">&quot;music.C61C0000-0200-11DB-89CA-0019B92A3933&quot;</span> };<br />Extras[] extras = <span class="kwrd">new</span> Extras[] { Extras.Tracks };<br /><br />Music music = await helper.LookupMediaCatalog(token, namespaceids, extras, <span class="kwrd">new</span> Culture(<span class="str">&quot;fr&quot;</span>, <span class="str">&quot;FR&quot;</span>));</pre>
</div>

<div align="justify">Pour éviter de surcharger le fichier <strong>json</strong> transmis, les collections liées (par exemple la classe <strong>Album</strong> propose une collection liée <strong>Tracks</strong>) ne sont pas inclus par défaut. Il est nécessaire de préciser, via l’argument <strong>extras</strong>, si vous souhaitez obtenir ces informations additionnelles. L’ensemble des déclarations possibles pour <strong>extras</strong> est définie ci-dessous: 

  <br />

  <br /></div>

<div align="center">
  <table border="1"><tbody>
      <tr>
        <th><strong>Item type</strong></th>

        <th><strong>&quot;Extras&quot; value</strong></th>

        <th><strong>Corresponding extra information</strong></th>
      </tr>

      <tr>
        <td rowspan="2">Artist</td>

        <td>albums</td>

        <td>The artist's <a href="http://msdn.microsoft.com/en-us/library/dn546684.aspx">paginated list</a> of <a href="http://msdn.microsoft.com/en-us/library/dn546679.aspx">albums.</a></td>
      </tr>

      <tr>
        <td>topTracks</td>

        <td>The artist's <a href="http://msdn.microsoft.com/en-us/library/dn546684.aspx">paginated list</a> of <a href="http://msdn.microsoft.com/en-us/library/dn546680.aspx">top tracks.</a></td>
      </tr>

      <tr>
        <td rowspan="2">Album</td>

        <td>tracks</td>

        <td>The album's <a href="http://msdn.microsoft.com/en-us/library/dn546684.aspx">paginated list</a> of <a href="http://msdn.microsoft.com/en-us/library/dn546685.aspx">tracks.</a></td>
      </tr>

      <tr>
        <td>artistDetails</td>

        <td>Extra fields in the album's <a href="http://msdn.microsoft.com/en-us/library/dn546680.aspx">artist</a> list (level of detail equivalent to a Lookup call on the artist).</td>
      </tr>

      <tr>
        <td rowspan="2">Track</td>

        <td>albumDetails</td>

        <td>Extra fields in the track's <a href="http://msdn.microsoft.com/en-us/library/dn546679.aspx">album</a> (level of detail equivalent to a Lookup call on the album).</td>
      </tr>

      <tr>
        <td>artistDetails</td>

        <td>Extra fields in the track's <a href="http://msdn.microsoft.com/en-us/library/dn546680.aspx">artist</a> (level of detail equivalent to a Lookup call on the artist).</td>
      </tr>
    </tbody></table>
</div>

<h3><font style="font-weight: normal;" color="#9b00d3" size="2">4. Obtenir les <font color="#9b00d3">éléments additionnels</font>.</font></h3>

<p><strong>LoadNext</strong> permet de charger des éléments additionnels à l’aide du <strong>ContinuationToken</strong>.</p>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <div id="codeSnippet" class="csharpcode">
    <pre class="alt"><span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// Request the continuation of an incomplete list of content.</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;param name=&quot;token&quot;&gt;Required. A valid developer authentication Access Token obtained from Azure Data Market, used to identify the third-party application using the Xbox Music RESTful API.&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;param name=&quot;continuationToken&quot;&gt;Required. A Continuation Token provided in an earlier service response and optionally passed back to the service to request the continuation of an incomplete list of content.&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;param name=&quot;namespaceids&quot;&gt;Optional. The ID or IDs to be looked up. Each ID is prefixed by a namespace and &quot;.&quot;. You can specify from 1 to 10 IDs in your request.&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="kwrd">public</span> async Task&lt;Music&gt; LoadNext(<span class="kwrd">string</span> token, <span class="kwrd">string</span> continuationToken, <span class="kwrd">string</span>[] namespaceids = <span class="kwrd">null</span>)</pre>
<!--CRLF-->

    <pre class="alt">{</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">const</span> <span class="kwrd">string</span> scopesearch = <span class="str">&quot;https://music.xboxlive.com/1/content/music/search&quot;</span>;</pre>
<!--CRLF-->

    <pre class="alt">    <span class="kwrd">const</span> <span class="kwrd">string</span> scopelookup = <span class="str">&quot;https://music.xboxlive.com/1/content/{0}/lookup&quot;</span>;</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">    <span class="kwrd">string</span> scope = <span class="kwrd">string</span>.Empty;</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">string</span> jsonContent = <span class="kwrd">string</span>.Empty;</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">    Music next = <span class="kwrd">null</span>;</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="rem">// Formatting namespace ids</span></pre>
<!--CRLF-->

    <pre class="alt">    <span class="kwrd">if</span> (namespaceids != <span class="kwrd">null</span>)</pre>
<!--CRLF-->

    <pre class="alteven">    {</pre>
<!--CRLF-->

    <pre class="alt">        StringBuilder ids = <span class="kwrd">new</span> StringBuilder();</pre>
<!--CRLF-->

    <pre class="alteven">        <span class="kwrd">for</span> (<span class="kwrd">int</span> cpt = 0; cpt &lt; namespaceids.Length; cpt++)</pre>
<!--CRLF-->

    <pre class="alt">        {</pre>
<!--CRLF-->

    <pre class="alteven">            <span class="kwrd">if</span> (cpt != 0) ids.Append(<span class="str">&quot;+&quot;</span>); ids.Append(namespaceids[0]);</pre>
<!--CRLF-->

    <pre class="alt">        }</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">        scope = <span class="kwrd">string</span>.Format(scopelookup, ids.ToString());</pre>
<!--CRLF-->

    <pre class="alteven">    }</pre>
<!--CRLF-->

    <pre class="alt">    <span class="kwrd">else</span></pre>
<!--CRLF-->

    <pre class="alteven">    {</pre>
<!--CRLF-->

    <pre class="alt">        scope = scopesearch;</pre>
<!--CRLF-->

    <pre class="alteven">    }</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">using</span> (HttpClient proxy = <span class="kwrd">new</span> HttpClient())</pre>
<!--CRLF-->

    <pre class="alt">    {</pre>
<!--CRLF-->

    <pre class="alteven">        StringBuilder service = <span class="kwrd">new</span> StringBuilder();</pre>
<!--CRLF-->

    <pre class="alt">        service.Append(scope);</pre>
<!--CRLF-->

    <pre class="alteven">        service.Append(<span class="str">&quot;?continuationToken=&quot;</span>);</pre>
<!--CRLF-->

    <pre class="alt">        service.Append(continuationToken);</pre>
<!--CRLF-->

    <pre class="alteven">        service.Append(<span class="str">&quot;&amp;accessToken=Bearer+&quot;</span>);</pre>
<!--CRLF-->

    <pre class="alt">        service.Append(WebUtility.UrlEncode(token));</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">        <span class="rem">// Authentication Request</span></pre>
<!--CRLF-->

    <pre class="alteven">        HttpResponseMessage response = await proxy.GetAsync(<span class="kwrd">new</span> Uri(service.ToString()));</pre>
<!--CRLF-->

    <pre class="alt">        <span class="kwrd">string</span> responseContent = await response.Content.ReadAsStringAsync();</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">        <span class="kwrd">if</span> (response.IsSuccessStatusCode)</pre>
<!--CRLF-->

    <pre class="alteven">        {</pre>
<!--CRLF-->

    <pre class="alt">            <span class="rem">// Parsing Content to populate Music object</span></pre>
<!--CRLF-->

    <pre class="alteven">            next = Music.PopulateObject(responseContent);</pre>
<!--CRLF-->

    <pre class="alt">        }</pre>
<!--CRLF-->

    <pre class="alteven">    }</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">return</span> next;</pre>
<!--CRLF-->

    <pre class="alt">}</pre>
<!--CRLF--></div>
</div>

<p>Utilisation de cette méthode (lors de l’évènement <strong>ItemRealized</strong> sur le LongListSelector):</p>

<div id="codeSnippetWrapper">
  <div id="codeSnippetWrapper">
    <pre id="codeSnippet" class="csharpcode"><span class="kwrd">private</span> async <span class="kwrd">void</span> AlbumsList_ItemRealized(<span class="kwrd">object</span> sender, ItemRealizationEventArgs e)<br />{<br />    <span class="kwrd">int</span> offset = 25;<br />    <span class="kwrd">if</span> (AlbumsList.ItemsSource != <span class="kwrd">null</span> &amp;&amp; AlbumsList.ItemsSource.Count &gt;= offset)<br />    {<br />        <span class="kwrd">if</span> (e.ItemKind == LongListSelectorItemKind.Item)<br />        {<br />            <span class="kwrd">if</span> ((e.Container.Content <span class="kwrd">as</span> Album).Equals(AlbumsList.ItemsSource[AlbumsList.ItemsSource.Count <br />                - offset]))<br />            {<br />                <span class="rem">// Refresh token (in case of expiration)</span><br />                <span class="kwrd">string</span> token = await helper.GetAccessToken(App.ClientId, App.ClientSecret);<br />                <span class="kwrd">string</span> continuationToken = music.Albums.ContinuationToken;<br /><br />                Music result = await helper.LoadNext(token, continuationToken);<br />                <span class="kwrd">foreach</span> (Album item <span class="kwrd">in</span> result.Albums.Items)<br />                {<br />                    music.Albums.Items.Add(item);<br />                }<br />            }<br />        }<br />    }<br />}</pre>
    <font color="#9b00d3" size="3">DeepLink et ImageUrl</font> 

    <br /></div>

  <div align="justify">Les classes <strong>Track</strong> et <strong>Album</strong> contiennent un <strong>DeepLink</strong> pour rediriger vers les applications natives <strong>Xbox Music</strong> de Windows Phone et Windows Store. Ce <strong>DeepLink</strong> peut être paramétré pour <strong>jouer</strong>, <strong>acheter</strong> ou <strong>ajouter </strong>le titre ou l’album à la collection de l’utilisateur. A noter que le programme d’affiliation vous permet également de modifier ce <strong>DeepLink</strong> pour un partage des revenus quand votre application déclenche une vente d’un morceau ou d’un abonnement (cf. <a href="http://msdn.microsoft.com/en-us/library/dn546658.aspx">Affiliate Program</a>).</div>

  <div id="codeSnippetWrapper">
    <pre id="codeSnippet" class="csharpcode"><span class="rem">// Launches playback of the media content.</span><br /><span class="kwrd">public</span> <span class="kwrd">string</span> DeepLinkPlay<br />{<br />    get { <span class="kwrd">return</span> <span class="kwrd">this</span>.Link + <span class="str">&quot;?action=play&quot;</span>; }<br />}<br /><br /><span class="rem">// Opens the &quot;add to collection&quot; screen on the Xbox Music service.</span><br /><span class="kwrd">public</span> <span class="kwrd">string</span> DeepLinkAddToCollection<br />{<br />    get { <span class="kwrd">return</span> <span class="kwrd">this</span>.Link + <span class="str">&quot;?action=addtocollection&quot;</span>; }<br />}<br /><br /><span class="rem">// Opens the appropriate purchase flow on the Xbox Music service.</span><br /><span class="kwrd">public</span> <span class="kwrd">string</span> DeepLinkBuy<br />{<br />    get { <span class="kwrd">return</span> <span class="kwrd">this</span>.Link + <span class="str">&quot;?action=buy&quot;</span>; }<br />}</pre>
Utilisation du DeepLink (lors de l’évènement <strong>SelectionChanged </strong>sur le LongListSelector):</div>

  <div>
    <pre id="codeSnippet" class="csharpcode"><span class="kwrd">private</span> <span class="kwrd">void</span> TracksList_SelectionChanged(<span class="kwrd">object</span> sender, SelectionChangedEventArgs e)<br />{<br />    <span class="rem">// If selected item is null (no selection) do nothing</span><br />    <span class="kwrd">if</span> (TracksList.SelectedItem == <span class="kwrd">null</span>)<br />        <span class="kwrd">return</span>;<br /><br />    Track track = TracksList.SelectedItem <span class="kwrd">as</span> Track;<br />    <span class="rem">// Navigate to the Xbox Music application</span><br />    WebBrowserTask webBrowserTask = <span class="kwrd">new</span> WebBrowserTask();<br />    webBrowserTask.Uri = <span class="kwrd">new</span> Uri(track.DeepLinkPlay, UriKind.Absolute);<br />    webBrowserTask.Show();<br /><br />    <span class="rem">// Reset selected item to null (no selection)</span><br />    TracksList.SelectedItem = <span class="kwrd">null</span>;<br />}</pre>
  </div>

  <div align="justify">Last but not least, les classes <strong>Track</strong>, <strong>Album</strong> et <strong>Artist</strong> permettent d’accéder à des images en HD pour illustrer vos applications. Du coup, si vous récupérez dans l’état l’Url, vous avez des grandes chances de plomber la mémoire et de voir votre application s’arrêter violement (oui, ça sent un peu le vécu). Pensez donc à paramétrer l’Url pour demander les images dans une taille moins gourmande.</div>

  <div></div>

  <div>Pour vous aider à paramétrer ce point, j’ai ajouté une classe <strong>ImageSettings</strong> à la solution:</div>

  <div>
    <div>
      <pre id="codeSnippet" class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">enum</span> ImageMode<br />{<br />    Scale = 1,<br />    LetterBox = 2,<br />    Crop = 3<br />}<br /><br /><span class="kwrd">public</span> <span class="kwrd">class</span> ImageSettings<br />{<br />    <span class="kwrd">public</span> <span class="kwrd">int</span> Width { get; set; }<br />    <span class="kwrd">public</span> <span class="kwrd">int</span> Height { get; set; }<br />    <span class="kwrd">public</span> ImageMode Mode { get; set; }<br />    <span class="kwrd">public</span> <span class="kwrd">string</span> Background { get; set; }<br /><br />    <span class="kwrd">public</span> ImageSettings(<span class="kwrd">int</span> width, <span class="kwrd">int</span> height, ImageMode mode, <span class="kwrd">string</span> background)<br />    {<br />        <span class="kwrd">this</span>.Width = width;<br />        <span class="kwrd">this</span>.Height = height;<br />        <span class="kwrd">this</span>.Mode = mode;<br />        <span class="kwrd">this</span>.Background = background;<br />    }<br />}</pre>
    </div>

    <div>Cette classe vous permet de configurer la <strong>taille</strong>, le <strong>mode</strong> (Scale, Crop ou LetterBox) et la <strong>couleur du fond</strong> (uniquement dans le mode LetterBox).</div>

    <div>
      <div id="codeSnippetWrapper" class="csharpcode-wrapper">
        <div id="codeSnippet" class="csharpcode">
          <pre class="alt"><span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

          <pre class="alteven"><span class="rem">/// Every piece of content returned by catalog search and lookup APIs contains a field ImageUrl, which is a direct link to the content's default image, hosted on http://musicimage.xboxlive.com/. This image link generates an image with specific default properties, but it is possible to modify the link in order to change some of the image properties, such as its size. Image resolution is context-aware, so the actual image might change depending on the size parameters used. The details of the image API are shown here.</span></pre>
<!--CRLF-->

          <pre class="alt"><span class="rem">/// You should use the image URL given in the response. The URL should not be modified or altered other than with the parameters described below. Any other use of the images will be considered as a breach of the terms of use of the API (see TBD).</span></pre>
<!--CRLF-->

          <pre class="alteven"><span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

          <pre class="alt"><span class="rem">/// &lt;param name=&quot;width&quot;&gt;Image width. Cannot be set without height parameter.&lt;/param&gt;</span></pre>
<!--CRLF-->

          <pre class="alteven"><span class="rem">/// &lt;param name=&quot;height&quot;&gt;Image height. Cannot be set without width parameter.&lt;/param&gt;</span></pre>
<!--CRLF-->

          <pre class="alt"><span class="rem">/// &lt;param name=&quot;mode&quot;&gt;Image resize mode: </span></pre>
<!--CRLF-->

          <pre class="alteven"><span class="rem">/// - scale to resize to maximum size which fits dimension without changing the aspect ratio.</span></pre>
<!--CRLF-->

          <pre class="alt"><span class="rem">/// - letterbox to pad to dimension after resize if aspect ratio didn't match. </span></pre>
<!--CRLF-->

          <pre class="alteven"><span class="rem">/// - crop to get the required width and height but image is cropped. Defaults to crop if w and h are provided.&lt;/param&gt;</span></pre>
<!--CRLF-->

          <pre class="alt"><span class="rem">/// &lt;param name=&quot;background&quot;&gt;HTML-compliant color for letterbox resize mode background. Cannot be specified if mode is not set to letterbox.&lt;/param&gt;</span></pre>
<!--CRLF-->

          <pre class="alteven"><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<!--CRLF-->

          <pre class="alt"><span class="kwrd">public</span> <span class="kwrd">string</span> ImageUrlWithOptions(ImageSettings settings)</pre>
<!--CRLF-->

          <pre class="alteven">{</pre>
<!--CRLF-->

          <pre class="alt">    <span class="kwrd">if</span> (settings.Mode == ImageMode.LetterBox)</pre>
<!--CRLF-->

          <pre class="alteven">    {</pre>
<!--CRLF-->

          <pre class="alt">        <span class="kwrd">return</span> <span class="kwrd">this</span>.ImageUrl + <span class="kwrd">string</span>.Format(<span class="str">&quot;&amp;w={0}&amp;h={1}&amp;mode={2}&amp;background={3}&quot;</span>, settings.Width.ToString(), settings.Height.ToString(), settings.Mode.ToString().ToLower(), settings.Background);</pre>
<!--CRLF-->

          <pre class="alteven">    }</pre>
<!--CRLF-->

          <pre class="alt">    <span class="kwrd">else</span></pre>
<!--CRLF-->

          <pre class="alteven">    {</pre>
<!--CRLF-->

          <pre class="alt">        <span class="kwrd">return</span> <span class="kwrd">this</span>.ImageUrl + <span class="kwrd">string</span>.Format(<span class="str">&quot;&amp;w={0}&amp;h={1}&amp;mode={2}&quot;</span>, settings.Width.ToString(), settings.Height.ToString(), settings.Mode.ToString().ToLower(), settings.Background);</pre>
<!--CRLF-->

          <pre class="alteven">    }</pre>
<!--CRLF-->

          <pre class="alt">}</pre>
<!--CRLF-->

          <pre class="alteven">&#160;</pre>
<!--CRLF-->

          <pre class="alt"><span class="rem">// Settings in order to change image format</span></pre>
<!--CRLF-->

          <pre class="alteven"><span class="kwrd">public</span> ImageSettings ImageSettings { get; set; }</pre>
<!--CRLF-->

          <pre class="alt">&#160;</pre>
<!--CRLF-->

          <pre class="alteven"><span class="kwrd">public</span> <span class="kwrd">string</span> ImageUrlEx</pre>
<!--CRLF-->

          <pre class="alt">{</pre>
<!--CRLF-->

          <pre class="alteven">    get</pre>
<!--CRLF-->

          <pre class="alt">    {</pre>
<!--CRLF-->

          <pre class="alteven">        <span class="kwrd">if</span> (<span class="kwrd">this</span>.ImageSettings != <span class="kwrd">null</span>)</pre>
<!--CRLF-->

          <pre class="alt">        {</pre>
<!--CRLF-->

          <pre class="alteven">            <span class="kwrd">return</span> <span class="kwrd">this</span>.ImageUrlWithOptions(ImageSettings);</pre>
<!--CRLF-->

          <pre class="alt">        }</pre>
<!--CRLF-->

          <pre class="alteven">        <span class="kwrd">else</span></pre>
<!--CRLF-->

          <pre class="alt">        {</pre>
<!--CRLF-->

          <pre class="alteven">            <span class="kwrd">return</span> <span class="kwrd">this</span>.ImageUrlWithOptions(<span class="kwrd">new</span> ImageSettings(160, 160, ImageMode.Scale, <span class="str">&quot;#000000&quot;</span>));</pre>
<!--CRLF-->

          <pre class="alt">        }</pre>
<!--CRLF-->

          <pre class="alteven">    }</pre>
<!--CRLF-->

          <pre class="alt">}</pre>
<!--CRLF--></div>
      </div>
Enjoy ! A très bientôt pour un prochain update des API.</div>

    <div>N’hésitez pas à me signaler les coquilles éventuelles dans le code. On n’est jamais à l’abri ^^. Pour compléter ces informations, je vous invite à consulter la documentation <a href="http://music.xbox.com/developer">Xbox Music for Developers</a>.</div>

    <div></div>

    <div align="right">Code de la solution <a href="https://blogmedia.blob.core.windows.net/files/XboxMusicDemo.zip">XboxMusicDemo</a>.</div>

    <div>&#160;</div>
  </div>

  <div align="justify"></div>

  <div align="justify"></div>

  <div>&#160;</div>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Tutorial Series - Introduction au développement d'application Direct3D avec XAML pour Windows Phone 8 : Matrices</title>
      <link>https://docs.microsoft.com/archive/blogs/jdupuy/tutorial-series-introduction-au-dveloppement-dapplication-direct3d-avec-xaml-pour-windows-phone-8-matrices</link>
      <pubDate>Fri, 20 Sep 2013 04:20:39 GMT</pubDate>
      <dc:creator><![CDATA[Jean-Sébastien DUPUY]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jdupuy/2013/09/20/tutorial-series-introduction-au-dveloppement-dapplication-direct3d-avec-xaml-pour-windows-phone-8-matrices/</guid>
      <description><![CDATA[Matrices de transformation  On va consacrer ce post aux matrices. Si vous avez allégrement séché...]]></description>
      <content:encoded><![CDATA[<h3><font size="3"><font style="font-weight: normal;" color="#9b00d3">Matrices de transformation</font></font></h3>  <p align="justify">On va consacrer ce post aux matrices. Si vous avez allégrement séché cette discipline mathématique en pensant que ça ne servait probablement à rien, pas de bol, dans le monde de la 3D c’est essentiel! :)</p>  <p align="justify">La seule explication simple (en tout cas à ma portée) c’est que chaque matrice se définie comme un tableau de nombres (4x4 dans notre cas) qui va nous permettre de nous simplifier largement la vie pour appliquer des transformations à notre cube (rotation, translation et mise à l’échelle). Comme je n’ai pas prétention à vous donner un cours d’algèbre dont mes notions sont somme toute assez limité, je vous invite à consulter les ressources en fin d’article (volé sur un post précédent de mon collègue <a href="http://blogs.msdn.com/b/davrous/archive/2013/06/13/tutorial-series-learning-how-to-write-a-3d-soft-engine-from-scratch-in-c-typescript-or-javascript.aspx">David Rousset</a> ; que je vous encourage à étudier au passage ^^):</p>  <p align="justify">Avant de déprimer, la bonne nouvelle c’est que Direct3D gère en grande partie la complexité inhérente aux matrices, le point important à comprendre c’est que les coordonnées de notre objet (les sommets dans un premier temps) vont transiter dans plusieurs référentiels.</p>  <ol>   <li>     <div align="justify">En premier lieu, on va pouvoir appliquer des transformations sur l’objet (<b>model</b>) pour le placer de manière appropriée dans la scène.</div>   </li>    <li>     <div align="justify">Ensuite, on va regarder cet objet sous un certains angle de vue (<b>view</b>). Imaginez une caméra qui se place au-dessus de notre objet. On va appliquer les transformations adéquates pour voir l’objet dans ce nouveau référentiel.</div>   </li>    <li>     <div align="justify">Et finalement la <b>projection</b>. On a beau être dans un monde en 3D, aux dernières nouvelles notre écran est une surface plane, l’emplacement de chaque pixel est représenté par 2 valeurs (x,y). On va donc basculer d’un référentiel 3D à un référentiel 2D.</div>   </li> </ol>  <p align="justify"><img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="http://upload.wikimedia.org/wikipedia/commons/4/48/Axonometric_projection.svg" width="240" height="204" /></p>  <p align="justify">Les transformations appliquées dans les référentiels précédents sont définies par des matrices différentes : <b>model</b>, <b>view</b> et <b>projection</b>. Nos données de départ (celles stockées dans le <b>Vertex Buffer</b>) vont donc être transformées par ces matrices pour obtenir les coordonnés finales de notre pixel à l’écran.</p>  <p align="justify">C’est en grande partie le rôle du <b>Vertex Shader </b>(encore un nouveau terme technique ^^) d’effectuer cette opération. Comment procède-t-il ? Il va simplement multiplier les coordonnées de départ par chacune des matrices <b>model</b>, <b>view</b> et <b>projection</b>, le tour est joué !</p>  <h3><font size="3"><font style="font-weight: normal;" color="#9b00d3">Constant Buffer</font></font></h3>  <p align="justify">Avant de parler du <b>Vertex Shader</b>, un petit laïus additionnel sur le <b>Constant Buffer</b>, tout un programme pour vous faire rêver ami lecteur !</p>  <p align="justify">La carte graphique est notre amie, elle va vite (voir très vite) car elle a tout sous la main pour travailler. Son espace mémoire est dédiée et on lui a déjà fournie des informations à digérer avec nos buffers précédents (le <b>Vertex Buffer</b> et l’<b>Index Buffer</b>).</p>  <p align="justify">Il en va de même pour les matrices, on va les stocker dans un <b>Constant Buffer</b>. C’est un espace mémoire que le <b>Vertex Shader </b>va pouvoir consommer<b> </b>pour effectuer les calculs de projection. Avec cette dernière pièce à l’édifice, notre <b>Vertex Shader</b> est enfin prêt pour travailler sur nos données !</p>  <p align="justify">Ok, maintenant qu’on a introduit les concepts, un peu de code.</p>  <h4><font style="font-weight: normal;" color="#9b00d3">1. Décalaration du constant buffer</font></h4>  <p align="justify">a. Dans <strong>SceneRenderer.cpp</strong>, nous allons commencer par déclarer la structure de notre <strong>Constant Buffer</strong>. Cette structure regroupe simplement nos 3 matrices 4x4 : <strong>model</strong>, <strong>view</strong> et <strong>projection</strong>.</p>  <div>   <pre id="codeSnippet" class="csharpcode"><span class="kwrd">struct</span> ModelViewProjectionConstantBuffer<br />{<br />    DirectX::XMFLOAT4X4 model;<br />    DirectX::XMFLOAT4X4 view;<br />    DirectX::XMFLOAT4X4 projection;<br />};</pre>
</div>

<div align="justify">b. Et du coup, on en profite pour ajouter deux variables membres dans la classe <strong>SceneRenderer</strong> pour manipuler ces matrices.</div>

<div>
  <pre id="codeSnippet" class="csharpcode">Microsoft::WRL::ComPtr&lt;ID3D11Buffer&gt; m_constantBuffer;<br />ModelViewProjectionConstantBuffer m_constantBufferData;</pre>
</div>

<ul>
  <li>
    <div align="justify"><strong>m_constantBuffer </strong>:<strong> </strong>c’est un pointeur sur notre buffer de données (au même titre que m_indexBuffer et m_vertexBuffer), il s’agit d’un espaces mémoire directement accessibles par la carte graphique (et du coup accessible par notre <strong>Vertex Shader</strong>) </div>
  </li>

  <li>
    <div align="justify"><strong>m_constantBufferData</strong> : les matrices vont être préalablement stockées dans cette variable (comme pour cubeVertices et cubeIndices). En bref, on prépare nos trois matrices dans cette variable et on envoie le résultat à m_constantBuffer.</div>
  </li>
</ul>

<h4><font style="font-weight: normal;" color="#9b00d3">2. Initialisation du constant buffer</font></h4>

<p align="justify">L’initialisation s’effectue dans <strong>SceneRenderer::CreateDeviceResources</strong>, on procède d‘une manière identique à l’Index/Vertex Buffer avec un appel à <a href="http://msdn.microsoft.com/en-us/library/windows/apps/ff476501.aspx">ID3D11Device::CreateBuffer</a>. L’unique différence c’est que les données en entrée sont vides dans l’immédiat (mais on va résoudre ce problème dans un instant).</p>

<div>
  <pre id="codeSnippet" class="csharpcode">CD3D11_BUFFER_DESC constantBufferDesc(<span class="kwrd">sizeof</span>(ModelViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);<br />DX::ThrowIfFailed(<br />    m_d3dDevice-&gt;CreateBuffer(<br />    &amp;constantBufferDesc,<br />    nullptr,<br />    &amp;m_constantBuffer<br />    )<br />    );</pre>
</div>

<h4><font style="font-weight: normal;" color="#9b00d3">3. Initialisation des matrices model, view et projection</font></h4>

<h4><font style="font-weight: normal;">a. matrice </font><font color="#9b00d3"><font style="font-weight: normal;">model</font></font></h4>

<p align="justify">On commence par s’attaquer à la matrice <strong>model. </strong>Dans cet exemple, je désire faire tourner notre cube : nous allons donc appliquer une matrice de rotation (sur l’axe des Y), et mettre à jour l’angle de rotation à chaque nouvelle frame.</p>

<p align="justify">C’est le but de la méthode <strong>SceneRenderer:Update</strong>,<strong> </strong>tout le travail est effectuée par la méthode <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.matrix.xmmatrixrotationy(v=vs.85).aspx">XMatrixRotationY</a> : elle prend simplement un angle comme argument d’entrée (en radian). Ce type de méthode existe pour l’ensemble des transformations, du coup le calcul matriciel devient une boite noire que vous pouvez utiliser les yeux fermés (ou presque).</p>

<div>
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">void</span> SceneRenderer::Update(<span class="kwrd">float</span> timeTotal, <span class="kwrd">float</span> timeDelta)<br />{<br />    (<span class="kwrd">void</span>) timeDelta; <span class="rem">// Unused parameter.</span><br />    XMStoreFloat4x4(&amp;m_constantBufferData.model, XMMatrixTranspose(XMMatrixRotationY(timeTotal * XM_PIDIV4)));<br />}</pre>
</div>

<div align="justify">Pour les matrices <strong>view</strong> et <strong>projection</strong>, l’initialisation est effectuée une fois pour toute au lancement de l’application dans la méthode <strong>SceneRenderer::CreateWindowSizeDependentResources</strong>.&#160;&#160; </div>

<h4 align="justify"><font style="font-weight: normal;">b. matrice </font><font color="#9b00d3"><font style="font-weight: normal;">view</font></font></h4>

<p align="justify">La matrice <strong>view</strong> positionne la scène dans un nouveau référentiel, celui de notre caméra. Pour définir une caméra, nous avons toutefois besoin de 3 vecteurs:</p>

<ul>
  <li>
    <div align="justify"><strong>eye </strong>définie la <strong>position</strong> de la camera</div>
  </li>

  <li>
    <div align="justify"><strong>at </strong>nous indique la <strong>direction</strong> vers l’objet étudié</div>
  </li>

  <li>
    <div align="justify"><strong>up </strong>positionne le <strong>haut</strong> de la caméra</div>
  </li>
</ul>

<div align="justify">&#160;</div>

<div align="justify"><a href="http://img833.imageshack.us/img833/5950/glulookat.gif"><img style="margin-right: auto; margin-left: auto; float: none; display: block;" border="0" alt="" src="http://img833.imageshack.us/img833/5950/glulookat.gif" width="300" height="202" /></a></div>

<div align="justify">
  <br />La méthode <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.matrix.xmmatrixlookatrh(v=vs.85).aspx">XMatrixLookAtRH</a> nous permet ensuite de repositionner la scène avec ces trois nouvelles coordonnées.</div>

<div>
  <pre id="codeSnippet" class="csharpcode">XMVECTOR eye = XMVectorSet(0.0f, 0.7f, 1.5f, 0.0f);<br />XMVECTOR at = XMVectorSet(0.0f, -0.1f, 0.0f, 0.0f);<br />XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);<br /><br />XMStoreFloat4x4(&amp;m_constantBufferData.view, XMMatrixTranspose(XMMatrixLookAtRH(eye, at, up)));</pre>
</div>

<div align="justify"><u>Note:</u> Les vecteurs <strong>eye</strong>, <strong>at</strong> et <strong>up</strong> ne nécessitent que 3 valeurs (x, y, et z). On travaille toutefois avec 4 valeurs (la dernière étant 0.0f) car les matrices de transformations sont en 4x4. 

  <br /></div>

<h4><font style="font-weight: normal;">c. matrice </font><font color="#9b00d3"><font style="font-weight: normal;">projection</font></font><font style="font-weight: normal;"> </font></h4>

<div align="justify">Ça pique un chouïa plus, mais rien de violent ! Cette dernière matrice nous aide à basculer du monde 3D au référentiel 2D pour projeter notre scène à l’écran. On va utiliser également un petit cadeau de Direct3D pour nous simplifier la vie : <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.matrix.xmmatrixperspectivefovrh(v=vs.85).aspx">XMMatrixPerspectiveFovRH</a>. Cette fonction prend toutefois 4 arguments un peu austères au premier abord mais rien d’inabordable dans les faits :)</div>

<div align="justify">&#160;</div>

<ul>
  <li>
    <div align="justify"><strong>FovAngleY </strong>défine l’angle du champ de vision (<strong>field-of-view</strong>) sur l’axe des Y (de haut en bas). Cet angle est de 70 degrés dans notre cas. Et pour faire simple, cette valeur doit être préalablement convertie en radian :)</div>
  </li>

  <li><strong>AspectRatio</strong> définie le rapport entre la largeur et la hauteur de l’écran (on divise simplement x par y)</li>

  <li><strong>NearZ</strong> indique le plan de clipping <strong>proche</strong>, tous les éléments <strong>devant</strong> ce plan sont ignorés.</li>

  <li><strong>FarZ</strong> indique le plan de clipping <strong>lointain</strong>, tous les éléments <strong>derrière</strong> ce plan sont ignorés.</li>
</ul>

<p>&#160;</p>

<p>Comme un dessin est probablement plus parlant, ca ressemble à ça :</p>

<ul></ul>
<img style="margin-right: auto; margin-left: auto; float: none; display: block;" border="0" alt="fov (field of view) diagram" src="http://codinghorror.typepad.com/.a/6a0120a85dcdae970b0120a86d9495970b-pi" width="536" height="352" />

<p>Et le tour est joué, on a notre troisième matrice !</p>

<div></div>

<div>
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">float</span> aspectRatio = m_windowBounds.Width / m_windowBounds.Height;<br /><span class="kwrd">float</span> fovAngleY = 70.0f * XM_PI / 180.0f;  <span class="rem">// convert in radian</span><br /><br /><span class="kwrd">if</span> (aspectRatio &lt; 1.0f)<br />{<br />    fovAngleY /= aspectRatio;<br />}<br /><br />XMStoreFloat4x4(<br />    &amp;m_constantBufferData.projection,<br />    XMMatrixTranspose(<br />        XMMatrixPerspectiveFovRH(<br />            fovAngleY,        <span class="rem">// field-of-view</span><br />            aspectRatio,      <span class="rem">// aspect ratio</span><br />            0.01f,            <span class="rem">// near clipping plane</span><br />            100.0f            <span class="rem">// far clipping plane</span><br />            )<br />        )<br />    );</pre>
</div>

<div align="justify">Parfait, on a nos 3 matrices !&#160; Mais à quel moment suis-je sensé copié les informations de la variable <strong>m_constantBufferData</strong> vers le buffer <strong>m_constantBuffer</strong> !? 

  <br /></div>

<div align="justify">C’est un peu tôt pour en parler, mais vous pouvez jeter un coup d’œil dans la méthode SceneRenderer::Render(), l’appel à UpdateSubresource effectue exactement ce travail. Promis on parle très prochainement en détail de ce point !</div>

<div align="justify">&#160;</div>

<div>
  <pre id="codeSnippet" class="csharpcode">m_d3dContext-&gt;UpdateSubresource(<br />    m_constantBuffer.Get(),<br />    0,<br />    NULL,<br />    &amp;m_constantBufferData,<br />    0,<br />    0<br />    );</pre>
</div>

<div>
  <br /><font size="3"><font style="font-weight: normal;" color="#9b00d3">Ressources</font></font></div>

<div>&#160;</div>

<ul>
  <li><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb206269(v=vs.85).aspx">Transforms (Direct3D 9)</a></li>

  <li><a href="http://robertokoci.com/world-view-projection-matrix-unveiled/">World, View and Projection Matrix Unveiled</a></li>

  <li><a href="http://db-in.com/blog/2011/04/cameras-on-opengl-es-2-x/">Cameras on OpenGL ES 2.x – The ModelViewProjection Matrix</a></li>

  <li><a href="http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/">Tutorial 3 : Matrices</a></li>

  <li><a href="http://inear.se/talk/a_brief_introduction_to_3d.pptx">A brief introduction to 3D</a></li>

  <li><a href="http://www.songho.ca/opengl/gl_transform.html">OpenGL Transformation </a></li>
</ul>

<p>&#160;</p>

<p align="right"><a href="https://blogmedia.blob.core.windows.net/files/OmegaCrusher-Introduction.zip">Télécharger le Code</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Tutorial Series - Introduction to Direct3D with XAML application development for Windows Phone 8 : Transformation Matrices</title>
      <link>https://docs.microsoft.com/archive/blogs/jdupuy/tutorial-series-introduction-to-direct3d-with-xaml-application-development-for-windows-phone-8-transformation-matrices</link>
      <pubDate>Tue, 17 Sep 2013 06:46:42 GMT</pubDate>
      <dc:creator><![CDATA[Jean-Sébastien DUPUY]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jdupuy/2013/09/17/tutorial-series-introduction-to-direct3d-with-xaml-application-development-for-windows-phone-8-transformation-matrices/</guid>
      <description><![CDATA[Transformation matrices  I will dedicate this post to matrices. If you missed this mathematical...]]></description>
      <content:encoded><![CDATA[<h3><font size="3"><font style="font-weight: normal;" color="#9b00d3">Transformation matrices</font></font></h3>  <p align="justify">I will dedicate this post to matrices. If you missed this mathematical discipline thinking it was probably useless: bad luck, in the world of 3D rendering this topic is essential! :)</p>  <p align="justify">A simple explanation (basically) is that each matrix is ​​defined as an array of numbers (4x4 in our case) which will simplify our life for applying transformations to the cube mesh (rotation, translation and scaling). As I do not claim to give you an algebra class (that my notions are actually quite limited), I suggest you to visit the resources section at the end of this article (stolen on a previous post from my colleague <a href="http://blogs.msdn.com/b/davrous/archive/2013/06/13/tutorial-series-learning-how-to-write-a-3d-soft-engine-from-scratch-in-c-typescript-or-javascript.aspx">David Rousset</a> ^^):</p>  <p align="justify">Before depressing, the good news is that Direct3D manages much of the inherent complexity of the matrices, the important point to understand is that the coordinates of our object (vertices in first) will be transformed in the following way.</p>  <ol>   <li>     <div align="justify">In the first place, we will apply transformations on the object (<strong>model</strong>) to position it appropriately in the scene.</div>   </li>    <li>     <div align="justify">Then, we'll look at this object from a certain point of <strong>view</strong>. Imagine a camera that fits over our cube. We will apply the appropriate transformations to see the object in the new coordinates system.</div>   </li>    <li>     <div align="justify">And finally the <b>projection</b>. It is nice to be in a 3D world, but our screen is a flat surface where each pixel is represented by 2 values (x and y). Projection will help us to switch from the 3D world to the 2D surface.</div>   </li> </ol>  <p align="justify"><img style="margin-right: auto; margin-left: auto; float: none; display: block;" src="http://upload.wikimedia.org/wikipedia/commons/4/48/Axonometric_projection.svg" width="240" height="204" /></p>  <p align="justify">These transformations are defined by different matrices: <strong>model</strong>, <strong>view</strong> and <strong>projection</strong>. Our initial data (stored in the <strong>Vertex Buffer</strong>) will be transformed by these matrices to obtain the final coordinated of our pixel on the screen.</p>  <p align="justify">This is largely the role of the <strong>Vertex Shader</strong> (yet another technical term ^^) to perform this operation. How does it do? It will simply multiply the starting coordinates with each matrix <strong>model</strong>, <strong>view</strong> and <strong>projection</strong>, job completed!</p>  <!--more-->  <p align="justify"></p>  <h3><font size="3"><font style="font-weight: normal;" color="#9b00d3">Constant Buffer</font></font></h3>  <p align="justify">Before talking about the <strong>Vertex Shader</strong>, a small additional speech about the <strong>Constant Buffer</strong>, an awesome program for you dear reader. :)</p>  <p align="justify">The graphics card is our friend, it works quickly because this hardware has everything available to work. Its memory is dedicated and we already allocated some information on this area with our previous buffers (<strong>Vertex Buffer</strong> and <strong>Index Buffer</strong>).</p>  <p align="justify">The same goes for the matrices, we will store them in a <strong>Constant Buffer</strong>. It is a memory space that <strong>Vertex Shader</strong> will be able to consume to perform the projection calculations. With this last piece, our <strong>Vertex Shader</strong> is finally ready to work on our data!</p>  <p align="justify">Ok, now that we have introduced the concepts, some code.</p>  <h4><font style="font-weight: normal;" color="#9b00d3">1. Constant buffer declaration</font></h4>  <p align="justify">a. In <strong>SceneRenderer.cpp</strong>, we will start by declaring the structure of our <strong>Constant Buffer</strong>. This structure simply consists of our three 4x4 matrices: <strong>model</strong>, <strong>view</strong> and <strong>projection</strong>.</p>  <div>   <pre id="codeSnippet" class="csharpcode"><span class="kwrd">struct</span> ModelViewProjectionConstantBuffer<br />{<br />    DirectX::XMFLOAT4X4 model;<br />    DirectX::XMFLOAT4X4 view;<br />    DirectX::XMFLOAT4X4 projection;<br />};</pre>
</div>

<div align="justify">b. And by the way, we add two member variables in <strong>SceneRenderer</strong> class to manipulate these matrices.</div>

<div>
  <pre id="codeSnippet" class="csharpcode">Microsoft::WRL::ComPtr&lt;ID3D11Buffer&gt; m_constantBuffer;<br />ModelViewProjectionConstantBuffer m_constantBufferData;</pre>
</div>

<ul>
  <li>
    <div align="justify"><strong>m_constantBuffer</strong>: this is a pointer to our buffer data (as well as m_indexBuffer and m_vertexBuffer), directly accessible by the graphics card (and hence accessible by our <strong>Vertex Shader</strong>). </div>
  </li>

  <li>
    <div align="justify"><strong>m_constantBufferData</strong>: our matrices will be first stored in this variable (as cubeVertices and cubeIndices). In short, our three transformation matrices are initialized in this variable and we send the result to m_constantBuffer.</div>
  </li>
</ul>

<h4><font style="font-weight: normal;" color="#9b00d3">2. Constant buffer initialization</font></h4>

<p align="justify">Initialization is performed in <strong>SceneRenderer::CreateDeviceResources</strong>, we proceed in a similar way to Index/Vertex Buffer with a call to <a href="http://msdn.microsoft.com/en-us/library/windows/apps/ff476501.aspx">ID3D11Device::CreateBuffer</a>. The only difference is that the input data is empty at the moment (but we will fix this soon).</p>

<div>
  <pre id="codeSnippet" class="csharpcode">CD3D11_BUFFER_DESC constantBufferDesc(<span class="kwrd">sizeof</span>(ModelViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);<br />DX::ThrowIfFailed(<br />    m_d3dDevice-&gt;CreateBuffer(<br />    &amp;constantBufferDesc,<br />    nullptr,<br />    &amp;m_constantBuffer<br />    )<br />    );</pre>
</div>

<h4><font style="font-weight: normal;" color="#9b00d3">3. Matrices initialization: model, view et projection</font></h4>

<h4><font style="font-weight: normal;">a. <font color="#9b00d3">model</font> matrix</font></h4>

<p align="justify">We begin by addressing the matrix <strong>model</strong>. In this example, I want to rotate the cube: we're going to apply a rotation matrix (on the Y axis), and update the rotation angle for each new frame.</p>

<p align="justify">This job is performed in <strong>SceneRenderer::Update </strong>method with a call to <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.matrix.xmmatrixrotationy(v=vs.85).aspx">XMatrixRotationY</a>: it simply takes an angle argument (in radians). This type of method exists for all transformations, by the way matrix calculation become a black box that you can use easily. </p>

<div>
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">void</span> SceneRenderer::Update(<span class="kwrd">float</span> timeTotal, <span class="kwrd">float</span> timeDelta)<br />{<br />    (<span class="kwrd">void</span>) timeDelta; <span class="rem">// Unused parameter.</span><br />    XMStoreFloat4x4(&amp;m_constantBufferData.model, XMMatrixTranspose(XMMatrixRotationY(timeTotal * XM_PIDIV4)));<br />}</pre>
</div>

<div align="justify">For the two next topics (view and projection matrices initialization), the code is executed once at application launch in <strong>SceneRenderer:CreateWindowSizeDependentResources</strong>.&#160;&#160; </div>

<h4 align="justify"><font style="font-weight: normal;">b. <font color="#9b00d3">view</font> matrix</font></h4>

<p align="justify">The <strong>view</strong> matrix sets the scene in a new coordinate systems, where object is targeted by a camera. To define a camera, we need three vectors:</p>

<ul>
  <li>
    <div align="justify"><strong>eye </strong>defines the position of the camera</div>
  </li>

  <li>
    <div align="justify"><strong>at </strong>defines the position of the focal point (the direction of the targeted object)</div>
  </li>

  <li>
    <div align="justify"><strong>up </strong>defines the up direction of the camera</div>
  </li>
</ul>

<div align="justify">&#160;</div>

<div align="justify"><a href="http://img833.imageshack.us/img833/5950/glulookat.gif"><img style="margin-right: auto; margin-left: auto; float: none; display: block;" border="0" alt="" src="http://img833.imageshack.us/img833/5950/glulookat.gif" width="300" height="202" /></a></div>

<div align="justify">&#160;&#160; <br />Then <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.matrix.xmmatrixlookatrh(v=vs.85).aspx">XMatrixLookAtRH</a> method allows us to reposition the scene with these three new coordinates.</div>

<div>
  <pre id="codeSnippet" class="csharpcode">XMVECTOR eye = XMVectorSet(0.0f, 0.7f, 1.5f, 0.0f);<br />XMVECTOR at = XMVectorSet(0.0f, -0.1f, 0.0f, 0.0f);<br />XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);<br /><br />XMStoreFloat4x4(&amp;m_constantBufferData.view, XMMatrixTranspose(XMMatrixLookAtRH(eye, at, up)));</pre>
</div>

<div align="justify"><u>Note:</u> Vectors <strong>eye</strong>, <strong>at</strong> and <strong>up</strong> require only three values ​​(x, y, and z). However, you can notice that we are working with four values ​​(the latter being 0.0f) because our transformation matrices are 4x4 

  <br /></div>

<h4><font style="font-weight: normal;">c. <font color="#9b00d3">projection</font> matrix</font><font style="font-weight: normal;"> </font></h4>

<div align="justify">This latter matrix will helps us to switch from 3D world to 2D surface. We want to project our scene to the flat screen surface. We will also use a small gift from Direct3D to simplify our life: <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.matrix.xmmatrixperspectivefovrh(v=vs.85).aspx">XMMatrixPerspectiveFovRH</a>. However, this function takes four arguments a little bit more tricky that need some explanation :)</div>

<div align="justify">&#160;</div>

<ul>
  <li>
    <div align="justify"><strong>FovAngleY </strong>defines the top-down <strong>field-of-view</strong> angle in radians. This angle is 70 degrees in our case, we just need to convert this value in radian :)</div>
  </li>

  <li><strong>AspectRatio</strong> defines the <strong>aspect ratio</strong> of the view space (we devide x by y)</li>

  <li><strong>NearZ</strong> is the distance to the <strong>near</strong> clipping plane, all graphics elements <strong>before</strong> this plane are not displayed.</li>

  <li><strong>FarZ</strong> is the distance to the <strong>far</strong> clipping plane, all graphics elements <strong>after</strong> this plane are not displayed.</li>
</ul>

<p>&#160;</p>

<p>As drawing is probably more meaningful, it looks like this:</p>

<ul></ul>
<img style="margin-right: auto; margin-left: auto; float: none; display: block;" border="0" alt="fov (field of view) diagram" src="http://codinghorror.typepad.com/.a/6a0120a85dcdae970b0120a86d9495970b-pi" width="536" height="352" />

<p>And voila, we have our third matrix !</p>

<div></div>

<div>
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">float</span> aspectRatio = m_windowBounds.Width / m_windowBounds.Height;<br /><span class="kwrd">float</span> fovAngleY = 70.0f * XM_PI / 180.0f;  <span class="rem">// convert in radian</span><br /><br /><span class="kwrd">if</span> (aspectRatio &lt; 1.0f)<br />{<br />    fovAngleY /= aspectRatio;<br />}<br /><br />XMStoreFloat4x4(<br />    &amp;m_constantBufferData.projection,<br />    XMMatrixTranspose(<br />        XMMatrixPerspectiveFovRH(<br />            fovAngleY,        <span class="rem">// field-of-view</span><br />            aspectRatio,      <span class="rem">// aspect ratio</span><br />            0.01f,            <span class="rem">// near clipping plane</span><br />            100.0f            <span class="rem">// far clipping plane</span><br />            )<br />        )<br />    );</pre>
</div>

<div align="justify">Perfect, we have our three matrix! But when am I supposed to copy the information from <strong>m_constantBufferData</strong> variable to <strong>m_constantBuffer</strong> buffer!? 

  <br /></div>

<div align="justify">A little bit early to discuss about this point, but you can take a look at the method SceneRenderer::Render(), the call to UpdateSubresource performs exactly this job. We will talk soon in details about this point.</div>

<div align="justify">&#160;</div>

<div>
  <pre id="codeSnippet" class="csharpcode">m_d3dContext-&gt;UpdateSubresource(<br />    m_constantBuffer.Get(),<br />    0,<br />    NULL,<br />    &amp;m_constantBufferData,<br />    0,<br />    0<br />    );</pre>
</div>

<div>
  <br /><font size="3"><font style="font-weight: normal;" color="#9b00d3">Resources</font></font></div>

<div>&#160;</div>

<ul>
  <li><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb206269(v=vs.85).aspx">Transforms (Direct3D 9)</a></li>

  <li><a href="http://robertokoci.com/world-view-projection-matrix-unveiled/">World, View and Projection Matrix Unveiled</a></li>

  <li><a href="http://db-in.com/blog/2011/04/cameras-on-opengl-es-2-x/">Cameras on OpenGL ES 2.x – The ModelViewProjection Matrix</a></li>

  <li><a href="http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/">Tutorial 3 : Matrices</a></li>

  <li><a href="http://inear.se/talk/a_brief_introduction_to_3d.pptx">A brief introduction to 3D</a></li>

  <li><a href="http://www.songho.ca/opengl/gl_transform.html">OpenGL Transformation </a></li>
</ul>

<p align="right"><a href="https://blogmedia.blob.core.windows.net/files/OmegaCrusher-Introduction.zip">Download the Code</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Tutorial Series - Introduction au développement d'application Direct3D avec XAML pour Windows Phone 8 : Création d’un mesh</title>
      <link>https://docs.microsoft.com/archive/blogs/jdupuy/tutorial-series-introduction-au-dveloppement-dapplication-direct3d-avec-xaml-pour-windows-phone-8-cration-dun-mesh</link>
      <pubDate>Thu, 22 Aug 2013 08:50:10 GMT</pubDate>
      <dc:creator><![CDATA[Jean-Sébastien DUPUY]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jdupuy/2013/08/22/tutorial-series-introduction-au-dveloppement-dapplication-direct3d-avec-xaml-pour-windows-phone-8-cration-dun-mesh/</guid>
      <description><![CDATA[Le dernier épisode nous a démontré qu’on pouvait se compliquer la vie pour afficher un fond bleu :)...]]></description>
      <content:encoded><![CDATA[<p align="justify">Le <a href="http://blogs.msdn.com/b/jdupuy/archive/2013/07/18/tutorial-series-introduction-au-d-233-veloppement-d-application-direct3d-avec-xaml-pour-windows-phone-8.aspx">dernier épisode</a> nous a démontré qu’on pouvait se compliquer la vie pour afficher un fond bleu :) ; mais en contrepartie vous venez d’ouvrir la porte sur DirectX. Pour ce deuxième article, je vais donc tenter de vulgariser les concepts principaux de <strong>Direct3D</strong> pour vous aider à mettre le pied à l’étrier. Ces points ne sont toutefois pas spécifiques à Windows Phone, vous trouverez en bas de page des pointeurs sur des ressources additionnelles pour compléter ces informations.</p>  <h3><font style="font-weight: normal;" color="#9b00d3" size="3">Initialisation de Direct3D</font></h3>  <p align="justify">Bonne nouvelle, vous n’avez pas à gérer cette partie de code, le contrôle <strong>DrawingSurfaceBackgroundGrid </strong>(ou <strong>DrawingSurface</strong>)<strong> </strong>prend en charge ce point pour vous, c’est cadeau ! Bien évidemment, si vous n’utilisez pas ces contrôles XAML et que vous souhaitez développer une application 100% native, vous devez effectuer cette initialisation … faut pas rêver non plus.</p>  <p align="justify">Concrètement, quelles sont les opérations prises en charge lors de cette initialisation ??</p>  <p align="justify"><font color="#9b00d3">1.</font> La création des objets <strong>device</strong> et <strong>device context</strong></p>  <p align="justify">La communication avec la carte graphique (ou plus largement le périphérique)&#160; s’effectue par l’intermédiaire de ces deux objets. Il s’agit des principaux points d’entrées pour utiliser Direct3D. </p>  <ul>   <li>     <div align="justify">L’objet <strong>device</strong> (<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ff476379(v=vs.85).aspx">ID3D11Device</a>) s’occupe principalement de créer les <strong>ressources</strong> graphiques (textures, vertex buffers, shaders, …).</div>   </li>    <li>     <div align="justify">L’objet <strong>device context</strong> (<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ff476385(v=vs.85).aspx">ID3D11DeviceContext</a>) se charge d’effectuer les opérations de <strong>rendu </strong>en utilisant les ressources initilisés par l’objet device.&#160;&#160;&#160;&#160;&#160;&#160; </div>   </li> </ul>  <p align="justify">&#160;</p>  <p align="justify"><font color="#9b00d3">2.</font> La création de la <strong>swap chain</strong></p>  <p align="justify">Le rendu n’est pas effectué directement à l’écran, il est réalisé dans un buffer mémoire (cad. un tableau de pixels de la dimension de l’écran) que l’on nomme <strong>back buffer</strong>. La swap chain se charge de copier le contenu du back buffer directement à l’écran. Pour information, la swap chain peut théoriquement utiliser plusieurs back buffers, mais Windows Phone limite son utilisation à <strong>un seul et unique</strong> buffer.</p>  <p align="justify">En complément, Direct3D permet d’accéder aux données du&#160; <strong>back buffer </strong>(notre tableau de pixels) via l’objet <strong>render target view</strong> (<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ff476582(v=vs.85).aspx">ID3D11RenderTargetView</a>).</p>  <p align="justify">Perdu ? Reprenons par exemple les lignes de code du post précédent. Le code de la méthode Direct3DBackground::Draw initialise en bleu notre écran.&#160; </p>  <blockquote>   <p align="justify">a/ La méthode ClearRenderTargetView est appelée depuis l’objet <strong>device context        <br /></strong>b/<strong> </strong>On cible le back buffer via l’objet <strong>render target view</strong>. Ca devient plus clair ? </p> </blockquote>  <div id="codeSnippetWrapper" class="csharpcode-wrapper">   <pre id="codeSnippet" class="csharpcode">HRESULT Direct3DBackground::Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceContext1* context, _In_ ID3D11RenderTargetView* renderTargetView)<br />{<br />    <span class="rem">// Clear the render target to default values.</span><br />    <span class="kwrd">const</span> <span class="kwrd">float</span> midnightBlue [] = { 0.098f, 0.098f, 0.439f, 1.000f };<br />    context-&gt;ClearRenderTargetView(<br />        renderTargetView,<br />        midnightBlue<br />        );<br /><br />    RequestAdditionalFrame();<br /><br />    <span class="kwrd">return</span> S_OK;<br />}</pre>

  <br /></div>

<p align="justify">Pour compléter ces informations, je vous invite à consulter l’article <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj714075(v=vs.105).aspx">Creating a Direct3D device and swap chain for Windows Phone 8</a>.</p>

<h3><font style="font-weight: normal;" color="#9b00d3" size="3">Construction de notre objet 3D</font></h3>

<h4 align="justify">Les sommets <font style="font-weight: normal;">(déclaration des vertices)</font></h4>

<p align="justify">Un objet 3D (ou <b>mesh</b>) se définie généralement par une liste de sommets (<b>vertices</b>) et de <b>faces</b>. Par exemple, huit sommets sont nécessaires pour décrire un cube. Et puisque nous sommes dans un repère à trois dimensions, chaque sommet comporte trois coordonnées : x, y et z. Si on place le centre du cube à l’origine de la scène avec des sommets définies entre les valeurs -0.5 et 0.5, on obtient donc le tableau suivant :</p>

<p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/5125.image_thumb8_1F9718DC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/5125.image_5F00_thumb8_5F00_1F9718DC.png"><img title="vertices" style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="vertices" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/8688.image_thumb8_thumb_086B9E5E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/8688.image_5F00_thumb8_5F00_thumb_5F00_086B9E5E.png" width="640" height="81" /></a></p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/2018.image_thumb11_2A5700E2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/2018.image_5F00_thumb11_5F00_2A5700E2.png"><img title="vertices 3D" style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="vertices 3D" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/2451.image_thumb11_thumb_20FDCC5F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/2451.image_5F00_thumb11_5F00_thumb_5F00_20FDCC5F.png" width="640" height="290" /></a></p>

<p align="justify">Pour compléter notre exemple, on va associer une <strong>couleur</strong> à chaque sommet (pour visualiser les faces plus simplement lors du rendu). Cette couleur se compose également de trois valeurs : rouge, vert et bleu (format RGB). Un sommet sera donc défini par une <strong>position</strong> et une <strong>couleur</strong> associée de la manière suivante :</p>

<div id="codeSnippetWrapper">
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">struct</span> VertexPositionColor<br />{<br />    DirectX::XMFLOAT3 pos;<br />    DirectX::XMFLOAT3 color;<br />};</pre>
</div>

<p align="justify">Pour des objets complexes, on chargera généralement les valeurs depuis un fichier (par exemple depuis un format Autodesk FBX qui fera l’objet d’un prochain post pour charger le vaisseau). Dans le cas présent, on va déclarer manuellement notre tableau de sommets, avec des couleurs définies arbitrairement :</p>

<div id="codeSnippetWrapper">
  <pre id="codeSnippet" class="csharpcode">VertexPositionColor cubeVertices [] =<br />{<br />    { XMFLOAT3(-0.5f, -0.5f, -0.5f), XMFLOAT3(0.0f, 0.0f, 0.0f) }, <span class="rem">// Vertice 0 at -0.5, -0.5, -0.5 // White</span><br />    { XMFLOAT3(-0.5f, -0.5f,  0.5f), XMFLOAT3(0.0f, 0.0f, 1.0f) }, <span class="rem">// Vertice 1 at -0.5, -0.5,  0.5 // Blue</span><br />    { XMFLOAT3(-0.5f,  0.5f, -0.5f), XMFLOAT3(0.0f, 1.0f, 0.0f) }, <span class="rem">// Vertice 2 at -0.5,  0.5, -0.5 // Green</span><br />    { XMFLOAT3(-0.5f,  0.5f,  0.5f), XMFLOAT3(0.0f, 1.0f, 1.0f) }, <span class="rem">// Vertice 3 at -0.5,  0.5,  0.5 </span><br />    { XMFLOAT3( 0.5f, -0.5f, -0.5f), XMFLOAT3(1.0f, 0.0f, 0.0f) }, <span class="rem">// Vertice 4 at  0.5, -0.5, -0.5 // Red</span><br />    { XMFLOAT3( 0.5f, -0.5f,  0.5f), XMFLOAT3(1.0f, 0.0f, 1.0f) }, <span class="rem">// Vertice 5 at  0.5, -0.5,  0.5 </span><br />    { XMFLOAT3( 0.5f,  0.5f, -0.5f), XMFLOAT3(1.0f, 1.0f, 0.0f) }, <span class="rem">// Vertice 6 at  0.5,  0.5, -0.5 </span><br />    { XMFLOAT3( 0.5f,  0.5f,  0.5f), XMFLOAT3(1.0f, 1.0f, 1.0f) }, <span class="rem">// Vertice 7 at  0.5,  0.5,  0.5 // Black</span><br />};</pre>
</div>

<h4>Les faces <font style="font-weight: normal;">(déclaration des indices)</font></h4>

<p align="justify">Maintenant que nous avons nos <strong>sommets</strong>, il reste toutefois à définir les <strong>faces</strong> de notre cube pour compléter sa définition : celui-ci comporte 6 faces chacune composé de 4 sommets (un carré). Cependant, si vous raisonnez plus largement,&#160; certains objets 3D peuvent se définir avec des faces non rectangulaires. Par exemple une pyramide à base carrée comporte 1 face de 4 sommets (la base) + 4 faces de 3 sommets (les côtés triangulaires).</p>

<p align="justify">Les algorithmes pour remplir les faces seraient particulièrement complexes si le nombre de sommets étaient variables. Direct3D (et plus généralement le monde de la 3D) utilise donc des triangles comme primitive pour définir des faces ; chaque carré pouvant se représenter par deux triangles.</p>

<p align="justify">Si on reprend l’exemple de notre cube, la première face se compose donc de deux triangles: </p>

<ul>
  <li>
    <div align="justify">Triangle 1: {0, 2, 1}</div>
  </li>

  <li>
    <div align="justify">Triangle 2: {1, 2, 3}</div>
  </li>
</ul>

<p>&#160;</p>

<p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/1738.image_thumb17_30A06821.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/1738.image_5F00_thumb17_5F00_30A06821.png"><img title="faces 3D" style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="faces 3D" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/5481.image_thumb17_thumb_1255B12B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/5481.image_5F00_thumb17_5F00_thumb_5F00_1255B12B.png" width="640" height="345" /></a></p>

<p>Et en extrapolant, on se retrouve donc avec 12 triangles pour une définition complète des faces. On va cataloguer/indexer ces triangles dans un tableau que l’on nomme liste d’index ou <b>indices</b>. </p>

<div id="codeSnippetWrapper">
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">unsigned</span> <span class="kwrd">short</span> cubeIndices[] = <br />{<br />    0,2,1, <span class="rem">// -x</span><br />    1,2,3,<br /><br />    4,5,6, <span class="rem">// +x</span><br />    5,7,6,<br /><br />    0,1,5, <span class="rem">// -y</span><br />    0,5,4,<br /><br />    2,6,7, <span class="rem">// +y</span><br />    2,7,3,<br /><br />    0,4,6, <span class="rem">// -z</span><br />    0,6,2,<br /><br />    1,3,7, <span class="rem">// +z</span><br />    1,7,5,<br />};</pre>
</div>

<h4>Vertex buffer et Index buffer</h4>

<p align="justify">On a désormais une définition de notre cube stockée dans deux tableaux (cubeVertices et cubeIndices) mais DirectX à besoin d’un coup de main supplémentaire pour <strong>consommer</strong> et <strong>interpréter</strong> les données précédentes.</p>

<p align="justify">En premier lieu, les deux listes [sommets (<strong>vertices</strong>) et faces (<strong>indices</strong>)] doivent être stockées dans des buffers prévus à cet effet, nommés sans trop d'originalité <strong>Vertex buffer</strong> et <strong>Index buffer</strong> : c’est le rôle de la méthode <a href="http://msdn.microsoft.com/en-us/library/windows/apps/ff476501.aspx">ID3D11Device::CreateBuffer</a>.</p>

<p align="justify">Pour faire simple, <strong>ID3D11Device::CreateBuffer</strong> récupère en entrée …</p>

<ul>
  <li>
    <div align="justify">Les <strong>données</strong> via la structure <a href="http://msdn.microsoft.com/en-us/library/windows/apps/ff476220.aspx">D3D11_SUBRESOURCE_DATA</a> qui pointe sur nos tableaux cubeVertices ou cubeIndices.</div>
  </li>

  <li>
    <div align="justify">Une <strong>description</strong> via <a href="http://msdn.microsoft.com/en-us/library/windows/apps/ff476092.aspx">D3D11_BUFFER_DESC</a> pour indiquer l’usage de ces données : Vertex buffer, Index Buffer, …</div>
  </li>
</ul>

<p align="justify">&#160;</p>

<p align="justify">… et nous retourne un objet qui implémente l’interface <a href="http://msdn.microsoft.com/en-us/library/windows/apps/ff476351.aspx">D3D11Buffer</a> (notre buffer Direct3D). On obtient donc le code suivant pour instancier notre <strong>Vertex buffer</strong> :</p>

<div align="justify">
  <div id="codeSnippetWrapper" class="csharpcode-wrapper">
    <pre id="codeSnippet" class="csharpcode">D3D11_SUBRESOURCE_DATA vertexBufferData = { 0 };<br />vertexBufferData.pSysMem = cubeVertices;<br />vertexBufferData.SysMemPitch = 0;<br />vertexBufferData.SysMemSlicePitch = 0;<br /><br />CD3D11_BUFFER_DESC vertexBufferDesc(<span class="kwrd">sizeof</span>(cubeVertices), D3D11_BIND_VERTEX_BUFFER);<br />DX::ThrowIfFailed(<br />    m_d3dDevice-&gt;CreateBuffer(<br />    &amp;vertexBufferDesc,<br />    &amp;vertexBufferData,<br />    &amp;m_vertexBuffer<br />    )<br />    );</pre>

    <br /></div>

  <div>Et le code quasi équivalent pour son adjoint l’<strong>Index Buffer </strong>:&#160;&#160;&#160;&#160; </div>

  <div id="codeSnippetWrapper" class="csharpcode-wrapper">
    <pre id="codeSnippet" class="csharpcode">D3D11_SUBRESOURCE_DATA indexBufferData = { 0 };<br />indexBufferData.pSysMem = cubeIndices;<br />indexBufferData.SysMemPitch = 0;<br />indexBufferData.SysMemSlicePitch = 0;<br /><br />CD3D11_BUFFER_DESC indexBufferDesc(<span class="kwrd">sizeof</span>(cubeIndices), D3D11_BIND_INDEX_BUFFER);<br />DX::ThrowIfFailed(<br />    m_d3dDevice-&gt;CreateBuffer(<br />    &amp;indexBufferDesc,<br />    &amp;indexBufferData,<br />    &amp;m_indexBuffer<br />    )<br />    );</pre>

    <br /></div>

  <div>&#160;</div>
</div>

<p align="justify">Il y a toutefois une différence majeure pour DirectX entre ces deux buffers. Ils contiennent tous les deux des données mais, dans l’état, seul l’<strong>Index buffer</strong> est compréhensible par Direct3D. Pourquoi ?</p>

<p align="justify">Notre <strong>Vertex buffer</strong> contient la <strong>position</strong> des sommets, mais également des <strong>couleurs</strong>. Et à termes, vous allez renseigner d’autres informations associés à chaque sommet (notamment pour <strong>éclairer</strong> convenablement votre objet et le <strong>texturer)</strong>. Du coup, DirectX n’a aucune idée de la signification exacte des données que vous lui fournissez en entrée. Il n’est pas capable de les digérer sans un coup de pouce additionnel. Ce petit service est rendu par l’<strong>Input layout</strong>&#160; (cf. section suivante).</p>

<p align="justify">Ce n’est pas le cas de l’<strong>Index buffer</strong> dont le seul travail est de d’indexer les sommets pour fournir une liste de triangles. Direct3D connait nativement la signification de ces données.</p>

<div align="justify">
  <h4>Input layout</h4>

  <p>Le <strong>vertex buffer</strong> contient pour le moment une suite de nombre flottants. Direct3D (et donc la carte graphique) va traiter ces données en les passant dans plusieurs moulinettes dont la principale se nomme <strong>vertex shader</strong> (qui fera l’objet du prochain post). </p>

  <p>Dans l’état, la carte graphique ne sait pas la structure de ces données. Direct3D a besoin qu’on déblaie le passage en précisant le format de chaque élément pour que le <strong>vertex shader</strong> puisse les interpréter. L’<strong>input layout</strong> sert exactement à ca ! Dans notre cas, on obtient donc la définition suivante:</p>

  <div id="codeSnippetWrapper" class="csharpcode-wrapper">
    <pre id="codeSnippet" class="csharpcode"><span class="kwrd">const</span> D3D11_INPUT_ELEMENT_DESC vertexDesc [] =<br />{<br />    { <span class="str">&quot;POSITION&quot;</span>, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },<br />    { <span class="str">&quot;COLOR&quot;</span>, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },<br />};<br /><br />DX::ThrowIfFailed(<br />    m_d3dDevice-&gt;CreateInputLayout(<br />    vertexDesc,<br />    ARRAYSIZE(vertexDesc),<br />    fileData-&gt;Data,<br />    fileData-&gt;Length,<br />    &amp;m_inputLayout<br />    )<br />    );</pre>

    <br /></div>
</div>

<ul>
  <li>
    <div align="justify">POSITION : Exprime la position de nos sommets sous la forme des 3 flottants (32bits) : x, y et z.</div>
  </li>

  <li>
    <div align="justify">COLOR : Exprime la couleur de nos sommets sous la forme de 3 flottants également (32bits): r, g et b.</div>
  </li>
</ul>

<p align="justify">&#160;</p>

<p align="justify">Vous pouvez constater qu’on utilise le format <strong>DXGI_FORMAT_R32G32B32_FLOAT</strong> dans les deux cas, qui s’apparente à l’utilisation d’une couleur. Ce n’est pas une erreur, comme il s’agit de 3 flottants dans les deux cas, pourquoi ne pas utiliser le même format?</p>

<p align="justify">De manière plus imagé, notre tableau de flottants est donc désormais interprétable de la manière suivante par Direct3D:</p>

<div align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/1207.inputlayout_thumb26_08FC7CA8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/1207.inputlayout_5F00_thumb26_5F00_08FC7CA8.png"><img title="input layout" style="border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="input layout" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/0167.inputlayout_thumb26_thumb_7F37152F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/0167.inputlayout_5F00_thumb26_5F00_thumb_5F00_7F37152F.png" width="712" height="105" /></a></div>

<div id="codeSnippetWrapper" align="justify">&#160;</div>

<div align="justify">Bon, je vous laisse digérer tout ca ^^.</div>

<div align="justify">&#160;</div>

<div align="justify">Vous pouvez d’ores et déjà télécharger le code <a href="https://blogmedia.blob.core.windows.net/files/OmegaCrusher-Introduction.zip">ici</a> (qui ressemble pas mal au template par défaut dans l’état; mais ça ne va pas tarder à changer) et consulter la portion de code <strong>SceneRenderer::CreateDeviceResources()</strong> qui reprend (hormis le chargement des shaders) l’ensemble du code de cet article.</div>

<div align="justify">&#160;</div>

<div align="justify">SceneRenderer::CreateDeviceResources</div>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">void</span> SceneRenderer::CreateDeviceResources()<br />{<br />    <span class="kwrd">auto</span> loadVSTask = DX::ReadDataAsync(<span class="str">&quot;SimpleVertexShader.cso&quot;</span>);<br />    <span class="kwrd">auto</span> loadPSTask = DX::ReadDataAsync(<span class="str">&quot;SimplePixelShader.cso&quot;</span>);<br /><br />    <span class="kwrd">auto</span> createVSTask = loadVSTask.then([<span class="kwrd">this</span>](Platform::Array&lt;byte&gt;^ fileData) {<br />        DX::ThrowIfFailed(<br />            m_d3dDevice-&gt;CreateVertexShader(<br />            fileData-&gt;Data,<br />            fileData-&gt;Length,<br />            nullptr,<br />            &amp;m_vertexShader<br />            )<br />            );<br /><br />        <span class="kwrd">const</span> D3D11_INPUT_ELEMENT_DESC vertexDesc [] =<br />        {<br />            { <span class="str">&quot;POSITION&quot;</span>, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },<br />            { <span class="str">&quot;COLOR&quot;</span>, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },<br />        };<br /><br />        DX::ThrowIfFailed(<br />            m_d3dDevice-&gt;CreateInputLayout(<br />            vertexDesc,<br />            ARRAYSIZE(vertexDesc),<br />            fileData-&gt;Data,<br />            fileData-&gt;Length,<br />            &amp;m_inputLayout<br />            )<br />            );<br />    });<br /><br />    <span class="kwrd">auto</span> createPSTask = loadPSTask.then([<span class="kwrd">this</span>](Platform::Array&lt;byte&gt;^ fileData) {<br />        DX::ThrowIfFailed(<br />            m_d3dDevice-&gt;CreatePixelShader(<br />            fileData-&gt;Data,<br />            fileData-&gt;Length,<br />            nullptr,<br />            &amp;m_pixelShader<br />            )<br />            );<br /><br />        CD3D11_BUFFER_DESC constantBufferDesc(<span class="kwrd">sizeof</span>(ModelViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);<br />        DX::ThrowIfFailed(<br />            m_d3dDevice-&gt;CreateBuffer(<br />            &amp;constantBufferDesc,<br />            nullptr,<br />            &amp;m_constantBuffer<br />            )<br />            );<br />    });<br /><br />    <span class="kwrd">auto</span> createCubeTask = (createPSTask &amp;&amp; createVSTask).then([<span class="kwrd">this</span>]() {<br />        VertexPositionColor cubeVertices [] =<br />        {<br />            { XMFLOAT3(-0.5f, -0.5f, -0.5f), XMFLOAT3(0.0f, 0.0f, 0.0f) }, <span class="rem">// Vertice 0 at -0.5, -0.5, -0.5 // White</span><br />            { XMFLOAT3(-0.5f, -0.5f,  0.5f), XMFLOAT3(0.0f, 0.0f, 1.0f) }, <span class="rem">// Vertice 1 at -0.5, -0.5,  0.5 // Blue</span><br />            { XMFLOAT3(-0.5f,  0.5f, -0.5f), XMFLOAT3(0.0f, 1.0f, 0.0f) }, <span class="rem">// Vertice 2 at -0.5,  0.5, -0.5 // Green</span><br />            { XMFLOAT3(-0.5f,  0.5f,  0.5f), XMFLOAT3(0.0f, 1.0f, 1.0f) }, <span class="rem">// Vertice 3 at -0.5,  0.5,  0.5 </span><br />            { XMFLOAT3( 0.5f, -0.5f, -0.5f), XMFLOAT3(1.0f, 0.0f, 0.0f) }, <span class="rem">// Vertice 4 at  0.5, -0.5, -0.5 // Red</span><br />            { XMFLOAT3( 0.5f, -0.5f,  0.5f), XMFLOAT3(1.0f, 0.0f, 1.0f) }, <span class="rem">// Vertice 5 at  0.5, -0.5,  0.5 </span><br />            { XMFLOAT3( 0.5f,  0.5f, -0.5f), XMFLOAT3(1.0f, 1.0f, 0.0f) }, <span class="rem">// Vertice 6 at  0.5,  0.5, -0.5 </span><br />            { XMFLOAT3( 0.5f,  0.5f,  0.5f), XMFLOAT3(1.0f, 1.0f, 1.0f) }, <span class="rem">// Vertice 7 at  0.5,  0.5,  0.5 // Black</span><br />        };<br /><br />        D3D11_SUBRESOURCE_DATA vertexBufferData = { 0 };<br />        vertexBufferData.pSysMem = cubeVertices;<br />        vertexBufferData.SysMemPitch = 0;<br />        vertexBufferData.SysMemSlicePitch = 0;<br />        CD3D11_BUFFER_DESC vertexBufferDesc(<span class="kwrd">sizeof</span>(cubeVertices), D3D11_BIND_VERTEX_BUFFER);<br />        DX::ThrowIfFailed(<br />            m_d3dDevice-&gt;CreateBuffer(<br />            &amp;vertexBufferDesc,<br />            &amp;vertexBufferData,<br />            &amp;m_vertexBuffer<br />            )<br />            );<br /><br />        <span class="kwrd">unsigned</span> <span class="kwrd">short</span> cubeIndices [] =<br />        {<br />            0, 2, 1, <span class="rem">// -x</span><br />            1, 2, 3,<br /><br />            4, 5, 6, <span class="rem">// +x</span><br />            5, 7, 6,<br /><br />            0, 1, 5, <span class="rem">// -y</span><br />            0, 5, 4,<br /><br />            2, 6, 7, <span class="rem">// +y</span><br />            2, 7, 3,<br /><br />            0, 4, 6, <span class="rem">// -z</span><br />            0, 6, 2,<br /><br />            1, 3, 7, <span class="rem">// +z</span><br />            1, 7, 5,<br />        };<br /><br />        m_indexCount = ARRAYSIZE(cubeIndices);<br /><br />        D3D11_SUBRESOURCE_DATA indexBufferData = { 0 };<br />        indexBufferData.pSysMem = cubeIndices;<br />        indexBufferData.SysMemPitch = 0;<br />        indexBufferData.SysMemSlicePitch = 0;<br />        CD3D11_BUFFER_DESC indexBufferDesc(<span class="kwrd">sizeof</span>(cubeIndices), D3D11_BIND_INDEX_BUFFER);<br />        DX::ThrowIfFailed(<br />            m_d3dDevice-&gt;CreateBuffer(<br />            &amp;indexBufferDesc,<br />            &amp;indexBufferData,<br />            &amp;m_indexBuffer<br />            )<br />            );<br />    });<br /><br />    createCubeTask.then([<span class="kwrd">this</span>]() {<br />        m_loadingComplete = true;<br />    });<br />}</pre>

  <br /></div>

<div align="justify"></div>

<div align="justify">Prochain épisode prochainement sur les shaders et les matrices, …. keep posted ! :)</div>

<h3><font size="3"><font style="font-weight: normal;" color="#9b00d3">Ressources</font></font></h3>

<ul>
  <li><a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj714075(v=vs.105).aspx">Creating a Direct3D device and swap chain for Windows Phone 8</a></li>

  <li><a href="http://msdn.microsoft.com/en-us/library/windows/apps/jj554502.aspx">Get started with DirectX game development</a></li>

  <li><a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206992(v=vs.105).aspx">Games for Windows Phone</a></li>
</ul>

<p>&#160;</p>

<p align="right"><a href="https://blogmedia.blob.core.windows.net/files/OmegaCrusher-Introduction.zip">Télécharger le Code</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Tutorial Series - Introduction to Direct3D with XAML application development for Windows Phone 8 : Create a basic mesh</title>
      <link>https://docs.microsoft.com/archive/blogs/jdupuy/tutorial-series-introduction-to-direct3d-with-xaml-application-development-for-windows-phone-8-create-a-basic-mesh</link>
      <pubDate>Fri, 09 Aug 2013 10:31:10 GMT</pubDate>
      <dc:creator><![CDATA[Jean-Sébastien DUPUY]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jdupuy/2013/08/09/tutorial-series-introduction-to-direct3d-with-xaml-application-development-for-windows-phone-8-create-a-basic-mesh/</guid>
      <description><![CDATA[The previous episode showed us that we could display a blue background by using lot of code :) but...]]></description>
      <content:encoded><![CDATA[<p align="justify">The <a href="http://blogs.msdn.com/b/jdupuy/archive/2013/07/15/tutorial-series-introduction-to-direct3d-with-xaml-application-development-for-windows-phone-8.aspx">previous episode</a> showed us that we could display a blue background by using lot of code :) but in return you have now opened the door on DirectX. In this second article, I will attempt to explain the main concepts of <strong>Direct3D</strong> to help you start. These points are, however, not specific to Windows Phone, and you will find at the bottom of this article additional resources to help you.</p>  <h3><font style="font-weight: normal;" color="#9b00d3" size="3">Direct3D Initialization</font></h3>  <p align="justify">Good news, you do not have to manage this part of code, <strong>DrawingSurfaceBackgroundGrid</strong> control (or <strong>DrawingSurface</strong>) supports this point to you, it’s a gift! Of course, if you do not use the XAML controls and you want to develop an application 100% native, you must perform this initialization ... do not dream either :)</p>  <p align="justify">Specifically, what are the supported operations during this initialization??</p>  <p align="justify"><font color="#9b00d3">1.</font> Creating <strong>device</strong> and <strong>device context</strong> objects </p>  <p align="justify">Communication with the graphics card (or more broadly the device) is done through these two objects. These are the main entry points to use Direct3D.</p>  <ul>   <li>     <div align="justify">The <strong>device </strong>object (<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ff476379(v=vs.85).aspx">ID3D11Device</a>) is primarily responsible for creating the graphic <strong>resources</strong> (textures, vertex buffers, shaders, ...).</div>   </li>    <li>     <div align="justify">The <strong>device context </strong>object (<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ff476385(v=vs.85).aspx">ID3D11DeviceContext</a>) takes care of rendering operations using resources initialized by the device object.&#160;&#160;&#160;&#160;&#160;&#160; </div>   </li> </ul>  <p align="justify">&#160;</p>  <p align="justify"><font color="#9b00d3">2.</font> Creating <strong>swap chain</strong></p>  <p align="justify">The rendering is not performed directly on the screen, it is made into a buffer memory (aka. an array of pixels of the screen size) named <strong>back buffer</strong>. The swap chain is responsible for copying the contents of the back buffer directly on the screen. For information, the swap chain can theoretically use multiple back buffers, but Windows Phone limit its use to a <strong>single</strong> buffer.</p>  <p align="justify">In addition, Direct3D provides access to data located in the back buffer (our array of pixels) via the<strong> render target view</strong> object (<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ff476582(v=vs.85).aspx">ID3D11RenderTargetView</a>).</p>  <p align="justify">Lost? Let us take for example the lines of code from the previous post. The code Direct3DBackground::Draw method initializes our screen with a blue color.</p>  <blockquote>   <p align="justify">a/ ClearRenderTargetView method is called from the <strong>device context</strong> object<strong>        <br /></strong>b/ We target the back buffer via <strong>render target view </strong>object. It becomes clearer?</p> </blockquote>  <div id="codeSnippetWrapper" class="csharpcode-wrapper">   <pre id="codeSnippet" class="csharpcode">HRESULT Direct3DBackground::Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceContext1* context, _In_ ID3D11RenderTargetView* renderTargetView)<br />{<br />    <span class="rem">// Clear the render target to default values.</span><br />    <span class="kwrd">const</span> <span class="kwrd">float</span> midnightBlue [] = { 0.098f, 0.098f, 0.439f, 1.000f };<br />    context-&gt;ClearRenderTargetView(<br />        renderTargetView,<br />        midnightBlue<br />        );<br /><br />    RequestAdditionalFrame();<br /><br />    <span class="kwrd">return</span> S_OK;<br />}</pre>

  <br /></div>

<p align="justify">For additional information, I suggest you to read the following article: <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj714075(v=vs.105).aspx">Creating a Direct3D device and swap chain for Windows Phone 8</a>.</p>

<!--more-->

<p align="justify"></p>

<h3><font style="font-weight: normal;" color="#9b00d3" size="3">Building our 3D mesh object</font></h3>

<h4 align="justify">Vertices</h4>

<p align="justify">A 3D object (or <strong>mesh</strong>) is generally defined by a list of <strong>vertices</strong> and <strong>faces</strong>. For example, eight vertices are needed to describe a cube. And since we're in a three-dimensional world, each vertex has three coordinates: x, y and z. If the center of the cube is placed at the origin of the scene, with vertices values defined ​​between -0.5 and 0.5, we obtain the following table:</p>

<p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/3058.image_123DE874.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/3058.image_5F00_123DE874.png"><img title="image" style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/4456.image_thumb_0231AA6E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/4456.image_5F00_thumb_5F00_0231AA6E.png" width="640" height="81" /></a></p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/0602.image_0B213CAD.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/0602.image_5F00_0B213CAD.png"><img title="image" style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/3022.image_thumb_5A8DBEF4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/3022.image_5F00_thumb_5F00_5A8DBEF4.png" width="640" height="290" /></a></p>

<p align="justify">To complete our example, we will assign a <strong>color</strong> to each vertex (to see the faces more easily when rendering). This color is also made up of three values​​: red, green and blue (RGB format). A vertex will be defined by a <strong>position</strong> and a <strong>color</strong> associated in the following way:</p>

<div id="codeSnippetWrapper">
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">struct</span> VertexPositionColor<br />{<br />    DirectX::XMFLOAT3 pos;<br />    DirectX::XMFLOAT3 color;<br />};</pre>
</div>

<p align="justify">For complex objects, we usually load the values ​​from a file (eg from an Autodesk FBX format which will be the subject of a future post to load our shuttle). In the present case, we will manually declare our vertices table with colors defined arbitrarily:</p>

<div id="codeSnippetWrapper">
  <pre id="codeSnippet" class="csharpcode">VertexPositionColor cubeVertices [] =<br />{<br />    { XMFLOAT3(-0.5f, -0.5f, -0.5f), XMFLOAT3(0.0f, 0.0f, 0.0f) }, <span class="rem">// Vertice 0 at -0.5, -0.5, -0.5 // White</span><br />    { XMFLOAT3(-0.5f, -0.5f,  0.5f), XMFLOAT3(0.0f, 0.0f, 1.0f) }, <span class="rem">// Vertice 1 at -0.5, -0.5,  0.5 // Blue</span><br />    { XMFLOAT3(-0.5f,  0.5f, -0.5f), XMFLOAT3(0.0f, 1.0f, 0.0f) }, <span class="rem">// Vertice 2 at -0.5,  0.5, -0.5 // Green</span><br />    { XMFLOAT3(-0.5f,  0.5f,  0.5f), XMFLOAT3(0.0f, 1.0f, 1.0f) }, <span class="rem">// Vertice 3 at -0.5,  0.5,  0.5 </span><br />    { XMFLOAT3( 0.5f, -0.5f, -0.5f), XMFLOAT3(1.0f, 0.0f, 0.0f) }, <span class="rem">// Vertice 4 at  0.5, -0.5, -0.5 // Red</span><br />    { XMFLOAT3( 0.5f, -0.5f,  0.5f), XMFLOAT3(1.0f, 0.0f, 1.0f) }, <span class="rem">// Vertice 5 at  0.5, -0.5,  0.5 </span><br />    { XMFLOAT3( 0.5f,  0.5f, -0.5f), XMFLOAT3(1.0f, 1.0f, 0.0f) }, <span class="rem">// Vertice 6 at  0.5,  0.5, -0.5 </span><br />    { XMFLOAT3( 0.5f,  0.5f,  0.5f), XMFLOAT3(1.0f, 1.0f, 1.0f) }, <span class="rem">// Vertice 7 at  0.5,  0.5,  0.5 // Black</span><br />};</pre>
</div>

<h4>Faces <font style="font-weight: normal;">(indices declaration)</font></h4>

<p align="justify">Now that we have our <strong>vertices</strong>, it remains to define the <strong>faces</strong> of the cube to complete its definition: it has six faces, each consisting of four vertices (a square). However, if you reason more broadly, some 3D objects cannot be defined with rectangular faces. For example, a square base pyramid is built with one face of 4 vertices (the square basement) + four faces of 3 vertices (the triangular sides).</p>

<p align="justify">Algorithms to fill the faces would be particularly complex if the number of vertices is variable. Direct3D (and more generally the 3D world) therefore uses triangles as primitive to define faces, each square can be represented by two triangles.</p>

<p align="justify">If we take the example of our cube, the first side is therefore composed of two triangles:</p>

<ul>
  <li>
    <div align="justify">Triangle 1: {0, 2, 1}</div>
  </li>

  <li>
    <div align="justify">Triangle 2: {1, 2, 3}</div>
  </li>
</ul>

<p>&#160;</p>

<p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/6102.image_234737B9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/6102.image_5F00_234737B9.png"><img title="image" style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/6545.image_thumb_72B3BA00.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/6545.image_5F00_thumb_5F00_72B3BA00.png" width="640" height="345" /></a></p>

<p align="justify">And extrapolating, we end up with 12 triangles for a complete definition of faces. We will catalog / index these triangles in a table named <strong>indices</strong>.</p>

<div id="codeSnippetWrapper">
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">unsigned</span> <span class="kwrd">short</span> cubeIndices[] = <br />{<br />    0,2,1, <span class="rem">// -x</span><br />    1,2,3,<br /><br />    4,5,6, <span class="rem">// +x</span><br />    5,7,6,<br /><br />    0,1,5, <span class="rem">// -y</span><br />    0,5,4,<br /><br />    2,6,7, <span class="rem">// +y</span><br />    2,7,3,<br /><br />    0,4,6, <span class="rem">// -z</span><br />    0,6,2,<br /><br />    1,3,7, <span class="rem">// +z</span><br />    1,7,5,<br />};</pre>
</div>

<h4>Vertex buffer and Index buffer</h4>

<p align="justify">We just obtained a definition of our cube stored in two tables (cubeVertices and cubeIndices) but DirectX need a little extra hand to <strong>use</strong> and <strong>interpret</strong> the data above.</p>

<p align="justify">First, the two lists [<strong>vertices</strong> and faces (<strong>indices</strong>)] must be stored in buffers provided for this purpose, named without much originality <strong>Vertex Buffer</strong> and <strong>Index Buffer</strong>: this is the purpose of <a href="http://msdn.microsoft.com/en-us/library/windows/apps/ff476501.aspx">ID3D11Device::CreateBuffer</a> method.</p>

<p align="justify">Simply, <strong>ID3D11Device::CreateBuffer</strong> will take the following input arguments …</p>

<ul>
  <li>
    <div align="justify"><strong>Data</strong> via <a href="http://msdn.microsoft.com/en-us/library/windows/apps/ff476220.aspx">D3D11_SUBRESOURCE_DATA</a> structure that points to our cubeVertices or cubeIndices tables.</div>
  </li>

  <li>
    <div align="justify">A <strong>description</strong> via <a href="http://msdn.microsoft.com/en-us/library/windows/apps/ff476092.aspx">D3D11_BUFFER_DESC</a> to indicate the use of these data: vertex buffer, index buffer, ...</div>
  </li>
</ul>

<p align="justify">&#160;</p>

<p align="justify">… and we will return an object that implements the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/ff476351.aspx">D3D11Buffer</a> interface (our Direct3D buffer). So we get the following code to instantiate our <strong>Vertex Buffer</strong>:</p>

<div align="justify">
  <div id="codeSnippetWrapper" class="csharpcode-wrapper">
    <pre id="codeSnippet" class="csharpcode">D3D11_SUBRESOURCE_DATA vertexBufferData = { 0 };<br />vertexBufferData.pSysMem = cubeVertices;<br />vertexBufferData.SysMemPitch = 0;<br />vertexBufferData.SysMemSlicePitch = 0;<br /><br />CD3D11_BUFFER_DESC vertexBufferDesc(<span class="kwrd">sizeof</span>(cubeVertices), D3D11_BIND_VERTEX_BUFFER);<br />DX::ThrowIfFailed(<br />    m_d3dDevice-&gt;CreateBuffer(<br />    &amp;vertexBufferDesc,<br />    &amp;vertexBufferData,<br />    &amp;m_vertexBuffer<br />    )<br />    );</pre>

    <br /></div>&#160;&#160; And code almost equivalent to instantiate the <strong>Index Buffer</strong>: 

  <div id="codeSnippetWrapper" class="csharpcode-wrapper">
    <pre id="codeSnippet" class="csharpcode">D3D11_SUBRESOURCE_DATA indexBufferData = { 0 };<br />indexBufferData.pSysMem = cubeIndices;<br />indexBufferData.SysMemPitch = 0;<br />indexBufferData.SysMemSlicePitch = 0;<br /><br />CD3D11_BUFFER_DESC indexBufferDesc(<span class="kwrd">sizeof</span>(cubeIndices), D3D11_BIND_INDEX_BUFFER);<br />DX::ThrowIfFailed(<br />    m_d3dDevice-&gt;CreateBuffer(<br />    &amp;indexBufferDesc,<br />    &amp;indexBufferData,<br />    &amp;m_indexBuffer<br />    )<br />    );</pre>

    <br /></div>

  <div>&#160;</div>
</div>

<p align="justify">There is one major difference between these two buffers DirectX. They both contain data, but in the state, only the <strong>Index</strong> <strong>buffer</strong> is understood by Direct3D. Why?</p>

<p align="justify">Our <strong>Vertex buffer</strong> contains the <strong>position</strong> of the vertices, but also the <strong>colors</strong>. And in the future posts, you will add other information associated with each vertex (including texture coordinates, normals …). So, at the moment, DirectX has no idea of the exact meaning of this data that you provided. It is not able to digest without an added boost. This small service is offered by the <strong>input layout</strong> (see next section).</p>

<p align="justify">This is not the case of the <strong>Index buffer</strong> whose only job is to index the vertices to provide a list of triangles. Direct3D natively knows the meaning of these data</p>

<div align="justify">
  <h4>Input layout</h4>

  <p>The <strong>vertex buffer</strong> currently contains a series of floating point numbers. Direct3D will process this data into a pipeline whose main stage is called <strong>vertex shader</strong> (which will be topic of the next post).</p>

  <p>In the current state, the graphics card does not know the structure of the data. Direct3D requires that we clear the way by specifying the format of each element: by the way, the <strong>vertex shader</strong> can interpret this information. The <strong>input layout</strong> is exactly designed for that purpose! In our case, we obtain the following definition:</p>

  <div id="codeSnippetWrapper" class="csharpcode-wrapper">
    <pre id="codeSnippet" class="csharpcode"><span class="kwrd">const</span> D3D11_INPUT_ELEMENT_DESC vertexDesc [] =<br />{<br />    { <span class="str">&quot;POSITION&quot;</span>, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },<br />    { <span class="str">&quot;COLOR&quot;</span>, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },<br />};<br /><br />DX::ThrowIfFailed(<br />    m_d3dDevice-&gt;CreateInputLayout(<br />    vertexDesc,<br />    ARRAYSIZE(vertexDesc),<br />    fileData-&gt;Data,<br />    fileData-&gt;Length,<br />    &amp;m_inputLayout<br />    )<br />    );</pre>

    <br /></div>
</div>

<ul>
  <li>
    <div align="justify">POSITION: Declares the position of our vertices with 3 floats struct (32bits): x, y and z.</div>
  </li>

  <li>
    <div align="justify">COLOR: Declares the color of our vertices with 3 floats struct (32bit): r, g and b.</div>
  </li>
</ul>

<p align="justify">&#160;</p>

<p align="justify">You may find that I used the <strong>DXGI_FORMAT_R32G32B32_FLOAT</strong> format in both cases, which seems to be specific to RGB color usage. This is not a mistake, as it is a 3 floats struct in both cases, why not use the same format?</p>

<p align="justify">In more pictorial way, our array of floats is now interpreted as follows by Direct3D:</p>

<div align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/1665.inputlayout_5AE68D23.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/1665.inputlayout_5F00_5AE68D23.png"><img title="inputlayout" style="border: 0px currentcolor; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" border="0" alt="inputlayout" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/70/29/metablogapi/4300.inputlayout_thumb_6612A81E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-70-29-metablogapi/4300.inputlayout_5F00_thumb_5F00_6612A81E.png" width="712" height="105" /></a></div>

<div id="codeSnippetWrapper" align="justify">&#160;</div>

<div align="justify">Well, I'll let you digest all this ^^.</div>

<div align="justify">&#160;</div>

<div align="justify">You can already download the code <a href="https://blogmedia.blob.core.windows.net/files/OmegaCrusher-Introduction.zip">here</a> (which looks similar as default template in the state, but that will soon change) and check out the portion of code <strong>SceneRenderer::CreateDeviceResources()</strong> that resumes (except loading shaders) the entire code for this article.</div>

<div align="justify">&#160;</div>

<div align="justify">SceneRenderer::CreateDeviceResources</div>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">void</span> SceneRenderer::CreateDeviceResources()<br />{<br />    <span class="kwrd">auto</span> loadVSTask = DX::ReadDataAsync(<span class="str">&quot;SimpleVertexShader.cso&quot;</span>);<br />    <span class="kwrd">auto</span> loadPSTask = DX::ReadDataAsync(<span class="str">&quot;SimplePixelShader.cso&quot;</span>);<br /><br />    <span class="kwrd">auto</span> createVSTask = loadVSTask.then([<span class="kwrd">this</span>](Platform::Array&lt;byte&gt;^ fileData) {<br />        DX::ThrowIfFailed(<br />            m_d3dDevice-&gt;CreateVertexShader(<br />            fileData-&gt;Data,<br />            fileData-&gt;Length,<br />            nullptr,<br />            &amp;m_vertexShader<br />            )<br />            );<br /><br />        <span class="kwrd">const</span> D3D11_INPUT_ELEMENT_DESC vertexDesc [] =<br />        {<br />            { <span class="str">&quot;POSITION&quot;</span>, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },<br />            { <span class="str">&quot;COLOR&quot;</span>, 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },<br />        };<br /><br />        DX::ThrowIfFailed(<br />            m_d3dDevice-&gt;CreateInputLayout(<br />            vertexDesc,<br />            ARRAYSIZE(vertexDesc),<br />            fileData-&gt;Data,<br />            fileData-&gt;Length,<br />            &amp;m_inputLayout<br />            )<br />            );<br />    });<br /><br />    <span class="kwrd">auto</span> createPSTask = loadPSTask.then([<span class="kwrd">this</span>](Platform::Array&lt;byte&gt;^ fileData) {<br />        DX::ThrowIfFailed(<br />            m_d3dDevice-&gt;CreatePixelShader(<br />            fileData-&gt;Data,<br />            fileData-&gt;Length,<br />            nullptr,<br />            &amp;m_pixelShader<br />            )<br />            );<br /><br />        CD3D11_BUFFER_DESC constantBufferDesc(<span class="kwrd">sizeof</span>(ModelViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);<br />        DX::ThrowIfFailed(<br />            m_d3dDevice-&gt;CreateBuffer(<br />            &amp;constantBufferDesc,<br />            nullptr,<br />            &amp;m_constantBuffer<br />            )<br />            );<br />    });<br /><br />    <span class="kwrd">auto</span> createCubeTask = (createPSTask &amp;&amp; createVSTask).then([<span class="kwrd">this</span>]() {<br />        VertexPositionColor cubeVertices [] =<br />        {<br />            { XMFLOAT3(-0.5f, -0.5f, -0.5f), XMFLOAT3(0.0f, 0.0f, 0.0f) }, <span class="rem">// Vertice 0 at -0.5, -0.5, -0.5 // White</span><br />            { XMFLOAT3(-0.5f, -0.5f,  0.5f), XMFLOAT3(0.0f, 0.0f, 1.0f) }, <span class="rem">// Vertice 1 at -0.5, -0.5,  0.5 // Blue</span><br />            { XMFLOAT3(-0.5f,  0.5f, -0.5f), XMFLOAT3(0.0f, 1.0f, 0.0f) }, <span class="rem">// Vertice 2 at -0.5,  0.5, -0.5 // Green</span><br />            { XMFLOAT3(-0.5f,  0.5f,  0.5f), XMFLOAT3(0.0f, 1.0f, 1.0f) }, <span class="rem">// Vertice 3 at -0.5,  0.5,  0.5 </span><br />            { XMFLOAT3( 0.5f, -0.5f, -0.5f), XMFLOAT3(1.0f, 0.0f, 0.0f) }, <span class="rem">// Vertice 4 at  0.5, -0.5, -0.5 // Red</span><br />            { XMFLOAT3( 0.5f, -0.5f,  0.5f), XMFLOAT3(1.0f, 0.0f, 1.0f) }, <span class="rem">// Vertice 5 at  0.5, -0.5,  0.5 </span><br />            { XMFLOAT3( 0.5f,  0.5f, -0.5f), XMFLOAT3(1.0f, 1.0f, 0.0f) }, <span class="rem">// Vertice 6 at  0.5,  0.5, -0.5 </span><br />            { XMFLOAT3( 0.5f,  0.5f,  0.5f), XMFLOAT3(1.0f, 1.0f, 1.0f) }, <span class="rem">// Vertice 7 at  0.5,  0.5,  0.5 // Black</span><br />        };<br /><br />        D3D11_SUBRESOURCE_DATA vertexBufferData = { 0 };<br />        vertexBufferData.pSysMem = cubeVertices;<br />        vertexBufferData.SysMemPitch = 0;<br />        vertexBufferData.SysMemSlicePitch = 0;<br />        CD3D11_BUFFER_DESC vertexBufferDesc(<span class="kwrd">sizeof</span>(cubeVertices), D3D11_BIND_VERTEX_BUFFER);<br />        DX::ThrowIfFailed(<br />            m_d3dDevice-&gt;CreateBuffer(<br />            &amp;vertexBufferDesc,<br />            &amp;vertexBufferData,<br />            &amp;m_vertexBuffer<br />            )<br />            );<br /><br />        <span class="kwrd">unsigned</span> <span class="kwrd">short</span> cubeIndices [] =<br />        {<br />            0, 2, 1, <span class="rem">// -x</span><br />            1, 2, 3,<br /><br />            4, 5, 6, <span class="rem">// +x</span><br />            5, 7, 6,<br /><br />            0, 1, 5, <span class="rem">// -y</span><br />            0, 5, 4,<br /><br />            2, 6, 7, <span class="rem">// +y</span><br />            2, 7, 3,<br /><br />            0, 4, 6, <span class="rem">// -z</span><br />            0, 6, 2,<br /><br />            1, 3, 7, <span class="rem">// +z</span><br />            1, 7, 5,<br />        };<br /><br />        m_indexCount = ARRAYSIZE(cubeIndices);<br /><br />        D3D11_SUBRESOURCE_DATA indexBufferData = { 0 };<br />        indexBufferData.pSysMem = cubeIndices;<br />        indexBufferData.SysMemPitch = 0;<br />        indexBufferData.SysMemSlicePitch = 0;<br />        CD3D11_BUFFER_DESC indexBufferDesc(<span class="kwrd">sizeof</span>(cubeIndices), D3D11_BIND_INDEX_BUFFER);<br />        DX::ThrowIfFailed(<br />            m_d3dDevice-&gt;CreateBuffer(<br />            &amp;indexBufferDesc,<br />            &amp;indexBufferData,<br />            &amp;m_indexBuffer<br />            )<br />            );<br />    });<br /><br />    createCubeTask.then([<span class="kwrd">this</span>]() {<br />        m_loadingComplete = true;<br />    });<br />}</pre>

  <br /></div>

<div align="justify"></div>

<div align="justify">Next episode soon on shaders and matrices .... keep posted! :)</div>

<h3><font size="3"><font style="font-weight: normal;" color="#9b00d3">Resources</font></font></h3>

<ul>
  <li><a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj714075(v=vs.105).aspx">Creating a Direct3D device and swap chain for Windows Phone 8</a></li>

  <li><a href="http://msdn.microsoft.com/en-us/library/windows/apps/jj554502.aspx">Get started with DirectX game development</a></li>

  <li><a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206992(v=vs.105).aspx">Games for Windows Phone</a></li>
</ul>

<p>&#160;</p>

<p align="right"><a href="https://blogmedia.blob.core.windows.net/files/OmegaCrusher-Introduction.zip">Download the Code</a></p>]]></content:encoded>
    </item>
  </channel>
</rss>