コード例 #1
0
ファイル: Dialog.cs プロジェクト: chaami/PowerArgs
        /// <summary>
        /// Shows a dialog with a message and a set of options for the user to choose from
        /// </summary>
        /// <param name="options">the options used to configure the dialog</param>
        /// <returns>a promise that resolves with the selected option or null if the dialog was cancelled. The promise never rejects.</returns>
        public static Promise <DialogOption> ShowMessage(DialogButtonOptions options)
        {
            var d = Deferred <DialogOption> .Create();

            var rawPromise = new Dialog(options).Show();

            rawPromise.Then(() => d.Resolve(options.SelectedOption));
            return(d.Promise);
        }
コード例 #2
0
        /// <summary>
        /// Shows a dialog with a message and a set of options for the user to choose from
        /// </summary>
        /// <param name="options">the options used to configure the dialog</param>
        /// <returns>a Task that resolves with the selected option or null if the dialog was cancelled. The Task never rejects.</returns>
        public static Task <DialogOption> ShowMessage(DialogButtonOptions options)
        {
            var d       = new TaskCompletionSource <DialogOption>();
            var dialog  = new Dialog(options);
            var rawTask = dialog.Show();

            rawTask.Then(() => d.SetResult(dialog.WasEscapeUsedToClose ? null : options.SelectedOption));
            return(d.Task);
        }