Skip to content

Lnlxy/WinForms.MessageBox

Repository files navigation

WinForms.MessageBox

封装以 System.Windows.Forms.MessageBoxIcon 枚举图标风格的多种创建MessageBox的方法。支持自定义按钮显示的文本及按钮点击的返回值和方法。

用法

  1. 基本用法
MessageBoxService.Question("text", "title").AsYesNoBehavior()
                .OnYes(() =>
                {
                    //yes button click todo;
                })
                .OnNo(() =>
                {
                    //no button click todo;
                }).Show();
  1. 操作返回值
var result = MessageBoxService.Question("text", "title").AsYesNoBehavior<int>()
                .OnYes(() =>
                {
                    //yes button click todo;
                    return 1;
                })
                .OnNo(() =>
                {
                    //no button click todo;
                    return -1; 
                }).Show();
  1. 修改指定按钮显示文本
MessageBoxService.Question("Agree?", "select...").AsYesNoBehavior()
                .SetYesText("Agree!")
                .SetNoText("No!")
                .OnYes(() =>
                {
                    //do agree code;
                })
                .OnNo(() =>
                {
                    //do disagree code;
                }).Show();

About

WinForms.MessageBox

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published