private static PopUp.PopUpResult MessageBoxCreateAndOpen(Action <MessageWindow> SetOwnerAndCenter,
                                                                 ref string message, string title, MessageBoxImage icon, TextAlignment textAlignment,
                                                                 PopUp.PopUpButtons buttons, int autoCloseTimeoutMs = Timeout.Infinite, //infinite
                                                                 bool bReadonly = true)
        {
            MessageWindow wnd = new MessageWindow(buttons);

            wnd.WindowStartupLocation = WindowStartupLocation.Manual; // sWindowStartupLocation;
            wnd.ConfigureAppearance(icon);
            wnd.Title = title;                                        //for task bar visible tetx
            wnd.txtMessage.TextAlignment = textAlignment;
            wnd.txtMessage.Text          = message;
            wnd.txtMessage.IsReadOnly    = bReadonly;
            //wnd.txtMessage.ToolTip = message;
            wnd.txtTitle.Text = title;
            //wnd.txtTitle.ToolTip = title;

            wnd.btn1.Content = buttons.btn1.Text;
            wnd.btn2.Content = buttons.btn2.Text;
            wnd.btn3.Content = buttons.btn3.Text;

            wnd.AdjustSize(message, true);

            SetOwnerAndCenter(wnd);

            //if timeout is set and window is not closed after timeout - close it
            Thread t = wnd.CloseWindowOnTimeout(autoCloseTimeoutMs);

            wnd.ShowDialog();

            //if closed before timeout - abort thread
            if (t != null)
            {
                t.Abort();
            }

            //get text from input box - return value
            message = wnd.txtMessage.Text;

            return(wnd._DialogResult);
        }
        public static PopUp.PopUpResult MessageBox(IntPtr ownerHwnd,
                                                   ref string message, string title,
                                                   MessageBoxImage icon,
                                                   TextAlignment textAlignment,
                                                   PopUp.PopUpButtons buttons,
                                                   int autoCloseTimeoutMs = Timeout.Infinite, //infinite
                                                   bool bReadonly         = true)
        {
            Action <MessageWindow> SetOwnerAndCenter = (wnd) =>
            {
                wnd.SetOwner(ownerHwnd);
                if (ownerHwnd != IntPtr.Zero)
                {
                    wnd.CenterToWindow(ownerHwnd);
                }
                else
                {
                    wnd.CenterToMainWindow();
                }
            };

            return(MessageBoxCreateAndOpen(SetOwnerAndCenter, ref message, title, icon, textAlignment, buttons, autoCloseTimeoutMs, bReadonly));
        }