From 120dbf215104dd1ed66cdaa636addc38c39aad76 Mon Sep 17 00:00:00 2001 From: Sunny Date: Fri, 29 Nov 2024 10:59:06 +0800 Subject: [PATCH] =?UTF-8?q?*=20UICheckBoxGroup:=20=E4=BF=AE=E5=A4=8DTitleT?= =?UTF-8?q?op=E4=B8=BA0=E6=97=B6=EF=BC=8C=E6=9D=A1=E7=9B=AE=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=94=99=E4=BD=8D=E7=9A=84=E9=97=AE=E9=A2=98=20#IB7ST?= =?UTF-8?q?O=20*=20UIRadioButtonGroup:=20=E4=BF=AE=E5=A4=8DTitleTop?= =?UTF-8?q?=E4=B8=BA0=E6=97=B6=EF=BC=8C=E6=9D=A1=E7=9B=AE=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=94=99=E4=BD=8D=E7=9A=84=E9=97=AE=E9=A2=98=20#IB7ST?= =?UTF-8?q?O?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UICheckBoxGroup.cs | 7 +++++-- SunnyUI/Controls/UIRadioButtonGroup.cs | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/SunnyUI/Controls/UICheckBoxGroup.cs b/SunnyUI/Controls/UICheckBoxGroup.cs index c0e223c2..2abfe76a 100644 --- a/SunnyUI/Controls/UICheckBoxGroup.cs +++ b/SunnyUI/Controls/UICheckBoxGroup.cs @@ -27,6 +27,7 @@ * 2023-11-07: V3.5.2 重写UICheckBoxGroup * 2023-12-04: V3.6.1 增加属性可修改图标大小 * 2024-09-09: V3.7.0 更改计算节点位置的方法,解决问题:#IAPY94 + * 2024-11-29: V3.8.0 修复TitleTop为0时,条目显示错位的问题 #IB7STO ******************************************************************************/ using System; @@ -206,11 +207,13 @@ namespace Sunny.UI protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); + if (TitleTop == 0 && Text.IsValid()) Text = ""; if (Items.Count == 0) return; + InitRects(); - if (activeIndex >= 0 && CheckBoxRects.ContainsKey(activeIndex)) + if (activeIndex >= 0 && CheckBoxRects.TryGetValue(activeIndex, out Rectangle boxRect)) { - e.Graphics.FillRectangle(hoverColor, CheckBoxRects[activeIndex]); + e.Graphics.FillRectangle(hoverColor, boxRect); } int startX = StartPos.X; diff --git a/SunnyUI/Controls/UIRadioButtonGroup.cs b/SunnyUI/Controls/UIRadioButtonGroup.cs index dd6f94dc..a48a86e1 100644 --- a/SunnyUI/Controls/UIRadioButtonGroup.cs +++ b/SunnyUI/Controls/UIRadioButtonGroup.cs @@ -26,6 +26,7 @@ * 2023-11-09: V3.5.2 重写UIRadioButtonGroup * 2023-12-04: V3.6.1 增加属性可修改图标大小 * 2024-09-09: V3.7.0 更改计算节点位置的方法,解决问题:#IAPY94 + * 2024-11-29: V3.8.0 修复TitleTop为0时,条目显示错位的问题 #IB7STO ******************************************************************************/ using System; @@ -132,12 +133,13 @@ namespace Sunny.UI protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); - + if (TitleTop == 0 && Text.IsValid()) Text = ""; if (Items.Count == 0) return; + InitRects(); - if (activeIndex >= 0 && CheckBoxRects.ContainsKey(activeIndex)) + if (activeIndex >= 0 && CheckBoxRects.TryGetValue(activeIndex, out Rectangle boxRect)) { - e.Graphics.FillRectangle(hoverColor, CheckBoxRects[activeIndex]); + e.Graphics.FillRectangle(hoverColor, boxRect); } int startX = StartPos.X;