diff --git a/Bin/net40/SunnyUI.Demo.exe b/Bin/net40/SunnyUI.Demo.exe index 8bf7f4fd..563d3f08 100644 Binary files a/Bin/net40/SunnyUI.Demo.exe and b/Bin/net40/SunnyUI.Demo.exe differ diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll index 75a93320..702cac68 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/SunnyUI.dll b/Bin/net5.0-windows/SunnyUI.dll index 70980966..b6c8b9e8 100644 Binary files a/Bin/net5.0-windows/SunnyUI.dll and b/Bin/net5.0-windows/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/ref/SunnyUI.dll b/Bin/net5.0-windows/ref/SunnyUI.dll index 2a2b566f..3851de24 100644 Binary files a/Bin/net5.0-windows/ref/SunnyUI.dll and b/Bin/net5.0-windows/ref/SunnyUI.dll differ diff --git a/Bin/netcoreapp3.1/SunnyUI.dll b/Bin/netcoreapp3.1/SunnyUI.dll index bd1fe887..df8deee0 100644 Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ diff --git a/SunnyUI/Forms/UIEditForm.cs b/SunnyUI/Forms/UIEditForm.cs index f58e3c85..8213b40c 100644 --- a/SunnyUI/Forms/UIEditForm.cs +++ b/SunnyUI/Forms/UIEditForm.cs @@ -20,6 +20,7 @@ ******************************************************************************/ using System; +using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; @@ -49,9 +50,10 @@ namespace Sunny.UI if (option == null || option.Infos.Count == 0) return; base.Text = option.Text; - int tabIndex = 0; int top = 55; + List ctrls = new List(); + if (option.AutoLabelWidth) { float size = 0; @@ -86,8 +88,21 @@ namespace Sunny.UI edit.Top = top; edit.Text = info.Value.ToString(); edit.Parent = this; - edit.TabIndex = tabIndex; edit.Name = "Edit_" + info.DataPropertyName; + ctrls.Add(edit); + } + + if (info.EditType == EditType.Password) + { + UITextBox edit = new UITextBox(); + edit.Left = option.LabelWidth; + edit.Width = option.ValueWidth; + edit.Top = top; + edit.Text = info.Value.ToString(); + edit.Parent = this; + edit.PasswordChar = '*'; + edit.Name = "Edit_" + info.DataPropertyName; + ctrls.Add(edit); } if (info.EditType == EditType.Integer) @@ -99,8 +114,8 @@ namespace Sunny.UI edit.Top = top; edit.IntValue = info.Value.ToString().ToInt(); edit.Parent = this; - edit.TabIndex = tabIndex; edit.Name = "Edit_" + info.DataPropertyName; + ctrls.Add(edit); } if (info.EditType == EditType.Double) @@ -112,8 +127,8 @@ namespace Sunny.UI edit.Top = top; edit.DoubleValue = info.Value.ToString().ToDouble(); edit.Parent = this; - edit.TabIndex = tabIndex; edit.Name = "Edit_" + info.DataPropertyName; + ctrls.Add(edit); } if (info.EditType == EditType.Date) @@ -124,8 +139,8 @@ namespace Sunny.UI edit.Top = top; edit.Value = (DateTime)info.Value; edit.Parent = this; - edit.TabIndex = tabIndex; edit.Name = "Edit_" + info.DataPropertyName; + ctrls.Add(edit); } if (info.EditType == EditType.DateTime) @@ -136,15 +151,22 @@ namespace Sunny.UI edit.Top = top; edit.Value = (DateTime)info.Value; edit.Parent = this; - edit.TabIndex = tabIndex; edit.Name = "Edit_" + info.DataPropertyName; + ctrls.Add(edit); } top += 29 + 10; - tabIndex++; } + pnlBtm.BringToFront(); Height = top + 10 + 55; + + int tabIndex = 0; + foreach (var ctrl in ctrls) + { + ctrl.TabIndex = tabIndex; + tabIndex++; + } } public object this[string dataPropertyName] @@ -228,7 +250,7 @@ namespace Sunny.UI { foreach (var info in Option.Infos) { - if (info.EditType == EditType.Text) + if (info.EditType == EditType.Text || info.EditType == EditType.Password) { UITextBox edit = this.GetControl("Edit_" + info.DataPropertyName); if (edit == null) continue; diff --git a/SunnyUI/Forms/UIEditFormHelper.cs b/SunnyUI/Forms/UIEditFormHelper.cs index 5e3e1f7a..6cd4de37 100644 --- a/SunnyUI/Forms/UIEditFormHelper.cs +++ b/SunnyUI/Forms/UIEditFormHelper.cs @@ -32,7 +32,8 @@ namespace Sunny.UI Integer, Double, Date, - DateTime + DateTime, + Password } public class EditInfo @@ -85,6 +86,25 @@ namespace Sunny.UI Dictionary.TryAdd(info.DataPropertyName, info); } + public void AddPassword(string dataPropertyName, string text, string value, bool checkEmpty, bool enabled = true) + { + if (Dictionary.ContainsKey(dataPropertyName)) + throw new DuplicateNameException(dataPropertyName + ": 已经存在"); + + EditInfo info = new EditInfo() + { + DataPropertyName = dataPropertyName, + EditType = EditType.Password, + Text = text, + Value = value, + CheckEmpty = checkEmpty, + Enabled = enabled + }; + + Infos.Add(info); + Dictionary.TryAdd(info.DataPropertyName, info); + } + public void AddDouble(string dataPropertyName, string text, double value, bool enabled = true, bool halfWidth = true) { if (Dictionary.ContainsKey(dataPropertyName))