/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { DebugSettings.EnableFrameRateCounter = true; } #endif var rootFrame = Window.Current.Content as Frame; await ContexteAppli.Init(false); //chargement de la page d'acceuil rootFrame = new Frame(); Window.Current.Content = rootFrame; rootFrame.NavigationFailed += OnNavigationFailed; rootFrame.Navigated += OnNavigated; SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = rootFrame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; var paramBusiness = new ParamBusiness(); await paramBusiness.Initialization; if (await paramBusiness.NeedUpdate()) { rootFrame.Navigate(typeof(UpdateVersion)); Window.Current.Activate(); } else { OpenAppli(); } }
/// <summary> /// Méthode de lancement de l'appel de cortana /// </summary> /// <param name="taskInstance"></param> public async void Run(IBackgroundTaskInstance taskInstance) { //lancement _serviceDeferral = taskInstance.GetDeferral(); taskInstance.Canceled += (sender, reason) => _serviceDeferral?.Complete(); var triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails; _voiceCommandServiceConnection = VoiceCommandServiceConnection.FromAppServiceTriggerDetails(triggerDetails); _voiceCommandServiceConnection.VoiceCommandCompleted += (sender, args) => _serviceDeferral?.Complete(); var voicecommand = await _voiceCommandServiceConnection.GetVoiceCommandAsync(); await ContexteAppli.Init(true); var filmBusiness = new FilmBusiness(); await filmBusiness.Initialization; var movieDbBusiness = new MovieDbBusiness(); var tiles = new List <VoiceCommandContentTile>(); switch (voicecommand.CommandName) { case "showVoirFilm": var listeFilmVoir = await filmBusiness.GetFilmSuggestionVoir(); tiles.AddRange(listeFilmVoir.Select(film => new VoiceCommandContentTile { ContentTileType = VoiceCommandContentTileType.TitleOnly, Title = film.Titre, AppContext = film })); break; case "showFilm": var listeFilm = await filmBusiness.GetFilmSuggestionAleatoire(); tiles.AddRange(listeFilm.Select(film => new VoiceCommandContentTile { ContentTileType = VoiceCommandContentTileType.TitleOnly, Title = film.Titre, AppContext = film })); break; case "showFilmFav": var listeFilmFav = await filmBusiness.GetFilmSuggestionFavoris(); tiles.AddRange(listeFilmFav.Select(film => new VoiceCommandContentTile { ContentTileType = VoiceCommandContentTileType.TitleOnly, Title = film.Titre, AppContext = film })); break; case "showAcheter": var listeFilmPosseder = await filmBusiness.GetFilmSuggestionPosseder(); tiles.AddRange(listeFilmPosseder.Select(film => new VoiceCommandContentTile { ContentTileType = VoiceCommandContentTileType.TitleOnly, Title = film.Titre, AppContext = film })); break; case "showFilmMoment": var listeFilmMoment = (await movieDbBusiness.GetPopularMovie()).Take(9); tiles.AddRange(listeFilmMoment.Select(film => new VoiceCommandContentTile { ContentTileType = VoiceCommandContentTileType.TitleOnly, Title = film.title, AppContext = film })); break; case "showSerieMoment": var listeserieMoment = (await movieDbBusiness.GetPopularSerie()).Take(9); tiles.AddRange(listeserieMoment.Select(film => new VoiceCommandContentTile { ContentTileType = VoiceCommandContentTileType.TitleOnly, Title = film.name, AppContext = film })); break; } var userPrompt = new VoiceCommandUserMessage(); if (tiles.Count > 0) { userPrompt.DisplayMessage = GetString("filmTrouve"); userPrompt.SpokenMessage = GetString("filmTrouve"); } else { userPrompt.DisplayMessage = GetString("aucunResultat"); userPrompt.SpokenMessage = GetString("aucunResultat"); } if (tiles.Count == 0) { var response = VoiceCommandResponse.CreateResponse(userPrompt); await _voiceCommandServiceConnection.ReportSuccessAsync(response); } else { var response = VoiceCommandResponse.CreateResponse(userPrompt, tiles); await _voiceCommandServiceConnection.ReportSuccessAsync(response); } }