diff --git a/Bin/SunnyUI.dll b/Bin/SunnyUI.dll index 76a8016c..ad892f18 100644 Binary files a/Bin/SunnyUI.dll and b/Bin/SunnyUI.dll differ diff --git a/SunnyUI/Controls/UIAvatar.cs b/SunnyUI/Controls/UIAvatar.cs index b85fc8ca..236c9e36 100644 --- a/SunnyUI/Controls/UIAvatar.cs +++ b/SunnyUI/Controls/UIAvatar.cs @@ -237,6 +237,12 @@ namespace Sunny.UI } } + [DefaultValue(0), Description("水平偏移"), Category("SunnyUI")] + public int OffsetX { get; set; } = 0; + + [DefaultValue(0), Description("垂直偏移"), Category("SunnyUI")] + public int OffsetY { get; set; } = 0; + /// /// OnPaint /// @@ -288,13 +294,13 @@ namespace Sunny.UI if (Icon == UIIcon.Symbol) { - e.Graphics.DrawFontImage(symbol, symbolSize, ForeColor, new Rectangle((Width - avatarSize) / 2 + 1, (Height - avatarSize) / 2 + 1, avatarSize, avatarSize)); + e.Graphics.DrawFontImage(symbol, symbolSize, ForeColor, new Rectangle((Width - avatarSize) / 2 + 1 + OffsetX, (Height - avatarSize) / 2 + 1 + OffsetY, avatarSize, avatarSize)); } if (Icon == UIIcon.Text) { SizeF sf = e.Graphics.MeasureString(Text, Font); - e.Graphics.DrawString(Text, Font, foreColor, 2 + (Width - sf.Width) / 2.0f, (Height - sf.Height) / 2.0f); + e.Graphics.DrawString(Text, Font, foreColor, (Width - sf.Width) / 2.0f + OffsetX, (Height - sf.Height) / 2.0f + 1 + OffsetY); } } } diff --git a/SunnyUI/Controls/UICheckBox.cs b/SunnyUI/Controls/UICheckBox.cs index 1645d260..6fc3974b 100644 --- a/SunnyUI/Controls/UICheckBox.cs +++ b/SunnyUI/Controls/UICheckBox.cs @@ -42,6 +42,33 @@ namespace Sunny.UI foreColor = UIStyles.Blue.CheckBoxForeColor; fillColor = UIStyles.Blue.CheckBoxColor; SetStyle(ControlStyles.StandardDoubleClick, UseDoubleClick); + PaintOther += UICheckBox_PaintOther; ; + } + + private void UICheckBox_PaintOther(object sender, PaintEventArgs e) + { + if (AutoSize) + { + SizeF sf = Text.MeasureString(Font); + int w = (int)sf.Width + ImageSize + 3; + int h = Math.Max(ImageSize, (int)sf.Height) + 2; + if (Width != w) Width = w; + if (Height != h) Height = h; + } + } + + private bool autoSize; + + [Browsable(true)] + [Description("自动大小"), Category("SunnyUI")] + public override bool AutoSize + { + get => autoSize; + set + { + autoSize = value; + UICheckBox_PaintOther(this, null); + } } public delegate void OnValueChanged(object sender, bool value); diff --git a/SunnyUI/Controls/UIControl.cs b/SunnyUI/Controls/UIControl.cs index c2190bba..8b8838b5 100644 --- a/SunnyUI/Controls/UIControl.cs +++ b/SunnyUI/Controls/UIControl.cs @@ -287,7 +287,7 @@ namespace Sunny.UI if (useDoubleClick != value) { useDoubleClick = value; - //SetStyle(ControlStyles.StandardDoubleClick, useDoubleClick); + SetStyle(ControlStyles.StandardDoubleClick, useDoubleClick); //Invalidate(); } } diff --git a/SunnyUI/Controls/UIRadioButton.cs b/SunnyUI/Controls/UIRadioButton.cs index 01f83faf..4e1186bb 100644 --- a/SunnyUI/Controls/UIRadioButton.cs +++ b/SunnyUI/Controls/UIRadioButton.cs @@ -46,6 +46,33 @@ namespace Sunny.UI Size = new Size(150, 29); foreColor = UIStyles.Blue.CheckBoxForeColor; fillColor = UIStyles.Blue.CheckBoxColor; + PaintOther += UIRadioButton_PaintOther; + } + + private void UIRadioButton_PaintOther(object sender, PaintEventArgs e) + { + if (AutoSize) + { + SizeF sf = Text.MeasureString(Font); + int w = (int)sf.Width + ImageSize + 3; + int h = Math.Max(ImageSize, (int)sf.Height) + 2; + if (Width != w) Width = w; + if (Height != h) Height = h; + } + } + + private bool autoSize; + + [Browsable(true)] + [Description("自动大小"), Category("SunnyUI")] + public override bool AutoSize + { + get => autoSize; + set + { + autoSize = value; + UIRadioButton_PaintOther(this, null); + } } [DefaultValue(false)] diff --git a/SunnyUI/Forms/UIEditForm.cs b/SunnyUI/Forms/UIEditForm.cs index 86172af4..3a77fb7c 100644 --- a/SunnyUI/Forms/UIEditForm.cs +++ b/SunnyUI/Forms/UIEditForm.cs @@ -20,6 +20,7 @@ ******************************************************************************/ using System; +using System.ComponentModel; using System.Windows.Forms; namespace Sunny.UI @@ -36,9 +37,28 @@ namespace Sunny.UI public bool IsOK { get; private set; } + [Category("SunnyUI"), Description("确定按钮点击事件")] public event EventHandler ButtonOkClick; + + [Category("SunnyUI"), Description("取消按钮点击事件")] public event EventHandler ButtonCancelClick; + [Description("确定按钮可用状态"), Category("SunnyUI")] + [DefaultValue(true)] + public bool ButtonOKEnabled + { + get => btnOK.Enabled; + set => btnOK.Enabled = value; + } + + [Description("取消按钮可用状态"), Category("SunnyUI")] + [DefaultValue(true)] + public bool ButtonCancelEnabled + { + get => btnCancel.Enabled; + set => btnCancel.Enabled = value; + } + protected void btnOK_Click(object sender, EventArgs e) { if (!CheckData()) @@ -48,7 +68,7 @@ namespace Sunny.UI if (ButtonOkClick != null) { - ButtonOkClick.Invoke(sender,e); + ButtonOkClick.Invoke(sender, e); } else { @@ -62,7 +82,7 @@ namespace Sunny.UI { if (ButtonCancelClick != null) { - ButtonCancelClick.Invoke(sender,e); + ButtonCancelClick.Invoke(sender, e); } else {