Ejemplo n.º 1
0
        /// <summary>
        /// Runs the modal dialog.
        /// </summary>
        /// <returns></returns>
        public DialogBoxAction RunModal()
        {
            _showingModal = true;
            try
            {
                DialogResult result = _form.ShowDialog(_owner);
                switch (result)
                {
                case DialogResult.Cancel:
                    return(DialogBoxAction.Cancel);

                case DialogResult.OK:
                    return(DialogBoxAction.Ok);

                case DialogResult.No:
                    return(DialogBoxAction.No);

                case DialogResult.Yes:
                    return(DialogBoxAction.Yes);

                default:
                    throw new NotSupportedException();
                }
            }
            finally
            {
                _showingModal = false;
                DisposeForm();
            }
        }
Ejemplo n.º 2
0
        protected override ExceptionDialogAction Show()
        {
            var control = new ExceptionDialogControl(Exception, Message, Actions, CloseForm, CloseForm);

            _form = new DialogBoxForm(Title, control, Size.Empty, DialogSizeHint.Auto);

            var screen    = ScreenFromActiveForm() ?? ScreenFromMousePosition();
            int xdiff     = screen.Bounds.Width - _form.Bounds.Width;
            int ydiff     = screen.Bounds.Height - _form.Bounds.Height;
            int locationX = screen.WorkingArea.Left + Math.Max(0, (xdiff) / 2);
            int locationY = screen.WorkingArea.Top + Math.Max(0, (ydiff) / 2);

            _form.StartPosition = FormStartPosition.Manual;
            _form.Location      = new Point(locationX, locationY);
            //_form.TopMost = true;
            _form.ShowDialog();

            return(control.Result);
        }