Example #1
0
        public async Task <DialogClosedEventArgs> ShowAsync(string title, string content, IEnumerable <string> buttons)
        {
            try
            {
                var commands = buttons.Select(b => b.ToString()).ToList();

                var dialog = new ConcurrentMessageDialog(content, title);
                foreach (var command in commands)
                {
                    dialog.Commands.Add(new UICommand(command));
                }

                IUICommand uiResult = await dialog.ShowAsync();

                if (uiResult != null && !string.IsNullOrWhiteSpace(uiResult.Label))
                {
                    return(new DialogClosedEventArgs(commands.IndexOf(uiResult.Label)));
                }
                else
                {
                    return(new DialogClosedEventArgs(-1));
                }
            }
            catch (Exception e)
            {
                TrackingManagerHelper.Exception(e, string.Format("MessageBoxService.ShowAsync with buttons title: {0} content {1}", title, content));
                return(new DialogClosedEventArgs(-1));
            }
        }
Example #2
0
        public async Task <DialogResult> ShowAsync(string title, string content, DialogButton button = DialogButton.OK)
        {
            try
            {
                var dialog = new ConcurrentMessageDialog(content, title);

                switch (button)
                {
                case DialogButton.OK:
                    dialog.Commands.Add(new UICommand(StringResources.General_LabelOk));
                    break;

                case DialogButton.OKCancel:
                    dialog.Commands.Add(new UICommand(StringResources.General_LabelOk));
                    dialog.Commands.Add(new UICommand(StringResources.General_LabelCancel));
                    break;

                case DialogButton.YesNo:
                    dialog.Commands.Add(new UICommand(StringResources.General_LabelYes));
                    dialog.Commands.Add(new UICommand(StringResources.General_LabelNo));
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(button));
                }

                IUICommand result = await dialog.ShowAsync();

                if (result == null)
                {
                    return(DialogResult.Cancel);
                }
                else if (result.Label == StringResources.General_LabelOk)
                {
                    return(DialogResult.OK);
                }
                else if (result.Label == StringResources.General_LabelCancel)
                {
                    return(DialogResult.Cancel);
                }
                else if (result.Label == StringResources.General_LabelYes)
                {
                    return(DialogResult.Yes);
                }
            }
            catch (Exception e)
            {
                TrackingManagerHelper.Exception(e, string.Format("MessageBoxService.ShowAsync title: {0} content: {1}", title, content));
            }

            return(DialogResult.No);
        }