* UIInputDialog:输入框增加半透明遮罩

This commit is contained in:
Sunny 2021-12-15 22:20:26 +08:00
parent 533d8fb7b4
commit c2ebe8193c
4 changed files with 91 additions and 49 deletions

Binary file not shown.

Binary file not shown.

View File

@ -64,7 +64,7 @@ namespace Sunny.UI.Demo
private void btnStringInput_Click(object sender, EventArgs e)
{
string value = "请输入字符串";
if (this.InputStringDialog(ref value))
if (this.InputStringDialog(ref value, true, "请输入字符串:", true))
{
ShowInfoDialog(value);
}

View File

@ -243,7 +243,8 @@ namespace Sunny.UI
public static class UIInputDialog
{
public static bool InputStringDialog(ref string value, bool checkEmpty = true, string desc = "请输入字符串:", UIStyle style = UIStyle.Blue, bool topMost = false)
public static bool InputStringDialog(ref string value, bool checkEmpty = true,
string desc = "请输入字符串:", UIStyle style = UIStyle.Blue, bool topMost = false, bool showMask = false)
{
UIInputForm frm = new UIInputForm();
frm.TopMost = topMost;
@ -252,6 +253,9 @@ namespace Sunny.UI
frm.Text = UILocalize.InputTitle;
frm.Label.Text = desc;
frm.CheckInputEmpty = checkEmpty;
if (showMask)
frm.ShowDialogWithMask();
else
frm.ShowDialog();
if (frm.IsOK)
{
@ -262,22 +266,26 @@ namespace Sunny.UI
return false;
}
public static bool InputStringDialog(this UIForm form, ref string value, bool checkEmpty = true, string desc = "请输入字符串:")
public static bool InputStringDialog(this UIForm form, ref string value, bool checkEmpty = true,
string desc = "请输入字符串:", bool showMask = false)
{
return InputStringDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost);
return InputStringDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask);
}
public static bool InputStringDialog(this UIPage form, ref string value, bool checkEmpty = true, string desc = "请输入字符串:")
public static bool InputStringDialog(this UIPage form, ref string value, bool checkEmpty = true,
string desc = "请输入字符串:", bool showMask = false)
{
return InputStringDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost);
return InputStringDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask);
}
public static bool InputStringDialog(this Form form, ref string value, bool checkEmpty = true, string desc = "请输入字符串:", UIStyle style = UIStyle.Blue)
public static bool InputStringDialog(this Form form, ref string value, bool checkEmpty = true,
string desc = "请输入字符串:", UIStyle style = UIStyle.Blue, bool showMask = false)
{
return InputStringDialog(ref value, checkEmpty, desc, style, form != null && form.TopMost);
return InputStringDialog(ref value, checkEmpty, desc, style, form != null && form.TopMost, showMask);
}
public static bool InputPasswordDialog(ref string value, bool checkEmpty = true, string desc = "请输入密码:", UIStyle style = UIStyle.Blue, bool topMost = false)
public static bool InputPasswordDialog(ref string value, bool checkEmpty = true,
string desc = "请输入密码:", UIStyle style = UIStyle.Blue, bool topMost = false, bool showMask = false)
{
UIInputForm frm = new UIInputForm();
frm.TopMost = topMost;
@ -286,6 +294,9 @@ namespace Sunny.UI
frm.Label.Text = desc;
frm.Editor.PasswordChar = '*';
frm.CheckInputEmpty = checkEmpty;
if (showMask)
frm.ShowDialogWithMask();
else
frm.ShowDialog();
if (frm.IsOK)
{
@ -296,22 +307,26 @@ namespace Sunny.UI
return false;
}
public static bool InputPasswordDialog(this UIForm form, ref string value, bool checkEmpty = true, string desc = "请输入密码:")
public static bool InputPasswordDialog(this UIForm form, ref string value, bool checkEmpty = true,
string desc = "请输入密码:", bool showMask = false)
{
return InputPasswordDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost);
return InputPasswordDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask);
}
public static bool InputPasswordDialog(this UIPage form, ref string value, bool checkEmpty = true, string desc = "请输入密码:")
public static bool InputPasswordDialog(this UIPage form, ref string value, bool checkEmpty = true,
string desc = "请输入密码:", bool showMask = false)
{
return InputPasswordDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost);
return InputPasswordDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask);
}
public static bool InputPasswordDialog(this Form form, ref string value, bool checkEmpty = true, string desc = "请输入密码:", UIStyle style = UIStyle.Blue)
public static bool InputPasswordDialog(this Form form, ref string value, bool checkEmpty = true,
string desc = "请输入密码:", UIStyle style = UIStyle.Blue, bool showMask = false)
{
return InputPasswordDialog(ref value, checkEmpty, desc, style, form != null && form.TopMost);
return InputPasswordDialog(ref value, checkEmpty, desc, style, form != null && form.TopMost, showMask);
}
public static bool InputIntegerDialog(ref int value, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = false)
public static bool InputIntegerDialog(ref int value, bool checkEmpty = true,
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = false, bool showMask = false)
{
UIInputForm frm = new UIInputForm();
frm.TopMost = topMost;
@ -321,6 +336,9 @@ namespace Sunny.UI
frm.Text = UILocalize.InputTitle;
frm.Label.Text = desc;
frm.CheckInputEmpty = checkEmpty;
if (showMask)
frm.ShowDialogWithMask();
else
frm.ShowDialog();
if (frm.IsOK)
{
@ -331,7 +349,8 @@ namespace Sunny.UI
return false;
}
public static bool InputIntegerDialog(ref int value, int minimum, int maximum, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = false)
public static bool InputIntegerDialog(ref int value, int minimum, int maximum, bool checkEmpty = true,
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = false, bool showMask = false)
{
UIInputForm frm = new UIInputForm();
frm.TopMost = topMost;
@ -346,6 +365,9 @@ namespace Sunny.UI
frm.Editor.Maximum = maximum;
frm.Editor.HasMaximum = true;
frm.Editor.HasMinimum = true;
if (showMask)
frm.ShowDialogWithMask();
else
frm.ShowDialog();
if (frm.IsOK)
{
@ -356,37 +378,44 @@ namespace Sunny.UI
return false;
}
public static bool InputIntegerDialog(this UIForm form, ref int value, bool checkEmpty = true, string desc = "请输入数字:")
public static bool InputIntegerDialog(this UIForm form, ref int value, bool checkEmpty = true,
string desc = "请输入数字:", bool showMask = false)
{
return InputIntegerDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost);
return InputIntegerDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask);
}
public static bool InputIntegerDialog(this UIPage form, ref int value, bool checkEmpty = true, string desc = "请输入数字:")
public static bool InputIntegerDialog(this UIPage form, ref int value, bool checkEmpty = true,
string desc = "请输入数字:", bool showMask = false)
{
return InputIntegerDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost);
return InputIntegerDialog(ref value, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask);
}
public static bool InputIntegerDialog(this Form form, ref int value, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue)
public static bool InputIntegerDialog(this Form form, ref int value, bool checkEmpty = true,
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool showMask = false)
{
return InputIntegerDialog(ref value, checkEmpty, desc, style, form != null && form.TopMost);
return InputIntegerDialog(ref value, checkEmpty, desc, style, form != null && form.TopMost, showMask);
}
public static bool InputIntegerDialog(this UIForm form, ref int value, int minimum, int maximum, bool checkEmpty = true, string desc = "请输入数字:")
public static bool InputIntegerDialog(this UIForm form, ref int value, int minimum, int maximum, bool checkEmpty = true,
string desc = "请输入数字:", bool showMask = false)
{
return InputIntegerDialog(ref value, minimum, maximum, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost);
return InputIntegerDialog(ref value, minimum, maximum, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask);
}
public static bool InputIntegerDialog(this UIPage form, ref int value, int minimum, int maximum, bool checkEmpty = true, string desc = "请输入数字:")
public static bool InputIntegerDialog(this UIPage form, ref int value, int minimum, int maximum, bool checkEmpty = true,
string desc = "请输入数字:", bool showMask = false)
{
return InputIntegerDialog(ref value, minimum, maximum, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost);
return InputIntegerDialog(ref value, minimum, maximum, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask);
}
public static bool InputIntegerDialog(this Form form, ref int value, int minimum, int maximum, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue)
public static bool InputIntegerDialog(this Form form, ref int value, int minimum, int maximum, bool checkEmpty = true,
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool showMask = false)
{
return InputIntegerDialog(ref value, minimum, maximum, checkEmpty, desc, style, form != null && form.TopMost);
return InputIntegerDialog(ref value, minimum, maximum, checkEmpty, desc, style, form != null && form.TopMost, showMask);
}
public static bool InputDoubleDialog(ref double value, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = false)
public static bool InputDoubleDialog(ref double value, int decimals = 2, bool checkEmpty = true,
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = false, bool showMask = false)
{
UIInputForm frm = new UIInputForm();
frm.TopMost = topMost;
@ -397,6 +426,9 @@ namespace Sunny.UI
frm.Text = UILocalize.InputTitle;
frm.Label.Text = desc;
frm.CheckInputEmpty = checkEmpty;
if (showMask)
frm.ShowDialogWithMask();
else
frm.ShowDialog();
if (frm.IsOK)
{
@ -407,7 +439,8 @@ namespace Sunny.UI
return false;
}
public static bool InputDoubleDialog(ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = false)
public static bool InputDoubleDialog(ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true,
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool topMost = false, bool showMask = false)
{
UIInputForm frm = new UIInputForm();
frm.TopMost = topMost;
@ -422,6 +455,9 @@ namespace Sunny.UI
frm.Editor.Maximum = maximum;
frm.Editor.HasMaximum = true;
frm.Editor.HasMinimum = true;
if (showMask)
frm.ShowDialogWithMask();
else
frm.ShowDialog();
if (frm.IsOK)
{
@ -432,34 +468,40 @@ namespace Sunny.UI
return false;
}
public static bool InputDoubleDialog(this UIForm form, ref double value, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:")
public static bool InputDoubleDialog(this UIForm form, ref double value, int decimals = 2, bool checkEmpty = true,
string desc = "请输入数字:", bool showMask = false)
{
return InputDoubleDialog(ref value, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost);
return InputDoubleDialog(ref value, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask);
}
public static bool InputDoubleDialog(this UIPage form, ref double value, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:")
public static bool InputDoubleDialog(this UIPage form, ref double value, int decimals = 2, bool checkEmpty = true,
string desc = "请输入数字:", bool showMask = false)
{
return InputDoubleDialog(ref value, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost);
return InputDoubleDialog(ref value, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask);
}
public static bool InputDoubleDialog(this Form form, ref double value, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue)
public static bool InputDoubleDialog(this Form form, ref double value, int decimals = 2, bool checkEmpty = true,
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool showMask = false)
{
return InputDoubleDialog(ref value, decimals, checkEmpty, desc, style, form != null && form.TopMost);
return InputDoubleDialog(ref value, decimals, checkEmpty, desc, style, form != null && form.TopMost, showMask);
}
public static bool InputDoubleDialog(this UIForm form, ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:")
public static bool InputDoubleDialog(this UIForm form, ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true,
string desc = "请输入数字:", bool showMask = false)
{
return InputDoubleDialog(ref value, minimum, maximum, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost);
return InputDoubleDialog(ref value, minimum, maximum, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask);
}
public static bool InputDoubleDialog(this UIPage form, ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:")
public static bool InputDoubleDialog(this UIPage form, ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true,
string desc = "请输入数字:", bool showMask = false)
{
return InputDoubleDialog(ref value, minimum, maximum, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost);
return InputDoubleDialog(ref value, minimum, maximum, decimals, checkEmpty, desc, form != null ? form.Style : UIStyle.Blue, form != null && form.TopMost, showMask);
}
public static bool InputDoubleDialog(this Form form, ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true, string desc = "请输入数字:", UIStyle style = UIStyle.Blue)
public static bool InputDoubleDialog(this Form form, ref double value, double minimum, double maximum, int decimals = 2, bool checkEmpty = true,
string desc = "请输入数字:", UIStyle style = UIStyle.Blue, bool showMask = false)
{
return InputDoubleDialog(ref value, minimum, maximum, decimals, checkEmpty, desc, style, form != null && form.TopMost);
return InputDoubleDialog(ref value, minimum, maximum, decimals, checkEmpty, desc, style, form != null && form.TopMost, showMask);
}
}