AMBIENT INTELLIGENCE
tech days•
2015
#mstechdays techdays.microsoft.fr
Windows Phone:
Migrez de Silverlight vers
Universal App
Rudy Huyn / Julien Lo Presti
@rudyhuyn / @julopresti
tech.days 2015#mstechdays
MVP Client Development
www.rudyhuyn.com
@rudyhuyn
6Studio
Windows Phone : Migrez de Silverlight vers Universal App
tech.days 2015#mstechdays
Consultant .NET à Soat
www.jlopresti.fr
@julopresti
Windows Phone : Migrez de Silverlight vers Universal App
tech.days 2015#mstechdays
 Historique de la convergence
 Pourquoi ne pas migrer
 La migration vers Universal App
Windows Phone : Migrez de Silverlight vers Universal App
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Pourquoi ne pas migrer?
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
 Lock Screen Image
 Fournisseur de sonnerie
 Alarmes et reminder
 Faire fonctionner vos applications sous le lock-screen
 Lense (application caméra)
 Clipboard API
 OpacityMask, RadialGradientBrush
 Clip
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
 CameraCaptureTask
 VOIP
Feature Silverlight
8.0
Silverlight
8.1
XAML
Continuous Background Execution Agents (GPS
Apps)
  
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
 Mutualisation du code entre Windows et Windows Phone
 Meilleures performances
 Adaptation du rendu selon le device
 API pour éditer des vidéos
 Accéder aux sensors en tâche de fond (DeviceUseTrigger + Sensor)
 UI testing
Feature Silverlight 8.0 Silverlight 8.1 XAML
Background Audio   
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
 Amélioration Contrôles (Combobox, Textbox, …)
<StackPanel>
<TextBlock Text="Name />
<TextBox Text="Name"/>
</StackPanel>
<TextBox PlaceholderText="Name" Header="Name"/>
Silverlight
Store App
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Est-ce si différent ?
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
FAUX !
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Langage XAML
Framework Lifecycle
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
VBC#
F# C++
VBC#
F# C++
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
WinPRT
• Windows Phone Runtime
• Sous ensemble de WinRT pour Silverlight Phone 8.0
• Exemple:
• Windows.Devices.Geolocation.Geolocator
• Windows.Storage.StorageFolder
• Windows.Graphics.Display.DisplayProperties
• Windows.Networking.Proximity.PeerFinder
• Windows.System.Launcher.LaunchUriAsync
• …
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
La migration vers WinRT
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
 Changement du nom de l’évènement :
 Tap  Tapped
 DoubleTap  DoubleTapped
 Quelques changements de comportement par défaut
 Alignement horizontal des boutons
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
 Changement de l’enum pour l’InputScope
 Animations (Independent/DependentAnimation)
 EnableDependentAnimation = true
 TiltEffect (PointerDownAnimation)
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
• Fondamentalement identique
• Quelques modifications
• Déclaration des namespaces
• xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
• xmlns:phone="using:Microsoft.Phone.Controls«
• https://msdn.microsoft.com/en-us/library/windows/apps/dn800286.aspx
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Un seul canvas pour une diversité d’écran
Fournit un système de
layout et de
coordonnées commun
10”
tablet
7” tablet
6”
5”
4.5”
Infinite virtual canvas
166 Logical DPI
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
https://msdn.microsoft.com/en-us/library/windows/apps/Hh761491.aspx
Silverlight
 Flip
 Iconic
 Cycle
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
https://msdn.microsoft.com/en-us/library/windows/apps/Hh761491.aspx
Store App
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
 Equivalent au <Hub/> mais…
 attention, comportement différent
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
 Gestion des thèmes : Default, Dark, Light, HighContrast
 Récupération d’une ressource selon le thème appliqué
 Pas de changement à l’exécution
 RequestedTheme pour forcer un thème spécifique sur un
FrameworkElement ou sur l’application
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="TargetBackground" Color="Red"/>
<SolidColorBrush x:Key="TargetBorderBrush" Color="Black"/>
</ResourceDictionary>
<ResourceDictionary x:Key=“Dark">
<SolidColorBrush x:Key="TargetBackground" Color="Black"/>
<SolidColorBrush x:Key="TargetBorderBrush" Color="White"/>
</ResourceDictionary>
<ResourceDictionary x:Key=“Light">
<SolidColorBrush x:Key="TargetBackground" Color="White"/>
<SolidColorBrush x:Key="TargetBorderBrush" Color="Black"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Silverlight:
FontFamily="Segoe WP Black"
FontFamily="Segoe WP Light"
WinRT:
FontWeight="Black"
FontWeight="Light"
tech.days 2015#mstechdaysTitre session pied de page
tech.days 2015#mstechdaysTitre session pied de page
FontFamily="{ThemeResource PhoneFontFamilyNormal}"
#if WINDOWS_PHONE_APP
rootFrame.FontFamily = new FontFamily("Segoe WP");
#endif
Solution
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
 Applicationbar
 CommandBar
 1 seule par page
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Attention
{Binding .}
UIElement.OpacityProperty
“Opacity”
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Démo dans la vraie vie
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Silverlight WinRT
Application_Launching OnLaunched
Application_Activated Resuming/OnActivated
Application_Deactivated OnSuspending
Application_Closing Pas d’equivalent
IsApplicationInstancePreserved PreviousExecutionState
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
• Contexte de l’application conservée
• Fermeture de l’application par le gestionnaire de tâches
• L’état « terminated » ne conserve aucun état (ni stack de navigation ni
dictionnaire global)
• ATTENTION au bouton back
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Pros Cons
Restaurer l’état après un
« resuming » quand T < ? min
sinon réinitialiser app
NE PAS FERMER l’application pour
reproduire le comportement de 8.0
Sauvegarder l’état de l’app dans le
suspending
Ne pas restaurer l’état si
l’application a été fermée par
l’utilisateur
Sauvegarder plusieurs historiques
de navigation quand plusieurs
points d’entrée disponibles
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Nouveau template de projet:
Blank App n’inclut pas la gestion de la touche back
Hub App, Pivot App l’inclut dans la classe /Common/NavigationHelper
Ce qui cause un retour vers la page précédente
Si vous avez besoin de surcharger ceci, remplacez avec votre code pour une gestion custom de la
navigation
Gestion du bouton back
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Cache mode
NavigationCacheMode.Disabled
NavigationCacheMode.Enabled
NavigationCacheMode.Required
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Cache mode exemple
Page 1 Page 2 Page 3
new new
?
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Task
TimeTrigger
PUSH
Notification
LocationTrigger
PushNotificationTrigger
MaintenanceTrigger
InternetAvailable NetworkStateChange
TimeZoneChange
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Local
Emplacement principal
Peut être sauvegardé sur OneDrive
Roaming
Données partagées entre devices
Limité à 100kb
Temp
Données temporaires
Peut être vidé lorsque la mémoire du telephone
est pleine
Device B
WP 8.1 – PFN 12345
Roaming Local
Local
Cache
Temp
Device A
WP 8.1 App
Roaming Local
Local
Cache
Temp
Backup [Device A]
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
<TextBlock Text=""{Binding LocalizedResources.Farewell,
Source={StaticResource LocalizedStrings}}" />
Utilisation depuis le code:
Utilisation en XAML:
var message = AppResources.Farewell;
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
<TextBlock x:Uid="Greeting" Text="?" />
Utilisation depuis le code:
Utilisation en XAML:
var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
var string = loader.GetString('Farewell');
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Silverlight Universal Apps
Resx Resw
Dictionary<string,object> Dictionary<string,string>
Création de propriétés Accès via clés
Binding complexe et coûteux Résolution automatique
Le Xaml pilote la localisation Le resw pilote la localisation
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
 Les projets Universal apps ne supporte pas resx…
 Mais !
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
 Renommer vos *.resx en *.resw
 Utiliser une portable library
tech.days 2015#mstechdaysWindows Phone : Migrez de Silverlight vers Universal App
Démo !
tech.days 2015#mstechdaysTitre session pied de page
Windows Phone: Migrez de Silverlight vers Universal App, Préparez vous à Windows 10

Windows Phone: Migrez de Silverlight vers Universal App, Préparez vous à Windows 10

  • 1.
  • 2.
    Windows Phone: Migrez deSilverlight vers Universal App Rudy Huyn / Julien Lo Presti @rudyhuyn / @julopresti
  • 3.
    tech.days 2015#mstechdays MVP ClientDevelopment www.rudyhuyn.com @rudyhuyn 6Studio Windows Phone : Migrez de Silverlight vers Universal App
  • 4.
    tech.days 2015#mstechdays Consultant .NETà Soat www.jlopresti.fr @julopresti Windows Phone : Migrez de Silverlight vers Universal App
  • 5.
    tech.days 2015#mstechdays  Historiquede la convergence  Pourquoi ne pas migrer  La migration vers Universal App Windows Phone : Migrez de Silverlight vers Universal App
  • 6.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Pourquoi ne pas migrer?
  • 7.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App  Lock Screen Image  Fournisseur de sonnerie  Alarmes et reminder  Faire fonctionner vos applications sous le lock-screen  Lense (application caméra)  Clipboard API  OpacityMask, RadialGradientBrush  Clip
  • 8.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App  CameraCaptureTask  VOIP Feature Silverlight 8.0 Silverlight 8.1 XAML Continuous Background Execution Agents (GPS Apps)   
  • 9.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App  Mutualisation du code entre Windows et Windows Phone  Meilleures performances  Adaptation du rendu selon le device  API pour éditer des vidéos  Accéder aux sensors en tâche de fond (DeviceUseTrigger + Sensor)  UI testing Feature Silverlight 8.0 Silverlight 8.1 XAML Background Audio   
  • 10.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App  Amélioration Contrôles (Combobox, Textbox, …) <StackPanel> <TextBlock Text="Name /> <TextBox Text="Name"/> </StackPanel> <TextBox PlaceholderText="Name" Header="Name"/> Silverlight Store App
  • 11.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App
  • 12.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Est-ce si différent ?
  • 13.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App FAUX !
  • 14.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Langage XAML Framework Lifecycle
  • 15.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App VBC# F# C++ VBC# F# C++
  • 16.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App WinPRT • Windows Phone Runtime • Sous ensemble de WinRT pour Silverlight Phone 8.0 • Exemple: • Windows.Devices.Geolocation.Geolocator • Windows.Storage.StorageFolder • Windows.Graphics.Display.DisplayProperties • Windows.Networking.Proximity.PeerFinder • Windows.System.Launcher.LaunchUriAsync • …
  • 17.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App La migration vers WinRT
  • 18.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App  Changement du nom de l’évènement :  Tap  Tapped  DoubleTap  DoubleTapped  Quelques changements de comportement par défaut  Alignement horizontal des boutons
  • 19.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App  Changement de l’enum pour l’InputScope  Animations (Independent/DependentAnimation)  EnableDependentAnimation = true  TiltEffect (PointerDownAnimation)
  • 20.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App
  • 21.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App • Fondamentalement identique • Quelques modifications • Déclaration des namespaces • xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" • xmlns:phone="using:Microsoft.Phone.Controls« • https://msdn.microsoft.com/en-us/library/windows/apps/dn800286.aspx
  • 22.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Un seul canvas pour une diversité d’écran Fournit un système de layout et de coordonnées commun 10” tablet 7” tablet 6” 5” 4.5” Infinite virtual canvas 166 Logical DPI
  • 23.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App
  • 24.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App https://msdn.microsoft.com/en-us/library/windows/apps/Hh761491.aspx Silverlight  Flip  Iconic  Cycle
  • 25.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App https://msdn.microsoft.com/en-us/library/windows/apps/Hh761491.aspx Store App
  • 26.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App  Equivalent au <Hub/> mais…  attention, comportement différent
  • 27.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App  Gestion des thèmes : Default, Dark, Light, HighContrast  Récupération d’une ressource selon le thème appliqué  Pas de changement à l’exécution  RequestedTheme pour forcer un thème spécifique sur un FrameworkElement ou sur l’application
  • 28.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App <ResourceDictionary.ThemeDictionaries> <ResourceDictionary x:Key="Default"> <SolidColorBrush x:Key="TargetBackground" Color="Red"/> <SolidColorBrush x:Key="TargetBorderBrush" Color="Black"/> </ResourceDictionary> <ResourceDictionary x:Key=“Dark"> <SolidColorBrush x:Key="TargetBackground" Color="Black"/> <SolidColorBrush x:Key="TargetBorderBrush" Color="White"/> </ResourceDictionary> <ResourceDictionary x:Key=“Light"> <SolidColorBrush x:Key="TargetBackground" Color="White"/> <SolidColorBrush x:Key="TargetBorderBrush" Color="Black"/> </ResourceDictionary> </ResourceDictionary.ThemeDictionaries>
  • 29.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Silverlight: FontFamily="Segoe WP Black" FontFamily="Segoe WP Light" WinRT: FontWeight="Black" FontWeight="Light"
  • 30.
  • 31.
    tech.days 2015#mstechdaysTitre sessionpied de page FontFamily="{ThemeResource PhoneFontFamilyNormal}" #if WINDOWS_PHONE_APP rootFrame.FontFamily = new FontFamily("Segoe WP"); #endif Solution
  • 32.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App  Applicationbar  CommandBar  1 seule par page
  • 33.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Attention {Binding .} UIElement.OpacityProperty “Opacity”
  • 34.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Démo dans la vraie vie
  • 35.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App
  • 36.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App
  • 37.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Silverlight WinRT Application_Launching OnLaunched Application_Activated Resuming/OnActivated Application_Deactivated OnSuspending Application_Closing Pas d’equivalent IsApplicationInstancePreserved PreviousExecutionState
  • 38.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App • Contexte de l’application conservée • Fermeture de l’application par le gestionnaire de tâches • L’état « terminated » ne conserve aucun état (ni stack de navigation ni dictionnaire global) • ATTENTION au bouton back
  • 39.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Pros Cons Restaurer l’état après un « resuming » quand T < ? min sinon réinitialiser app NE PAS FERMER l’application pour reproduire le comportement de 8.0 Sauvegarder l’état de l’app dans le suspending Ne pas restaurer l’état si l’application a été fermée par l’utilisateur Sauvegarder plusieurs historiques de navigation quand plusieurs points d’entrée disponibles
  • 40.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Nouveau template de projet: Blank App n’inclut pas la gestion de la touche back Hub App, Pivot App l’inclut dans la classe /Common/NavigationHelper Ce qui cause un retour vers la page précédente Si vous avez besoin de surcharger ceci, remplacez avec votre code pour une gestion custom de la navigation Gestion du bouton back
  • 41.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App
  • 42.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Cache mode NavigationCacheMode.Disabled NavigationCacheMode.Enabled NavigationCacheMode.Required
  • 43.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Cache mode exemple Page 1 Page 2 Page 3 new new ?
  • 44.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Task TimeTrigger PUSH Notification LocationTrigger PushNotificationTrigger MaintenanceTrigger InternetAvailable NetworkStateChange TimeZoneChange
  • 45.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Local Emplacement principal Peut être sauvegardé sur OneDrive Roaming Données partagées entre devices Limité à 100kb Temp Données temporaires Peut être vidé lorsque la mémoire du telephone est pleine Device B WP 8.1 – PFN 12345 Roaming Local Local Cache Temp Device A WP 8.1 App Roaming Local Local Cache Temp Backup [Device A]
  • 46.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App <TextBlock Text=""{Binding LocalizedResources.Farewell, Source={StaticResource LocalizedStrings}}" /> Utilisation depuis le code: Utilisation en XAML: var message = AppResources.Farewell;
  • 47.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App <TextBlock x:Uid="Greeting" Text="?" /> Utilisation depuis le code: Utilisation en XAML: var loader = new Windows.ApplicationModel.Resources.ResourceLoader(); var string = loader.GetString('Farewell');
  • 48.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Silverlight Universal Apps Resx Resw Dictionary<string,object> Dictionary<string,string> Création de propriétés Accès via clés Binding complexe et coûteux Résolution automatique Le Xaml pilote la localisation Le resw pilote la localisation
  • 49.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App  Les projets Universal apps ne supporte pas resx…  Mais !
  • 50.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App  Renommer vos *.resx en *.resw  Utiliser une portable library
  • 51.
    tech.days 2015#mstechdaysWindows Phone: Migrez de Silverlight vers Universal App Démo !
  • 52.