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

📄 unifiedmessagebox.cs

📁 飞信的收发使用csharp进行开发
💻 CS
字号:
namespace Imps.Client.Pc
{
    using Imps.Client.Core;
    using Imps.Client.Resource;
    using Imps.Client.Utils;
    using System;
    using System.Windows.Forms;

    internal class UnifiedMessageBox : IUnifiedMessageBox
    {
        private IFrameworkWindow _frameworkWnd;
        private string _msgException;

        public UnifiedMessageBox(IFrameworkWindow frameworkeWnd)
        {
            this._frameworkWnd = frameworkeWnd;
        }

        public DialogResult Show(string text, string detail, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            return this.Show(null, text, detail, buttons, icon);
        }

        public DialogResult Show(string text, string detail, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultBtn)
        {
            return this.Show(null, text, detail, buttons, icon, defaultBtn);
        }

        public DialogResult Show(IWin32Window owner, string text, string detail, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            if ((owner == null) && (this._frameworkWnd is IWin32Window))
            {
                owner = (IWin32Window) this._frameworkWnd;
            }
            if (string.IsNullOrEmpty(detail))
            {
                detail = text;
            }
            else if (!string.IsNullOrEmpty(text))
            {
                detail = text + "\r\n\r\n" + detail;
            }
            if (string.IsNullOrEmpty(detail))
            {
                detail = this.MsgException;
            }
            ImpsMessageBox form = new ImpsMessageBox(owner, detail, buttons, icon);
            return ControlHelper.ShowDialogCenterOnParent(form, owner);
        }

        public DialogResult Show(IWin32Window owner, string text, string detail, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultBtn)
        {
            if ((owner == null) && (this._frameworkWnd is IWin32Window))
            {
                owner = (IWin32Window) this._frameworkWnd;
            }
            if (string.IsNullOrEmpty(detail))
            {
                detail = text;
            }
            else if (!string.IsNullOrEmpty(text))
            {
                detail = text + "\r\n\r\n" + detail;
            }
            if (string.IsNullOrEmpty(detail))
            {
                detail = this.MsgException;
            }
            ImpsMessageBox form = new ImpsMessageBox(owner, detail, buttons, icon, defaultBtn);
            return ControlHelper.ShowDialogCenterOnParent(form, owner);
        }

        public DialogResult ShowConfirmation(string text)
        {
            return this.Show(null, text, null, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        }

        public DialogResult ShowConfirmation(string text, string detail)
        {
            return this.Show(null, text, detail, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        }

        public DialogResult ShowConfirmation(string text, MessageBoxDefaultButton defaultBtn)
        {
            return this.Show(null, text, null, MessageBoxButtons.YesNo, MessageBoxIcon.Question, defaultBtn);
        }

        public DialogResult ShowConfirmation(IWin32Window owner, string text)
        {
            return this.Show(owner, text, null, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        }

        public DialogResult ShowConfirmation(string text, string detail, MessageBoxDefaultButton defaultBtn)
        {
            return this.Show(null, text, detail, MessageBoxButtons.YesNo, MessageBoxIcon.Question, defaultBtn);
        }

        public DialogResult ShowConfirmation(IWin32Window owner, string text, string detail)
        {
            return this.Show(owner, text, detail, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
        }

        public DialogResult ShowConfirmation(IWin32Window owner, string text, MessageBoxDefaultButton defaultBtn)
        {
            return this.Show(owner, text, null, MessageBoxButtons.YesNo, MessageBoxIcon.Question, defaultBtn);
        }

        public DialogResult ShowConfirmation(IWin32Window owner, string text, string detail, MessageBoxDefaultButton defaultBtn)
        {
            return this.Show(owner, text, detail, MessageBoxButtons.YesNo, MessageBoxIcon.Question, defaultBtn);
        }

        public void ShowError(string text)
        {
            this.Show(null, text, null, MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }

        public void ShowError(string text, string detail)
        {
            this.Show(null, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }

        public void ShowError(string text, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(null, text, null, MessageBoxButtons.OK, MessageBoxIcon.Hand, defaultBtn);
        }

        public void ShowError(IWin32Window owner, string text)
        {
            this.Show(owner, text, null, MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }

        public void ShowError(string text, string detail, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(null, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Hand, defaultBtn);
        }

        public void ShowError(IWin32Window owner, string text, string detail)
        {
            this.Show(owner, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }

        public void ShowError(IWin32Window owner, string text, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(owner, text, null, MessageBoxButtons.OK, MessageBoxIcon.Hand, defaultBtn);
        }

        public void ShowError(IWin32Window owner, string text, string detail, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(owner, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Hand, defaultBtn);
        }

        public void ShowException(Exception e)
        {
            if (Imps.Client.Core.Configuration.FixedClientSetting.IsDebugEdtion)
            {
                this.ShowError(e.Message, e.StackTrace);
            }
            else
            {
                ClientLogger.WriteException(e);
                this.ShowError(this.MsgException);
            }
        }

        public void ShowException(Exception e, MessageBoxDefaultButton defaultBtn)
        {
            if (Imps.Client.Core.Configuration.FixedClientSetting.IsDebugEdtion)
            {
                this.ShowError(e.Message, e.StackTrace, defaultBtn);
            }
            else
            {
                ClientLogger.WriteException(e);
                this.ShowError(this.MsgException, defaultBtn);
            }
        }

        public void ShowException(string summary, Exception e)
        {
            if (Imps.Client.Core.Configuration.FixedClientSetting.IsDebugEdtion)
            {
                this.ShowError(summary, e.ToString());
            }
            else
            {
                ClientLogger.WriteException(e);
                this.ShowError(summary);
            }
        }

        public void ShowException(IWin32Window owner, Exception e)
        {
            if (Imps.Client.Core.Configuration.FixedClientSetting.IsDebugEdtion)
            {
                this.ShowError(owner, e.Message, e.StackTrace);
            }
            else
            {
                ClientLogger.WriteException(e);
                this.ShowError(owner, this.MsgException);
            }
        }

        public void ShowException(string summary, Exception e, MessageBoxDefaultButton defaultBtn)
        {
            if (Imps.Client.Core.Configuration.FixedClientSetting.IsDebugEdtion)
            {
                this.ShowError(summary, e.ToString(), defaultBtn);
            }
            else
            {
                ClientLogger.WriteException(e);
                this.ShowError(summary, defaultBtn);
            }
        }

        public void ShowException(IWin32Window owner, Exception e, MessageBoxDefaultButton defaultBtn)
        {
            if (Imps.Client.Core.Configuration.FixedClientSetting.IsDebugEdtion)
            {
                this.ShowError(owner, e.Message, e.StackTrace, defaultBtn);
            }
            else
            {
                ClientLogger.WriteException(e);
                this.ShowError(owner, this.MsgException, defaultBtn);
            }
        }

        public void ShowException(IWin32Window owner, string summary, Exception e)
        {
            if (Imps.Client.Core.Configuration.FixedClientSetting.IsDebugEdtion)
            {
                this.ShowError(owner, summary, e.ToString());
            }
            else
            {
                ClientLogger.WriteException(e);
                this.ShowError(owner, summary);
            }
        }

        public void ShowException(IWin32Window owner, string summary, Exception e, MessageBoxDefaultButton defaultBtn)
        {
            if (Imps.Client.Core.Configuration.FixedClientSetting.IsDebugEdtion)
            {
                this.ShowError(owner, summary, e.ToString(), defaultBtn);
            }
            else
            {
                ClientLogger.WriteException(e);
                this.ShowError(owner, summary, defaultBtn);
            }
        }

        public void ShowFatalError(string text)
        {
            this.Show(null, text, null, MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }

        public void ShowFatalError(string text, string detail)
        {
            this.Show(null, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }

        public void ShowFatalError(string text, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(null, text, null, MessageBoxButtons.OK, MessageBoxIcon.Hand, defaultBtn);
        }

        public void ShowFatalError(IWin32Window owner, string text)
        {
            this.Show(owner, text, null, MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }

        public void ShowFatalError(string text, string detail, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(null, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Hand, defaultBtn);
        }

        public void ShowFatalError(IWin32Window owner, string text, string detail)
        {
            this.Show(owner, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }

        public void ShowFatalError(IWin32Window owner, string text, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(owner, text, null, MessageBoxButtons.OK, MessageBoxIcon.Hand, defaultBtn);
        }

        public void ShowFatalError(IWin32Window owner, string text, string detail, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(owner, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Hand, defaultBtn);
        }

        public void ShowInfo(string text)
        {
            this.Show(null, text, null, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }

        public void ShowInfo(string text, string detail)
        {
            this.Show(null, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }

        public void ShowInfo(string text, MessageBoxDefaultButton defaultButton)
        {
            this.Show(null, text, null, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, defaultButton);
        }

        public void ShowInfo(IWin32Window owner, string text)
        {
            this.Show(owner, text, null, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }

        public void ShowInfo(string text, string detail, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(null, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, defaultBtn);
        }

        public void ShowInfo(IWin32Window owner, string text, string detail)
        {
            this.Show(owner, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }

        public void ShowInfo(IWin32Window owner, string text, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(owner, text, null, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, defaultBtn);
        }

        public void ShowInfo(IWin32Window owner, string text, string detail, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(owner, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Asterisk, defaultBtn);
        }

        public void ShowWarning(string text)
        {
            this.Show(null, text, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }

        public void ShowWarning(string text, string detail)
        {
            this.Show(null, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }

        public void ShowWarning(string text, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(null, text, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, defaultBtn);
        }

        public void ShowWarning(IWin32Window owner, string text)
        {
            this.Show(owner, text, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }

        public void ShowWarning(string text, string detail, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(null, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, defaultBtn);
        }

        public void ShowWarning(IWin32Window owner, string text, string detail)
        {
            this.Show(owner, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }

        public void ShowWarning(IWin32Window owner, string text, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(owner, text, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, defaultBtn);
        }

        public void ShowWarning(IWin32Window owner, string text, string detail, MessageBoxDefaultButton defaultBtn)
        {
            this.Show(owner, text, detail, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, defaultBtn);
        }

        public string MsgException
        {
            get
            {
                if (string.IsNullOrEmpty(this._msgException))
                {
                    this._msgException = string.Format(StringTable.MsgExceptionPattern, this._frameworkWnd.AccountManager.CurrentUser.Configuration.SystemSetting.SvcNoSetting.SvcNoHelpDesk);
                }
                return this._msgException;
            }
        }
    }
}

⌨️ 快捷键说明

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