public static async Task <object> ShowSelectChoiceAsync(string title, IList choices, string choiceBindingName = null, string confirmingText = "Ok", string dismissiveText = "Cancel", MaterialConfirmationDialogConfiguration configuration = null)
        {
            var radioButtonGroup = new MaterialRadioButtonGroup
            {
                HorizontalSpacing  = 20,
                ChoicesBindingName = choiceBindingName
            };

            radioButtonGroup.Choices = choices ?? throw new ArgumentNullException(nameof(choices));

            var dialog = new MaterialConfirmationDialog(configuration)
            {
                InputTaskCompletionSource = new TaskCompletionSource <object>(),
                _controlGroup             = radioButtonGroup
            };

            if (dialog._preferredConfig != null)
            {
                dialog._controlGroup.SelectedColor   = dialog._preferredConfig.ControlSelectedColor;
                dialog._controlGroup.UnselectedColor = dialog._preferredConfig.ControlUnselectedColor;
                dialog._controlGroup.FontFamily      = dialog._preferredConfig.TextFontFamily;
                dialog._controlGroup.TextColor       = dialog._preferredConfig.TextColor;
            }

            dialog._controlGroup.ShouldShowScrollbar = true;
            dialog.DialogTitle.Text         = !string.IsNullOrEmpty(title) ? title : throw new ArgumentNullException(nameof(title));
            dialog.PositiveButton.IsEnabled = false;
            dialog.PositiveButton.Text      = confirmingText.ToUpper();
            dialog.NegativeButton.Text      = dismissiveText.ToUpper();
            dialog.container.Content        = dialog._controlGroup;
            await dialog.ShowAsync();

            return(await dialog.InputTaskCompletionSource.Task);
        }
Exemple #2
0
        public static async Task <object> ShowSelectChoicesAsync(string title, IList <string> choices, MaterialConfirmationDialogConfiguration configuration)
        {
            var dialog = new MaterialConfirmationDialog(configuration)
            {
                InputTaskCompletionSource = new TaskCompletionSource <object>()
            };

            dialog._checkboxGroup = new MaterialCheckboxGroup
            {
                HorizontalSpacing = 20,
                Choices           = choices ?? throw new ArgumentNullException(nameof(choices))
            };

            if (dialog._preferredConfig != null)
            {
                dialog._checkboxGroup.SelectedColor   = dialog._preferredConfig.ControlSelectedColor;
                dialog._checkboxGroup.UnselectedColor = dialog._preferredConfig.ControlUnselectedColor;
                dialog._checkboxGroup.FontFamily      = dialog._preferredConfig.TextFontFamily;
                dialog._checkboxGroup.TextColor       = dialog._preferredConfig.TextColor;
            }

            dialog._checkboxGroup.ShouldShowScrollbar = true;
            dialog._isMultiChoice    = true;
            dialog.DialogTitle.Text  = !string.IsNullOrEmpty(title) ? title : throw new ArgumentNullException(nameof(title));
            dialog.container.Content = dialog._checkboxGroup;
            await dialog.ShowAsync();

            return(await dialog.InputTaskCompletionSource.Task);
        }
Exemple #3
0
        public static async Task <object> ShowSelectChoiceAsync(string title, IList <string> choices, int selectedIndex, MaterialConfirmationDialogConfiguration configuration)
        {
            var dialog = new MaterialConfirmationDialog(configuration)
            {
                InputTaskCompletionSource = new TaskCompletionSource <object>()
            };

            dialog._radioButtonGroup = new MaterialRadioButtonGroup
            {
                HorizontalSpacing                                   = 20,
                Choices                                             = choices ?? throw new ArgumentNullException(nameof(choices)),
                                                      SelectedIndex = selectedIndex
            };

            if (dialog._preferredConfig != null)
            {
                dialog._radioButtonGroup.SelectedColor   = dialog._preferredConfig.ControlSelectedColor;
                dialog._radioButtonGroup.UnselectedColor = dialog._preferredConfig.ControlUnselectedColor;
                dialog._radioButtonGroup.FontFamily      = dialog._preferredConfig.TextFontFamily;
                dialog._radioButtonGroup.TextColor       = dialog._preferredConfig.TextColor;
            }

            dialog.DialogTitle.Text         = !string.IsNullOrEmpty(title) ? title : throw new ArgumentNullException(nameof(title));
            dialog.container.Content        = dialog._radioButtonGroup;
            dialog.PositiveButton.IsEnabled = true;
            await dialog.ShowAsync();

            return(await dialog.InputTaskCompletionSource.Task);
        }
Exemple #4
0
 public async Task <int> SelectChoiceAsync(
     string title,
     IList <string> choices,
     string confirmingText = "Ok",
     string dismissiveText = "Cancel",
     MaterialConfirmationDialogConfiguration configuration = null)
 {
     return((int)await MaterialConfirmationDialog.ShowSelectChoiceAsync(title, choices, confirmingText, dismissiveText, configuration));
 }
 public async Task <int[]> SelectChoicesAsync(
     string title,
     IList choices,
     IList <int> selectedIndices,
     string choiceBindingName = null,
     string confirmingText    = "Ok",
     string dismissiveText    = "Cancel",
     MaterialConfirmationDialogConfiguration configuration = null)
 {
     return((int[])await MaterialConfirmationDialog.ShowSelectChoicesAsync(title, choices, selectedIndices, choiceBindingName, confirmingText, dismissiveText, configuration));
 }
 public async Task <int> SelectChoiceAsync(
     string title,
     IList <string> choices,
     int selectedIndex,
     string confirmingText = "Ok",
     string dismissiveText = "Cancel",
     MaterialConfirmationDialogConfiguration configuration = null,
     bool closeOnSelection = false)
 {
     return((int)await MaterialConfirmationDialog.ShowSelectChoiceAsync(title, choices, selectedIndex, confirmingText, dismissiveText, configuration, closeOnSelection));
 }
        public async Task <int?> SelectChoiceAsync(
            string title,
            IList choices,
            string choiceBindingName = null,
            string confirmingText    = "Ok",
            string dismissiveText    = "Cancel",
            MaterialConfirmationDialogConfiguration configuration = null)
        {
            var result = await MaterialConfirmationDialog.ShowSelectChoiceAsync(title, choices, choiceBindingName, confirmingText, dismissiveText, configuration);

            if (result != null)
            {
                int[] choice = (int[])result;
                return(choice[0]);
            }
            else
            {
                return(null);
            }
        }
Exemple #8
0
 /// <summary>
 /// Shows a confirmation dialog that allows the user to select any of the listed choices. Returns the indices of the selected choices. If none was selected, returns an empty array.
 /// </summary>
 /// <param name="title">The title of the confirmation dialog. This parameter must not be null or empty.</param>
 /// <param name="choices">The list of choices the user will choose from.</param>
 /// <param name="selectedIndices">The currently selected indices.</param>
 /// <param name="configuration">The style of the confirmation dialog.</param>
 /// <exception cref="ArgumentNullException" />
 /// <exception cref="IndexOutOfRangeException" />
 public async Task <int[]> SelectChoicesAsync(string title, IList <string> choices, List <int> selectedIndices, MaterialConfirmationDialogConfiguration configuration = null)
 {
     return((int[])await MaterialConfirmationDialog.ShowSelectChoicesAsync(title, choices, selectedIndices, configuration));
 }