Esempio n. 1
0
        private string ShowSyncInternalAssumingUiThread(string[] buttons, string title, string message, DoNotShowAgainOptions dontShowAgainFlag, string doNotShowAgainCustomText)
        {
            DialogResult result;

            using (MessageDialog messageDialog = new MessageDialog(_parent, doNotShowAgainCustomText))
            {
                switch (buttons.Length)
                {
                case 1:
                    messageDialog.InitializeButtonTexts(buttons[0], null, null);
                    messageDialog.HideButton1();
                    messageDialog.HideButton2();
                    break;

                case 2:
                    messageDialog.InitializeButtonTexts(buttons[0], buttons[1], null);
                    messageDialog.HideButton2();
                    break;

                case 3:
                    messageDialog.InitializeButtonTexts(buttons[0], buttons[1], buttons[2]);
                    break;

                default:
                    throw new NotSupportedException("Can't display alert dialog(s) with more than 3 buttons!");
                }

                if (dontShowAgainFlag == DoNotShowAgainOptions.None)
                {
                    messageDialog.HideDontShowAgain();
                }

                messageDialog.Text         = title;
                messageDialog.Message.Text = message;

                result = messageDialog.ShowDialog(_parent);

                if (dontShowAgainFlag != DoNotShowAgainOptions.None && messageDialog.dontShowThisAgain.Checked)
                {
                    New <UserSettings>().DoNotShowAgain = New <UserSettings>().DoNotShowAgain | dontShowAgainFlag;
                }
            }

            switch (result)
            {
            case DialogResult.OK:
                return(buttons[0]);

            case DialogResult.Cancel:
                return(buttons.Length > 1 ? buttons[1] : Texts.ButtonCancelText);

            case DialogResult.Abort:
                return(buttons[2]);

            default:
                throw new InvalidOperationException($"Unexpected result from dialog: {result}");
            }
        }