📄 msgbox.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Resources;
namespace APLib.Windows.Control
{
/// <summary>
/// 本地化的MessageBox
/// </summary>
public class MsgBox
{
/// <summary>
/// 显示提示对话框
/// </summary>
/// <param name="type">资源文件类型</param>
/// <param name="text">提示信息字符串资源名称</param>
/// <param name="caption">标题字符串资源名称</param>
/// <param name="button">按钮类型</param>
/// <param name="icon">图标类型</param>
/// <returns>对话框返回值</returns>
public static DialogResult Show(Type type, string text, string caption, MessageBoxButtons button, MessageBoxIcon icon)
{
ResourceManager rm = new ResourceManager(type);
return MessageBox.Show(rm.GetString(text), rm.GetString(caption), button, icon);
}
/// <summary>
/// 显示错误提示信息对话框
/// </summary>
/// <param name="type">资源文件类型</param>
/// <param name="text">提示信息字符串资源名称</param>
/// <param name="caption">标题字符串资源名称</param>
public static void ShowError(Type type,string text,string caption)
{
Show(type, text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
/// <summary>
/// 显示Yes/No询问对话框
/// </summary>
/// <param name="type">资源文件类型</param>
/// <param name="text">提示信息字符串资源名称</param>
/// <param name="caption">标题字符串资源名称</param>
/// <returns>对话框返回值</returns>
public static DialogResult ShowQuestion(Type type, string text, string caption)
{
return Show(type, text, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
/// <summary>
/// 显示Yes/No/Cancel询问对话框
/// </summary>
/// <param name="type">资源文件类型</param>
/// <param name="text">提示信息字符串资源名称</param>
/// <param name="caption">标题字符串资源名称</param>
/// <returns>对话框返回值</returns>
public static DialogResult ShowQuestion2(Type type, string text, string caption)
{
return Show(type, text, caption, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
}
/// <summary>
/// 显示信息对话框
/// </summary>
/// <param name="type">资源文件类型</param>
/// <param name="text">提示信息字符串资源名称</param>
/// <param name="caption">标题字符串资源名称</param>
/// <returns>对话框返回值</returns>
public static DialogResult ShowInformation(Type type, string text, string caption)
{
return Show(type, text, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -