From a1923f32c61ff96fac69d1418b3d49803fa69223 Mon Sep 17 00:00:00 2001 From: Sunny Date: Mon, 4 Dec 2023 09:38:50 +0800 Subject: [PATCH] =?UTF-8?q?*=20UICheckBox:=20=E5=A2=9E=E5=8A=A0=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=8F=AF=E4=BF=AE=E6=94=B9=E5=9B=BE=E6=A0=87=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=20*=20UICheckBoxGroup:=20=E5=A2=9E=E5=8A=A0=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=8F=AF=E4=BF=AE=E6=94=B9=E5=9B=BE=E6=A0=87=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=20*=20UIRadioButton:=20=E5=A2=9E=E5=8A=A0=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=8F=AF=E4=BF=AE=E6=94=B9=E5=9B=BE=E6=A0=87=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=20*=20UIRadioButtonGroup:=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=8F=AF=E4=BF=AE=E6=94=B9=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UICheckBox.cs | 22 +++++----------------- SunnyUI/Controls/UICheckBoxGroup.cs | 3 ++- SunnyUI/Controls/UIRadioButton.cs | 17 +++++------------ SunnyUI/Controls/UIRadioButtonGroup.cs | 3 ++- 4 files changed, 14 insertions(+), 31 deletions(-) diff --git a/SunnyUI/Controls/UICheckBox.cs b/SunnyUI/Controls/UICheckBox.cs index b2780ce3..755bf4b0 100644 --- a/SunnyUI/Controls/UICheckBox.cs +++ b/SunnyUI/Controls/UICheckBox.cs @@ -23,6 +23,7 @@ * 2022-03-19: V3.1.1 重构主题配色 * 2023-05-12: V3.3.6 重构DrawString函数 * 2023-11-07: V3.5.2 增加修改图标大小 + * 2023-12-04: V3.6.1 增加属性可修改图标大小 ******************************************************************************/ using System; @@ -66,8 +67,8 @@ namespace Sunny.UI if (AutoSize && Dock == DockStyle.None) { Size sf = TextRenderer.MeasureText(Text, Font); - int w = sf.Width + ImageSize + 3; - int h = Math.Max(ImageSize, sf.Height) + 2; + int w = sf.Width + CheckBoxSize + 3; + int h = Math.Max(CheckBoxSize, sf.Height) + 2; if (Width != w) Width = w; if (Height != h) Height = h; } @@ -107,20 +108,8 @@ namespace Sunny.UI [DefaultValue(16)] [Description("图标大小"), Category("SunnyUI")] - [Browsable(false)] + [Browsable(true)] public int CheckBoxSize - { - get => ImageSize; - set => ImageSize = value; - } - - /// - /// 图标大小 - /// - [DefaultValue(16)] - [Description("图标大小"), Category("SunnyUI")] - [Browsable(false)] - public int ImageSize { get => _imageSize; set @@ -202,12 +191,11 @@ namespace Sunny.UI /// 绘图路径 protected override void OnPaintFill(Graphics g, GraphicsPath path) { + int ImageSize = CheckBoxSize; //图标 float top = (Height - ImageSize) / 2.0f; float left = Text.IsValid() ? ImageInterval : (Width - ImageSize) / 2.0f; - Color color = Enabled ? fillColor : foreDisableColor; - if (Checked) { g.FillRoundRectangle(color, new Rectangle((int)left, (int)top, ImageSize, ImageSize), 1); diff --git a/SunnyUI/Controls/UICheckBoxGroup.cs b/SunnyUI/Controls/UICheckBoxGroup.cs index 6eecf55f..88d5befe 100644 --- a/SunnyUI/Controls/UICheckBoxGroup.cs +++ b/SunnyUI/Controls/UICheckBoxGroup.cs @@ -25,6 +25,7 @@ * 2023-04-19: V3.3.5 设置选择项ForeColor * 2023-06-27: V3.3.9 内置条目关联值由Tag改为TagString * 2023-11-07: V3.5.2 重写UICheckBoxGroup + * 2023-12-04: V3.6.1 增加属性可修改图标大小 ******************************************************************************/ using System; @@ -97,7 +98,7 @@ namespace Sunny.UI [DefaultValue(16)] [Description("图标大小"), Category("SunnyUI")] - [Browsable(false)] + [Browsable(true)] public int CheckBoxSize { get => _imageSize; diff --git a/SunnyUI/Controls/UIRadioButton.cs b/SunnyUI/Controls/UIRadioButton.cs index e588f27f..9c39f13b 100644 --- a/SunnyUI/Controls/UIRadioButton.cs +++ b/SunnyUI/Controls/UIRadioButton.cs @@ -24,6 +24,7 @@ * 2022-12-21: V3.3.0 修复CheckedChanged事件 * 2023-05-12: V3.3.6 重构DrawString函数 * 2023-11-07: V3.5.2 增加修改图标大小 + * 2023-12-04: V3.6.1 增加属性可修改图标大小 ******************************************************************************/ using System; @@ -67,8 +68,8 @@ namespace Sunny.UI if (AutoSize && Dock == DockStyle.None) { Size sf = TextRenderer.MeasureText(Text, Font); - int w = sf.Width + ImageSize + 3; - int h = Math.Max(ImageSize, sf.Height) + 2; + int w = sf.Width + RadioButtonSize + 3; + int h = Math.Max(RadioButtonSize, sf.Height) + 2; if (Width != w) Width = w; if (Height != h) Height = h; } @@ -108,17 +109,8 @@ namespace Sunny.UI [DefaultValue(16)] [Description("图标大小"), Category("SunnyUI")] - [Browsable(false)] + [Browsable(true)] public int RadioButtonSize - { - get => ImageSize; - set => ImageSize = value; - } - - [DefaultValue(16)] - [Description("按钮图片大小"), Category("SunnyUI")] - [Browsable(false)] - public int ImageSize { get => _imageSize; set @@ -201,6 +193,7 @@ namespace Sunny.UI /// 绘图路径 protected override void OnPaintFill(Graphics g, GraphicsPath path) { + int ImageSize = RadioButtonSize; //图标 float top = (Height - ImageSize) / 2.0f; float left = Text.IsValid() ? ImageInterval : (Width - ImageSize) / 2.0f; diff --git a/SunnyUI/Controls/UIRadioButtonGroup.cs b/SunnyUI/Controls/UIRadioButtonGroup.cs index d8f70d91..ab04acd3 100644 --- a/SunnyUI/Controls/UIRadioButtonGroup.cs +++ b/SunnyUI/Controls/UIRadioButtonGroup.cs @@ -24,6 +24,7 @@ * 2023-04-22: V3.3.5 设置选择项ForeColor * 2023-06-27: V3.3.9 内置条目关联值由Tag改为TagString * 2023-11-09: V3.5.2 重写UIRadioButtonGroup + * 2023-12-04: V3.6.1 增加属性可修改图标大小 ******************************************************************************/ using System; @@ -177,7 +178,7 @@ namespace Sunny.UI [DefaultValue(16)] [Description("图标大小"), Category("SunnyUI")] - [Browsable(false)] + [Browsable(true)] public int RadioButtonSize { get => _imageSize;