private async Task UpdateTilesAsync() { var todaysNames = await NamedayRepository.GetTodaysNamesAsStringAsync(); if (todaysNames == null) { return; } var template = @"<tile> <visual version=""4""> <binding template=""TileMedium""> <text hint-wrap=""true"">{0}</text> </binding> <binding template=""TileWide""> <text hint-wrap=""true"">{0}</text> </binding> </visual> </tile>"; var content = string.Format(template, todaysNames); var doc = new XmlDocument(); doc.LoadXml(content); TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(doc)); }
private async Task SendNotificationAsync() { var todaysNames = await NamedayRepository.GetTodaysNamesAsStringAsync(); if (todaysNames == null) { return; } ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier(); XmlDocument content = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); var texts = content.GetElementsByTagName("text"); texts[0].InnerText = todaysNames.Contains(",") ? "Les noms du jour sont" : "Le nom du jour est"; texts[1].InnerText = todaysNames; notifier.Show(new ToastNotification(content)); }
private static async Task HandleReadNamedaysCommandAsync(VoiceCommandServiceConnection connection) { var userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Fetching today's namedays for you"; userMessage.SpokenMessage = "Fetching today's namedays for you"; var response = VoiceCommandResponse.CreateResponse(userMessage); await connection.ReportProgressAsync(response); var today = DateTime.Now.Date; var namedays = await NamedayRepository.GetAllNamedaysAsync(); var todaysNameday = namedays.Find(e => e.Day == today.Day && e.Month == today.Month); var namedaysAsString = todaysNameday.NamesAsString; if (todaysNameday.Names.Count() == 1) { userMessage.SpokenMessage = userMessage.DisplayMessage = $"It is { namedaysAsString}'s nameday today"; response = VoiceCommandResponse.CreateResponse(userMessage); } else { userMessage.SpokenMessage = $"Today's namedays are: {namedaysAsString}"; userMessage.DisplayMessage = "Here are today's namedays:"; var tile = new VoiceCommandContentTile(); tile.ContentTileType = VoiceCommandContentTileType.TitleOnly; tile.Title = namedaysAsString; response = VoiceCommandResponse.CreateResponse(userMessage, new List <VoiceCommandContentTile> { tile }); } await connection.ReportSuccessAsync(response); }
private static async Task HandleReadNamedaysCommandAsync(VoiceCommandServiceConnection connection) { var userMessage = new VoiceCommandUserMessage(); userMessage.DisplayMessage = "Je récupères les noms du jour pour vous"; userMessage.SpokenMessage = "Je récupères les noms du jour pour vous"; var response = VoiceCommandResponse.CreateResponse(userMessage); await connection.ReportProgressAsync(response); var today = DateTime.Now.Date; var namedays = await NamedayRepository.GetAllNamedaysAsync(); var todaysNamedays = namedays.Find(e => e.Day == today.Day && e.Month == today.Month); var namedaysAsString = todaysNamedays.NamesAsString; if (todaysNamedays.Names.Count() == 1) { userMessage.SpokenMessage = userMessage.DisplayMessage = $"Le nom du jour est {namedaysAsString}"; response = VoiceCommandResponse.CreateResponse(userMessage); } else { userMessage.SpokenMessage = $"Les noms du jour sont {namedaysAsString}"; userMessage.DisplayMessage = "Voici les noms du jour : "; var tile = new VoiceCommandContentTile(); tile.ContentTileType = VoiceCommandContentTileType.TitleOnly; tile.Title = namedaysAsString; response = VoiceCommandResponse.CreateResponse(userMessage, new List <VoiceCommandContentTile> { tile }); } await connection.ReportSuccessAsync(response); }