⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uierrorhelper.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Pc
{
    using Imps.Client.Core;
    using Imps.Client.Utils;
    using System;
    using System.Windows.Forms;

    public static class UiErrorHelper
    {
        public static void HandEventSafely(IFrameworkWindow frameworkWnd, SimpleEventHandler handler)
        {
            try
            {
                handler();
            }
            catch (ApplicationException exception)
            {
                frameworkWnd.UnifiedMessageBox.ShowError(exception.Message);
            }
            catch (Exception exception2)
            {
                frameworkWnd.UnifiedMessageBox.ShowException(exception2);
            }
        }

        public static void HandEventSafely<TEventArgs>(IFrameworkWindow frameworkWnd, EventHandler<TEventArgs> handler, object sender, TEventArgs e) where TEventArgs: EventArgs
        {
            try
            {
                handler.Invoke(sender, e);
            }
            catch (ApplicationException exception)
            {
                frameworkWnd.UnifiedMessageBox.ShowError(exception.Message);
            }
            catch (Exception exception2)
            {
                frameworkWnd.UnifiedMessageBox.ShowException(exception2);
            }
        }

        public static void HandExceptionSafely(IFrameworkWindow frameworkWnd, Exception ex)
        {
            if (ex is ApplicationException)
            {
                frameworkWnd.UnifiedMessageBox.ShowError(ex.Message);
            }
            else
            {
                frameworkWnd.UnifiedMessageBox.ShowException(ex);
            }
        }

        public static DialogResult ShowImpsAlert(IFrameworkWindow framework, Form owner, ImpsErrorEventArgs e, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            DialogResult cancel = DialogResult.Cancel;
            try
            {
                if (e.Handled)
                {
                    return cancel;
                }
                string text = e.Description ?? string.Empty;
                string detail = text;
                if (e.ErrorException != null)
                {
                    detail = detail + "\r\n" + e.ErrorException.ToString();
                }
                ClientLogger.WriteGeneral(e.Summary, detail);
                if (((owner == null) || !owner.IsHandleCreated) || !owner.Visible)
                {
                    owner = framework.MainWindow;
                }
                cancel = framework.UnifiedMessageBox.Show(owner, e.Summary, "", buttons, icon);
                e.Handled = true;
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
            return cancel;
        }

        public static void ShowImpsError(IFrameworkWindow framework, Form owner, ImpsErrorEventArgs e)
        {
            try
            {
                if (!e.Handled)
                {
                    string detail = e.Description ?? string.Empty;
                    string text2 = detail;
                    if (e.ErrorException != null)
                    {
                        text2 = text2 + "\r\n" + e.ErrorException.ToString();
                    }
                    ClientLogger.WriteGeneral(e.Summary, text2);
                    if (((owner == null) || !owner.IsHandleCreated) || !owner.Visible)
                    {
                        owner = framework.MainWindow;
                    }
                    framework.UnifiedMessageBox.ShowWarning(owner, e.Summary, detail);
                    e.Handled = true;
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -