示例#1
0
        WaitHandle DisplayBaseMessageForm(Func <Forms.BaseMessageForm> formInitializer)
        {
            Forms.BaseMessageForm form = null;
            Action action = new Action(
                () =>
            {
                form = formInitializer();
                if (_ownerWindow.WindowState == FormWindowState.Minimized)
                {
                    _ownerWindow.WindowState = FormWindowState.Normal;
                }
                if (_lastMessageFormX > 0 && _lastMessageFormY > 0)
                {
                    form.Top  = _lastMessageFormY;
                    form.Left = _lastMessageFormX;
                }
                else
                {
                    form.Top  = _ownerWindow.Top + (_ownerWindow.Height - form.Height) / 2;
                    form.Left = _ownerWindow.Left + (_ownerWindow.Width - form.Width) / 2;
                }
                form.Show(_ownerWindow);
                form.Focus();
            });

            if (_ownerWindow.InvokeRequired)
            {
                _ownerWindow.Invoke(action);
            }
            else
            {
                action();
            }
            return(form.FormClosingEvent);
        }
示例#2
0
        void CloseForm(Forms.BaseMessageForm form, Action deinitialize)
        {
            Action action = new Action(
                () =>
            {
                if (form != null)
                {
                    _lastMessageFormY = form.Top;
                    _lastMessageFormX = form.Left;

                    form.Close();
                    deinitialize();
                }
            });

            if (_ownerWindow.InvokeRequired)
            {
                _ownerWindow.Invoke(action);
            }
            else
            {
                action();
            }
        }