开源代码,欢迎复制

//----集成消息弹出框

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace EcaClient.Estate.Windows
{
    public class EstateMessageBox
    {
        ///


        /// 显示信息对话框
        ///

        /// 消息内容
        public static void InfoMsgBox(string aMessage)
        {
            if (String.IsNullOrEmpty(aMessage))
                return;
            MessageBox.Show(aMessage, "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        ///


        /// 显示信息对话框,支持消息内容格式化
        ///

        /// 消息内容
        /// 参数数组
        public static void InfoMsgBox(string aMessage, params Object[] args)
        {
            string vMessage;

            vMessage = String.Format(aMessage, args);
            InfoMsgBox(vMessage);
        }

        ///


        /// 显示警告对话框
        ///

        /// 消息内容
        public static void WarningMsgBox(string aMessage)
        {
            if (String.IsNullOrEmpty(aMessage))
                return;
            MessageBox.Show(aMessage, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }

        ///


        /// 显示警告对话框,支持消息内容格式化
        ///

        /// 消息内容
        /// 参数数组
        public static void WarningMsgBox(string aMessage, params Object[] args)
        {
            string vMessage;

            vMessage = String.Format(aMessage, args);
            WarningMsgBox(vMessage);
        }

        ///


        /// 错误信息对话框
        ///

        /// 消息内容
        public static void ErrorMsgBox(string aMessage)
        {
            if (String.IsNullOrEmpty(aMessage))
                return;
            MessageBox.Show(aMessage, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        ///


        /// 错误信息对话框,支持消息内容格式化
        ///

        /// 消息内容
        /// 参数数组
        public static void ErrorMsgBox(string aMessage, params Object[] args)
        {
            string vMessage;

            vMessage = String.Format(aMessage, args);
            ErrorMsgBox(vMessage);
        }

        ///


        /// 显示询问对话框
        ///

        /// 消息内容
        /// 是否确认
        public static bool YesNoMsgBox(string aMessage)
        {
            bool vResult;

            vResult = MessageBox.Show(aMessage, "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
            return vResult;
        }

        ///


        /// 显示询问对话框,支持消息内容格式化
        ///

        /// 消息内容
        /// 参数数组
        /// 是否确认
        public static bool YesNoMsgBox(string aMessage, params Object[] args)
        {
            string vMessage;

            vMessage = String.Format(aMessage, args);
            return YesNoMsgBox(vMessage);
        }

        ///


        /// 显示询问对话框(含取消)
        ///

        /// 消息内容
        /// 对话框结果
        public static DialogResult YesNoCancelMsgBox(string aMessage)
        {
            DialogResult vResult;

            vResult = MessageBox.Show(aMessage, "询问", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
            return vResult;
        }

        ///


        /// 显示询问对话框(含取消),支持消息内容格式化
        ///

        /// 消息内容
        /// 参数数组
        ///
        public static DialogResult YesNoCancelMsgBox(string aMessage, params Object[] args)
        {
            string vMessage;

            vMessage = String.Format(aMessage, args);
            return YesNoCancelMsgBox(vMessage);
        }
    }
}

你可能感兴趣的:(.NET开发,string,object,class)