Exemple #1
0
        private async Task SendCompletionMessageForFilter(string filter)
        {
            var loadingSearchByType = string.Format(_cortanaResourceMap.GetValue("Cortana_Loading", _cortanaContext).ValueAsString, filter);

            await ShowProgressScreen(loadingSearchByType);

            var provider = new CatalogProvider();
            var items    = await provider.GetItemsByVoiceCommandAsync(filter);

            var userMessage = new VoiceCommandUserMessage();

            var ListContentTiles = new List <VoiceCommandContentTile>();

            if (items == null || !items.Any())
            {
                var foundNoSearchByType = string.Format(_cortanaResourceMap.GetValue("Cortana_foundNoSearchByType", _cortanaContext).ValueAsString, filter);
                userMessage.DisplayMessage = foundNoSearchByType;
                userMessage.SpokenMessage  = foundNoSearchByType;
            }
            else
            {
                int cont = 1;

                foreach (var item in items.Take(10))
                {
                    var typeTile = new VoiceCommandContentTile();
                    typeTile.ContentTileType = VoiceCommandContentTileType.TitleWithText;

                    typeTile.AppLaunchArgument = item.Id.ToString();
                    typeTile.Title             = item.Name;
                    typeTile.TextLine1         = $"{item.Price.ToString()}$";

                    ListContentTiles.Add(typeTile);
                    cont++;
                }
            }

            var message = WaitingForResult(filter, items.Count());

            userMessage.DisplayMessage = message;
            userMessage.SpokenMessage  = message;
            var response = VoiceCommandResponse.CreateResponse(userMessage, ListContentTiles);
            await _voiceServiceConnection.ReportSuccessAsync(response);
        }