Beispiel #1
0
        ///// <summary>
        ///// Shows an Exception box.
        ///// </summary>
        ///// <param name="owner">The owner.</param>
        ///// <param name="ex">The exception.</param>
        ///// <returns>Always <see cref="ExceptionBoxResult.Close"/>.</returns>
        //public static ExceptionBoxResult Show(IWin32Window owner, Exception exception)
        //{
        //    return Show(owner, exception, false);
        //}

        /// <summary>
        /// Shows the specified owner.
        /// </summary>
        /// <param name="owner">The owner.</param>
        /// <param name="exception">The exception.</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="canExitApplication">if set to <c>true</c> then the button allowing to exit the application is visible.</param>
        /// <returns>Either <see cref="ExceptionBoxResult.Close"/> or <see cref="ExceptionBoxResult.Exit"/>.</returns>
        public static ExceptionBoxResult Show(
            IWin32Window owner, object exception, string text, bool canExitApplication)
        {
            try
            {
                var box = new ExceptionBox(exception, text, canExitApplication);
                if (owner == null)
                {
                    box.StartPosition = FormStartPosition.CenterScreen;
                }
                box.ShowDialog(owner);
                return(box.Result);
            }
            catch (Exception ex)
            {
                // eat the exception
                var debugEx = ex;
            }

            return(ExceptionBoxResult.Close);
        }
        ///// <summary>
        ///// Shows an Exception box.
        ///// </summary>
        ///// <param name="owner">The owner.</param>
        ///// <param name="ex">The exception.</param>
        ///// <returns>Always <see cref="ExceptionBoxResult.Close"/>.</returns>
        //public static ExceptionBoxResult Show(IWin32Window owner, Exception exception)
        //{
        //    return Show(owner, exception, false);
        //}

        /// <summary>
        /// Shows the specified owner.
        /// </summary>
        /// <param name="owner">The owner.</param>
        /// <param name="exception">The exception.</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="canExitApplication">if set to <c>true</c> then the button allowing to exit the application is visible.</param>
        /// <returns>Either <see cref="ExceptionBoxResult.Close"/> or <see cref="ExceptionBoxResult.Exit"/>.</returns>
        public static ExceptionBoxResult Show(
            IWin32Window owner, object exception, string text, bool canExitApplication)
        {
            try
            {
                var box = new ExceptionBox(exception, text, canExitApplication);
                if (owner == null) box.StartPosition = FormStartPosition.CenterScreen;
                box.ShowDialog(owner);
                return box.Result;
            }
            catch (Exception ex)
            {
                // eat the exception
                var debugEx = ex;
            }

            return ExceptionBoxResult.Close;
        }