Example #1
0
        public static PopUp.PopUpResult MessageBox(this UIElement owner, string message, string title,
                                                   MessageBoxImage icon = MessageBoxImage.Information, TextAlignment textAlignment = TextAlignment.Center,
                                                   PopUp.PopUpButtonsType buttonsType = PopUp.PopUpButtonsType.OK, int timeout     = Timeout.Infinite)
        {
            PopUp.PopUpButtons buttons = new PopUp.PopUpButtons(buttonsType);

            return(WPF_Helper.ExecuteOnUIThreadWPF(() =>
            {
                return MessageWindowExtension.MessageBox(owner, ref message, title, icon, textAlignment, buttons, timeout);
            }));
        }
Example #2
0
        public static PopUp.PopUpResult MessageBoxEx(this System.Windows.Forms.Control owner, string message, string title,
                                                     MessageBoxImage icon       = MessageBoxImage.Information, TextAlignment textAlignment = TextAlignment.Center,
                                                     PopUp.PopUpButtons buttons = null, int timeout = Timeout.Infinite)
        {
            if (buttons == null)
            {
                buttons = new PopUp.PopUpButtons(PopUp.PopUpButtonsType.OK);
            }

            return(WPF_Helper.ExecuteOnUIThreadForm(() =>
            {
                return MessageWindowExtension.MessageBox(owner.Handle, ref message, title, icon, textAlignment, buttons, timeout);
            }));
        }
Example #3
0
        public static PopUpResult InputBox(ref string userInput, string title,
                                           MessageBoxImage icon         = MessageBoxImage.Information, TextAlignment textAlignment = TextAlignment.Justify,
                                           PopUpButtonsType buttonsType = PopUpButtonsType.CancelOK, int timeout                   = Timeout.Infinite)
        {
            PopUpButtons buttons = new PopUpButtons(buttonsType);

            string      message = userInput;
            PopUpResult res     = WPF_Helper.ExecuteOnUIThread(() =>
            {
                return(MessageWindowExtension.MessageBox(null,
                                                         ref message, title,
                                                         icon, textAlignment,
                                                         buttons, timeout,
                                                         false));
            });

            userInput = message;
            return(res);
        }
Example #4
0
        /// <summary>
        /// Show Message Box, using main app window(WinForms or WPF) as owner,
        /// If btn*text is null will assign text by 'buttons'
        /// </summary>
        /// <param name="GetOwnerOnUIThread">function that returns WPF UIElement to center on, wull be executed on UI thread, can be null</param>
        /// <param name="message"></param>
        /// <param name="title"></param>
        /// <param name="icon"></param>
        /// <param name="textAlignment"></param>
        /// <param name="buttons"></param>
        /// <param name="timeout">execute default action after timeout if more than 100 milliseconds</param>
        /// <returns></returns>
        public static PopUpResult MessageBox(Func <UIElement> GetOwnerOnUIThread, string message, string title,
                                             MessageBoxImage icon, TextAlignment textAlignment = TextAlignment.Center,
                                             PopUpButtons buttons = null, int timeout = Timeout.Infinite)
        {
            if (buttons == null)
            {
                buttons = new PopUpButtons(PopUpButtonsType.OK);
            }

            return(WPF_Helper.ExecuteOnUIThread(() =>
            {
                UIElement owner = null;
                if (GetOwnerOnUIThread != null)
                {
                    owner = GetOwnerOnUIThread();
                }

                return MessageWindowExtension.MessageBox(owner,
                                                         ref message, title,
                                                         icon, textAlignment,
                                                         buttons, timeout,
                                                         true);
            }));
        }