示例#1
0
        public Alert(string message, string title, AlertButtons buttons)
            : base(DroidFactory.MainActivity)
        {
            SetTitle(Title     = title);
            SetMessage(Message = message);
            Buttons            = buttons;
            DismissEvent      += Alert_DismissEvent;

            switch (buttons)
            {
            case AlertButtons.OKCancel:
                SetButton(DroidFactory.Instance.GetResourceString("OK"), Handler);
                SetButton2(DroidFactory.Instance.GetResourceString("Cancel"), Handler);
                break;

            case AlertButtons.YesNo:
                SetButton(DroidFactory.Instance.GetResourceString("Yes"), Handler);
                SetButton2(DroidFactory.Instance.GetResourceString("No"), Handler);
                break;

            default:
                SetButton(DroidFactory.Instance.GetResourceString("OK"), Handler);
                break;
            }
        }
示例#2
0
文件: Alert.cs 项目: Zebra/iFactr-iOS
 public Alert(string message, string title, AlertButtons buttons)
     : base()
 {
     Message = message;
     Title   = title;
     Buttons = buttons;
 }
示例#3
0
        protected override AlertResult ShowInternal(IComponent owner, string text, string caption,
                                                    AlertButtons alertButtons, AlertLevel alertLevel, AlertDefaultButton defaultButton, bool showInTaskbar)
        {
            Trace.TraceInformation("~~~ {0}", text);

            MessageBoxButtons       type       = GetButtonsForButtons(alertButtons);
            MessageBoxIcon          icon       = GetIconForAlertLevel(alertLevel);
            MessageBoxDefaultButton defaultBtn = GetDefaultButtonForDefaultButton(defaultButton);

            DialogResult result = DialogResult.Cancel;

            ProgressUtils.InvokeOnUIThread(() => result = MessageBox.Show((IWin32Window)owner, text, caption, type, icon, defaultBtn,
                                                                          showInTaskbar ? MessageBoxOptions.DefaultDesktopOnly : 0));
            switch (result)
            {
            case DialogResult.OK:
            case DialogResult.Yes:
            case DialogResult.Retry:
                return(AlertResult.Positive);

            case DialogResult.No:
            case DialogResult.Abort:
                return(AlertResult.Negative);

            default:                     // DialogResult.Cancel
                return(AlertResult.Cancel);
            }
        }
示例#4
0
        protected override AlertResult ShowInternal(IComponent owner, string text, string caption,
                                                    AlertButtons alertButtons, AlertLevel alertLevel, AlertDefaultButton defaultButton, bool showInTaskbar)
        {
            Logger.WriteEvent($"Paratext Alert: {text}");

            MessageBoxButtons       type       = GetButtonsForButtons(alertButtons);
            MessageBoxIcon          icon       = GetIconForAlertLevel(alertLevel);
            MessageBoxDefaultButton defaultBtn = GetDefaultButtonForDefaultButton(defaultButton);

            DialogResult result = MessageBox.Show((IWin32Window)owner, text, caption, type, icon, defaultBtn,
                                                  showInTaskbar ? MessageBoxOptions.DefaultDesktopOnly : 0);

            switch (result)
            {
            case DialogResult.OK:
            case DialogResult.Yes:
            case DialogResult.Retry:
                return(AlertResult.Positive);

            case DialogResult.No:
            case DialogResult.Abort:
                return(AlertResult.Negative);

            default:     // DialogResult.Cancel
                return(AlertResult.Cancel);
            }
        }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="iFactr.UI.Alert"/> class.
 /// </summary>
 /// <param name="message">The message to display with the alert.</param>
 /// <param name="title">The title of the alert.</param>
 /// <param name="buttons">The button combination for the alert.</param>
 public Alert(string message, string title, AlertButtons buttons)
 {
     nativeAlert = MXContainer.Resolve <IAlert>(null, message, title, buttons);
     if (nativeAlert == null)
     {
         throw new InvalidOperationException("No native object was found for the current instance.");
     }
 }
示例#6
0
 internal static DialogResult Alert(string title, string message, string messagesTitle, string exceptionDetail,
                                    AlertType alertType, AlertButtons alertButtons)
 {
     using (var alertForm = AlertFormFactory.CreateAlertForm(null, title, message, messagesTitle,
                                                             exceptionDetail, string.Empty, alertType, alertButtons))
     {
         alertForm.ShowDialog(HelperMethods.GetCurrentlyActiveForm());
         return(alertForm.DialogResult);
     }
 }
 internal static DialogResult Alert(string title, string message,
                                    AlertType alertType,
                                    AlertButtons alertButtons)
 {
     using (var alertForm = AlertFormFactory.CreateAlertForm(title, message,
                                                             alertType, alertButtons))
     {
         alertForm.ShowDialog();
         return(alertForm.DialogResult);
     }
 }
示例#8
0
        /// <summary>
        /// Handles displaying relevant messages to the user from the inputs
        /// </summary>
        /// <param name="operationTitle">The title of the message box</param>
        /// <param name="message">The message text</param>
        /// <param name="alertButtons">Alert buttons</param>
        /// <param name="alertType">Alert type</param>
        public static DialogResult Alert(string operationTitle, string message, AlertButtons alertButtons,
                                         AlertType alertType)
        {
            if (string.IsNullOrWhiteSpace(operationTitle))
            {
                operationTitle = "Operation";
            }

            if (message == null)
            {
                message = string.Empty;
            }

            return(AlertDisplayHandler.Alert(HelperMethods.GetCurrentlyActiveForm(), operationTitle, message, string.Empty, string.Empty, alertType,
                                             alertButtons));
        }
示例#9
0
        /// <summary>
        /// Handles displaying relevent messages to the user from the inputs
        /// </summary>
        /// <param name="operationTitle">The title of the message box</param>
        /// <param name="message">The message text</param>
        /// <param name="alertButtons"></param>
        /// <param name="alertType">The type of message box</param>
        public static DialogResult Alert(string operationTitle, string message, AlertButtons alertButtons,
                                         AlertType alertType)
        {
            if (string.IsNullOrWhiteSpace(operationTitle))
            {
                operationTitle = "Operation";
            }

            if (message == null)
            {
                message = string.Empty;
            }

            return(AlertDisplayHandler.Alert(operationTitle, message, alertType,
                                             alertButtons));
        }
示例#10
0
        protected async Task <bool?> Alert(string title, string message, AlertButtons buttons = AlertButtons.Ok)
        {
            ModalParameters parameters = new ModalParameters();

            parameters.Add("Buttons", buttons);
            parameters.Add("Message", message);
            var alert  = Popup.Show <AlertPopup>(title, parameters);
            var result = await alert.Result;

            if (result.Data != null)
            {
                bool alertResult = (bool)result.Data;
                return(alertResult);
            }
            return(null);
        }
示例#11
0
        protected static MessageBoxButtons GetButtonsForButtons(AlertButtons alertButtons)
        {
            switch (alertButtons)
            {
            case AlertButtons.Ok: return(MessageBoxButtons.OK);

            case AlertButtons.OkCancel: return(MessageBoxButtons.OKCancel);

            case AlertButtons.YesNo: return(MessageBoxButtons.YesNo);

            case AlertButtons.YesNoCancel: return(MessageBoxButtons.YesNoCancel);

            case AlertButtons.RetryCancel: return(MessageBoxButtons.RetryCancel);

            default: throw new ArgumentException("alertButtons unknown: " + alertButtons);
            }
        }
示例#12
0
文件: Alert.cs 项目: Zebra/iFactr-iOS
 public AlertLegacy(string message, string title, AlertButtons buttons)
     : base(title, message, null, TouchFactory.Instance.GetResourceString("OK"),
            buttons == AlertButtons.OKCancel ? new[] { TouchFactory.Instance.GetResourceString("Cancel") } : null)
 {
     base.Dismissed += (sender, e) =>
     {
         var handler = Dismissed;
         if (handler != null)
         {
             handler(this, new AlertResultEventArgs((AlertResult)(int)e.ButtonIndex));
         }
         else if (e.ButtonIndex == (int)AlertResult.OK)
         {
             iApp.Navigate(OKLink);
         }
         else if (e.ButtonIndex == (int)AlertResult.Cancel)
         {
             iApp.Navigate(CancelLink);
         }
     };
 }
示例#13
0
        /// <summary>
        /// Handles displaying relevant messages to the user from the inputs
        /// </summary>
        /// <param name="parentControl"></param>
        /// <param name="operationTitle">The title of the message box</param>
        /// <param name="messages">The message list</param>
        /// <param name="alertButtons">Alert buttons</param>
        /// <param name="alertType">Alert type</param>
        public static DialogResult Alert(Control parentControl, string operationTitle, List <string> messages, AlertButtons alertButtons,
                                         AlertType alertType)
        {
            if (string.IsNullOrWhiteSpace(operationTitle))
            {
                operationTitle = "Operation";
            }

            if (messages == null)
            {
                messages = new List <string>();
            }

            return(AlertDisplayHandler.Alert(HelperMethods.GetCurrentlyActiveForm(parentControl), operationTitle, messages, string.Empty, string.Empty,
                                             alertType, alertButtons));
        }
 protected override AlertResult ShowInternal(IComponent owner, string text, string caption,
                                             AlertButtons alertButtons, AlertLevel alertLevel, AlertDefaultButton defaultButton, bool showInTaskbar)
 {
     _logger.LogInformation($"Alert: {text} : {caption}");
     return(AlertResult.Positive);
 }
示例#15
0
 internal static DialogResult AlertRtf(Control parentControl, string title, List <string> messages,
                                       string messagesTitle, string exceptionDetail, string rtf, AlertType alertType, AlertButtons alertButtons)
 {
     using (var alertForm = AlertFormFactory.CreateAlertForm(parentControl, title, SingleMessage(messages), messagesTitle,
                                                             exceptionDetail, rtf, alertType, alertButtons))
     {
         alertForm.ShowDialog(HelperMethods.GetCurrentlyActiveForm(parentControl));
         return(alertForm.DialogResult);
     }
 }
示例#16
0
        /// <summary>
        /// Handles displaying relevent messages to the user from the inputs
        /// </summary>
        /// <param name="operationTitle">The title of the message box</param>
        /// <param name="messages">The message list</param>
        /// <param name="alertButtons"></param>
        /// <param name="alertType">The type of message box</param>
        public static DialogResult Alert(string operationTitle, List <string> messages, AlertButtons alertButtons,
                                         AlertType alertType)
        {
            if (string.IsNullOrWhiteSpace(operationTitle))
            {
                operationTitle = "Operation";
            }

            if (messages == null)
            {
                messages = new List <string>();
            }

            return(AlertDisplayHandler.Alert(operationTitle, SingleMessage(messages),
                                             alertType, alertButtons));
        }
示例#17
0
        internal static AlertForm CreateAlertForm(string title, string message,
                                                  AlertType alertType,
                                                  AlertButtons alertButtons)
        {
            var image = GetGifImage(alertType);
            var sound = GetPopupSound(alertType);

            switch (alertButtons)
            {
            case AlertButtons.Ok:
            {
                return(new AlertForm().SetDetail(title, message, image, sound,
                                                 new List <AlertButtonViewModel>
                    {
                        AlertStaticButtons.OkButton(GetOkButtonPenColour(alertType))
                    }));
            }

            case AlertButtons.OkCancel:
            {
                return(new AlertForm().SetDetail(title, message, image, sound,
                                                 new List <AlertButtonViewModel>
                    {
                        AlertStaticButtons.OkButton(),
                        AlertStaticButtons.CancelButton()
                    }));
            }

            case AlertButtons.AbortRetryIgnore:
            {
                return(new AlertForm().SetDetail(title, message, image, sound,
                                                 new List <AlertButtonViewModel>
                    {
                        AlertStaticButtons.OkButton(),
                        AlertStaticButtons.RetryButton(),
                        AlertStaticButtons.IgnoreButton()
                    }));
            }

            case AlertButtons.YesNoCancel:
            {
                return(new AlertForm().SetDetail(title, message, image, sound,
                                                 new List <AlertButtonViewModel>
                    {
                        AlertStaticButtons.YesButton(),
                        AlertStaticButtons.NoButton(),
                        AlertStaticButtons.CancelButton()
                    }));
            }

            case AlertButtons.YesNo:
            {
                return(new AlertForm().SetDetail(title, message, image, sound,
                                                 new List <AlertButtonViewModel>
                    {
                        AlertStaticButtons.YesButton(),
                        AlertStaticButtons.NoButton()
                    }));
            }

            case AlertButtons.RetryCancel:
            {
                return(new AlertForm().SetDetail(title, message, image, sound,
                                                 new List <AlertButtonViewModel>
                    {
                        AlertStaticButtons.RetryButton(),
                        AlertStaticButtons.CancelButton()
                    }));
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(alertButtons), alertButtons, null);
            }
        }
示例#18
0
        internal static AlertForm CreateAlertForm(Control parentControl, string title, string message,
                                                  string messagesTitle, string exceptionDetail, string rtf,
                                                  AlertType alertType, AlertButtons alertButtons)
        {
            var image        = GetGifImage(alertType);
            var sound        = GetPopupSound(alertType);
            var isErrorAlert = alertType == AlertType.Error;

            var alertForm = new AlertForm
            {
                ParentControl   = HelperMethods.GetCurrentlyActiveForm(parentControl),
                FormTitle       = title,
                MessagesTitle   = messagesTitle,
                FormImage       = image,
                FormMessage     = message,
                SystemSound     = sound,
                IsErrorAlert    = isErrorAlert,
                ExceptionDetail = exceptionDetail,
                Rtf             = rtf
            };

            switch (alertButtons)
            {
            case AlertButtons.Ok:
            {
                alertForm.FormButtons = new List <AlertButtonViewModel>
                {
                    AlertStaticButtons.OkButton(GetOkButtonPenColour(alertType))
                };
                break;
            }

            case AlertButtons.OkCancel:
            {
                alertForm.FormButtons = new List <AlertButtonViewModel>
                {
                    AlertStaticButtons.OkButton(),
                        AlertStaticButtons.CancelButton()
                };
                break;
            }

            case AlertButtons.AbortRetryIgnore:
            {
                alertForm.FormButtons = new List <AlertButtonViewModel>
                {
                    AlertStaticButtons.OkButton(),
                        AlertStaticButtons.RetryButton(),
                        AlertStaticButtons.IgnoreButton()
                };
                break;
            }

            case AlertButtons.YesNoCancel:
            {
                alertForm.FormButtons = new List <AlertButtonViewModel>
                {
                    AlertStaticButtons.YesButton(),
                        AlertStaticButtons.NoButton(),
                        AlertStaticButtons.CancelButton()
                };
                break;
            }

            case AlertButtons.YesNo:
            {
                alertForm.FormButtons = new List <AlertButtonViewModel>
                {
                    AlertStaticButtons.YesButton(),
                        AlertStaticButtons.NoButton()
                };
                break;
            }

            case AlertButtons.RetryCancel:
            {
                alertForm.FormButtons = new List <AlertButtonViewModel>
                {
                    AlertStaticButtons.RetryButton(),
                        AlertStaticButtons.CancelButton()
                };
                break;
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(alertButtons), alertButtons, null);
            }

            return(alertForm);
        }