* UICheckBox: 增加属性可修改图标大小

* UICheckBoxGroup: 增加属性可修改图标大小
* UIRadioButton: 增加属性可修改图标大小
* UIRadioButtonGroup: 增加属性可修改图标大小
This commit is contained in:
Sunny 2023-12-04 09:38:50 +08:00
parent 5ca057ab6c
commit a1923f32c6
4 changed files with 14 additions and 31 deletions

View File

@ -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;
}
/// <summary>
/// 图标大小
/// </summary>
[DefaultValue(16)]
[Description("图标大小"), Category("SunnyUI")]
[Browsable(false)]
public int ImageSize
{
get => _imageSize;
set
@ -202,12 +191,11 @@ namespace Sunny.UI
/// <param name="path">绘图路径</param>
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);

View File

@ -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;

View File

@ -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
/// <param name="path">绘图路径</param>
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;

View File

@ -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;