Ejemplo n.º 1
0
//		public string DefaultOkaySymbol = "Ok";// '\u2714' + "";
//		public string DefaultCancelSymbol = "Cancel";// '\u2718' + "";

        public override async Task <DialogResult> ShowDialogAsync(
            object content,
            string caption,
            DialogButton dialogButton,
            DialogImage dialogImage           = DialogImage.None,
            DialogController dialogController = null)
        {
            List <string> buttons = new List <string>();

            if (dialogButton == DialogButton.OK)
            {
                buttons.Add(Strings.Okay());
            }
            else if (dialogButton == DialogButton.OKCancel)
            {
                buttons.Add(Strings.Cancel());
                buttons.Add(Strings.Okay());
            }
            else if (dialogButton == DialogButton.YesNo)
            {
                buttons.Add(Strings.No());
                buttons.Add(Strings.Yes());
            }
            else if (dialogButton == DialogButton.YesNoCancel)
            {
                buttons.Add(Strings.No());
                buttons.Add(Strings.Cancel());
                buttons.Add(Strings.Yes());
            }

            var selectedIndex = await ShowDialogAsync(
                content,
                buttons,
                caption,
                0,
                dialogController);

            if (selectedIndex < 0)
            {
                return(DialogResult.Cancel);
            }

            switch (selectedIndex)
            {
            case 0:
                switch (dialogButton)
                {
                case DialogButton.OK:
                    return(DialogResult.OK);

                case DialogButton.OKCancel:
                    return(DialogResult.Cancel);

                case DialogButton.YesNo:
                    return(DialogResult.No);

                case DialogButton.YesNoCancel:
                    return(DialogResult.No);
                }
                break;

            case 1:
                switch (dialogButton)
                {
                case DialogButton.OKCancel:
                    return(DialogResult.OK);

                case DialogButton.YesNo:
                    return(DialogResult.Yes);

                case DialogButton.YesNoCancel:
                    return(DialogResult.Cancel);
                }
                break;

            case 2:
                switch (dialogButton)
                {
                case DialogButton.YesNoCancel:
                    return(DialogResult.Yes);
                }
                break;
            }

            throw new IndexOutOfRangeException(
                      "Index returned from dialog is out of range. "
                      + selectedIndex);
        }