示例#1
0
        private static int Show(IntPtr ownerHandle, string caption, string htmlTitle, string htmlMessage, List <string> buttonsList, ref object data, out YamuiInput msgBox, int maxFormWidth = 0, int maxFormHeight = 0, int minFormWidth = 0, bool waitResponse = true, EventHandler <HtmlLinkClickedEventArgs> onLinkClicked = null)
        {
            var ownerRect     = WinApi.GetWindowRect(ownerHandle);
            var ownerLocation = ownerRect.Location;

            ownerLocation.Offset(ownerRect.Width / 2, ownerRect.Height / 2);
            var screen = Screen.FromPoint(ownerLocation);

            // correct input if needed
            if (maxFormWidth == 0)
            {
                maxFormWidth = screen.WorkingArea.Width - 20;
            }
            if (maxFormHeight == 0)
            {
                maxFormHeight = screen.WorkingArea.Height - 20;
            }
            if (minFormWidth == 0)
            {
                minFormWidth = 300;
            }
            if (data != null)
            {
                waitResponse = true;
            }

            // new message box
            msgBox = new YamuiInput(htmlTitle, htmlMessage, buttonsList, data, maxFormWidth, maxFormHeight, minFormWidth, onLinkClicked)
            {
                ShowInTaskbar = !waitResponse,
                Text          = caption
            };

            // center parent
            msgBox.Location = new Point((ownerRect.Width - msgBox.Width) / 2 + ownerRect.X, (ownerRect.Height - msgBox.Height) / 2 + ownerRect.Y);

            // get yamui form
            var yamuiForm = FromHandle(ownerHandle) as YamuiMainAppli;

            // we either display a modal or a normal messagebox
            if (waitResponse)
            {
                if (yamuiForm != null)
                {
                    //yamuiForm.HasModalOpened = true;

                    msgBox.ShowDialog(new WindowWrapper(ownerHandle));
                }

                if (msgBox.Bound)
                {
                    data = msgBox.DataObject;
                }

                if (yamuiForm != null)
                {
                    //yamuiForm.HasModalOpened = false;

                    msgBox.Dispose();
                }

                // get focus back to owner
                WinApi.SetForegroundWindow(ownerHandle);
            }
            else
            {
                msgBox.Show(new WindowWrapper(ownerHandle));
            }

            var res = msgBox.DialogIntResult;

            return(res);
        }
示例#2
0
 /// <summary>
 /// Show a message box dialog
 /// </summary>
 public static int Show(IntPtr ownerHandle, string caption, string htmlTitle, string htmlMessage, List <string> buttonsList, ref object data, out YamuiInput msgBox, int maxFormWidth = 0, int maxFormHeight = 0, int minFormWidth = 0, EventHandler <HtmlLinkClickedEventArgs> onLinkClicked = null)
 {
     return(Show(ownerHandle, caption, htmlTitle, htmlMessage, buttonsList, ref data, out msgBox, maxFormWidth, maxFormHeight, minFormWidth, false, onLinkClicked));
 }