示例#1
0
        /// <summary>
        /// Resumes after native location dialog returns.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="result">The result.</param>
        /// <returns>The asynchronous task.</returns>
        internal override async Task ResumeAfterChildDialogInternalAsync(IDialogContext context, IAwaitable <LocationDialogResponse> result)
        {
            this.selectedLocation = (await result).Location;

            await this.TryReverseGeocodeAddress(this.selectedLocation);

            if (!this.requiredDialogCalled && this.requiredFields != LocationRequiredFields.None)
            {
                this.requiredDialogCalled = true;
                var requiredDialog = new LocationRequiredFieldsDialog(this.selectedLocation, this.requiredFields, this.ResourceManager);
                context.Call(requiredDialog, this.ResumeAfterChildDialogAsync);
            }
            else
            {
                if (this.options.HasFlag(LocationOptions.SkipFinalConfirmation))
                {
                    context.Done(CreatePlace(this.selectedLocation));
                    return;
                }

                var confirmationAsk = string.Format(
                    this.ResourceManager.ConfirmationAsk,
                    this.selectedLocation.GetFormattedAddress(this.ResourceManager.AddressSeparator));

                PromptDialog.Confirm(
                    context,
                    async(dialogContext, answer) =>
                {
                    if (await answer)
                    {
                        dialogContext.Done(CreatePlace(this.selectedLocation));
                    }
                    else
                    {
                        await dialogContext.PostAsync(this.ResourceManager.ResetPrompt);
                        await this.StartAsync(dialogContext);
                    }
                },
                    confirmationAsk,
                    retry: this.ResourceManager.ConfirmationInvalidResponse,
                    promptStyle: PromptStyle.None);
            }
        }
示例#2
0
        /// <summary>
        /// Resumes after native location dialog returns.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="result">The result.</param>
        /// <returns>The asynchronous task.</returns>
        internal override async Task ResumeAfterChildDialogInternalAsync(IDialogContext context, IAwaitable <LocationDialogResponse> result)
        {
            this.selectedLocation = (await result).Location;

            await this.TryReverseGeocodeAddress(this.selectedLocation);

            if (!this.requiredDialogCalled && this.requiredFields != LocationRequiredFields.None)
            {
                this.requiredDialogCalled = true;
                var requiredDialog = new LocationRequiredFieldsDialog(this.selectedLocation, this.requiredFields, this.ResourceManager);
                context.Call(requiredDialog, this.ResumeAfterChildDialogAsync);
            }
            else
            {
                if (this.announceDirections)
                {
                    await AnnounceDirections(context, this.addressDestination);
                }

                context.Done(CreatePlace(this.selectedLocation));
            }
        }