From 6543a103a4cc591bd8e12ba9ebcb33746ee04457 Mon Sep 17 00:00:00 2001 From: Sunny Date: Mon, 9 Sep 2024 15:47:06 +0800 Subject: [PATCH] =?UTF-8?q?*=20UICheckBoxGroup:=202024-09-09:=20V3.7.0=20?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E8=AE=A1=E7=AE=97=E8=8A=82=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E7=9A=84=E6=96=B9=E6=B3=95=EF=BC=8C=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9A#IAPY94=20*=20UIRadioButtonGroup:=20?= =?UTF-8?q?2024-09-09:=20V3.7.0=20=E6=9B=B4=E6=94=B9=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E4=BD=8D=E7=BD=AE=E7=9A=84=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E9=97=AE=E9=A2=98=EF=BC=9A#IAPY94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UICheckBoxGroup.cs | 31 +++++++++++++++++++++----- SunnyUI/Controls/UIRadioButtonGroup.cs | 31 +++++++++++++++++++++----- SunnyUI/Controls/UITextBox.cs | 2 +- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/SunnyUI/Controls/UICheckBoxGroup.cs b/SunnyUI/Controls/UICheckBoxGroup.cs index f7f6e5c6..c0e223c2 100644 --- a/SunnyUI/Controls/UICheckBoxGroup.cs +++ b/SunnyUI/Controls/UICheckBoxGroup.cs @@ -26,6 +26,7 @@ * 2023-06-27: V3.3.9 内置条目关联值由Tag改为TagString * 2023-11-07: V3.5.2 重写UICheckBoxGroup * 2023-12-04: V3.6.1 增加属性可修改图标大小 + * 2024-09-09: V3.7.0 更改计算节点位置的方法,解决问题:#IAPY94 ******************************************************************************/ using System; @@ -73,6 +74,7 @@ namespace Sunny.UI private void Items_CountChange(object sender, EventArgs e) { + InitRects(); Invalidate(); } @@ -178,6 +180,25 @@ namespace Sunny.UI } } + private void InitRects() + { + int startX = StartPos.X; + int startY = TitleTop + StartPos.Y; + for (int i = 0; i < Items.Count; i++) + { + string text = Items[i].ToString(); + int rowIndex = i / ColumnCount; + int columnIndex = i % ColumnCount; + int left = startX + ItemSize.Width * columnIndex + ColumnInterval * columnIndex; + int top = startY + ItemSize.Height * rowIndex + RowInterval * rowIndex; + Rectangle rect = new Rectangle(left, top, ItemSize.Width, ItemSize.Height); + if (CheckBoxRects.NotContainsKey(i)) + CheckBoxRects.Add(i, rect); + else + CheckBoxRects[i] = rect; + } + } + /// /// 重载绘图 /// @@ -203,11 +224,6 @@ namespace Sunny.UI int left = startX + ItemSize.Width * columnIndex + ColumnInterval * columnIndex; int top = startY + ItemSize.Height * rowIndex + RowInterval * rowIndex; Rectangle rect = new Rectangle(left, top, ItemSize.Width, ItemSize.Height); - if (CheckBoxRects.NotContainsKey(i)) - CheckBoxRects.Add(i, rect); - else - CheckBoxRects[i] = rect; - int ImageSize = CheckBoxSize; //图标 @@ -382,6 +398,7 @@ namespace Sunny.UI set { columnCount = value; + InitRects(); Invalidate(); } } @@ -399,6 +416,7 @@ namespace Sunny.UI set { _itemSize = value; + InitRects(); Invalidate(); } } @@ -416,6 +434,7 @@ namespace Sunny.UI set { startPos = value; + InitRects(); Invalidate(); } } @@ -434,6 +453,7 @@ namespace Sunny.UI set { columnInterval = value; + InitRects(); Invalidate(); } } @@ -451,6 +471,7 @@ namespace Sunny.UI set { rowInterval = value; + InitRects(); Invalidate(); } } diff --git a/SunnyUI/Controls/UIRadioButtonGroup.cs b/SunnyUI/Controls/UIRadioButtonGroup.cs index 17d61bb7..dd6f94dc 100644 --- a/SunnyUI/Controls/UIRadioButtonGroup.cs +++ b/SunnyUI/Controls/UIRadioButtonGroup.cs @@ -25,6 +25,7 @@ * 2023-06-27: V3.3.9 内置条目关联值由Tag改为TagString * 2023-11-09: V3.5.2 重写UIRadioButtonGroup * 2023-12-04: V3.6.1 增加属性可修改图标大小 + * 2024-09-09: V3.7.0 更改计算节点位置的方法,解决问题:#IAPY94 ******************************************************************************/ using System; @@ -84,6 +85,7 @@ namespace Sunny.UI private void Items_CountChange(object sender, EventArgs e) { + InitRects(); Invalidate(); } @@ -104,6 +106,25 @@ namespace Sunny.UI private readonly UIObjectCollection items = new UIObjectCollection(); + private void InitRects() + { + int startX = StartPos.X; + int startY = TitleTop + StartPos.Y; + for (int i = 0; i < Items.Count; i++) + { + string text = Items[i].ToString(); + int rowIndex = i / ColumnCount; + int columnIndex = i % ColumnCount; + int left = startX + ItemSize.Width * columnIndex + ColumnInterval * columnIndex; + int top = startY + ItemSize.Height * rowIndex + RowInterval * rowIndex; + Rectangle rect = new Rectangle(left, top, ItemSize.Width, ItemSize.Height); + if (CheckBoxRects.NotContainsKey(i)) + CheckBoxRects.Add(i, rect); + else + CheckBoxRects[i] = rect; + } + } + /// /// 重载绘图 /// @@ -130,11 +151,6 @@ namespace Sunny.UI int left = startX + ItemSize.Width * columnIndex + ColumnInterval * columnIndex; int top = startY + ItemSize.Height * rowIndex + RowInterval * rowIndex; Rectangle rect = new Rectangle(left, top, ItemSize.Width, ItemSize.Height); - if (CheckBoxRects.NotContainsKey(i)) - CheckBoxRects.Add(i, rect); - else - CheckBoxRects[i] = rect; - int ImageSize = RadioButtonSize; //图标 @@ -267,6 +283,7 @@ namespace Sunny.UI set { columnCount = value; + InitRects(); Invalidate(); } } @@ -281,6 +298,7 @@ namespace Sunny.UI set { itemSize = value; + InitRects(); Invalidate(); } } @@ -295,6 +313,7 @@ namespace Sunny.UI set { startPos = value; + InitRects(); Invalidate(); } } @@ -309,6 +328,7 @@ namespace Sunny.UI set { columnInterval = value; + InitRects(); Invalidate(); } } @@ -323,6 +343,7 @@ namespace Sunny.UI set { rowInterval = value; + InitRects(); Invalidate(); } } diff --git a/SunnyUI/Controls/UITextBox.cs b/SunnyUI/Controls/UITextBox.cs index e4674fff..c01c9d51 100644 --- a/SunnyUI/Controls/UITextBox.cs +++ b/SunnyUI/Controls/UITextBox.cs @@ -443,7 +443,7 @@ namespace Sunny.UI } [Browsable(false)] - public TextBox TextBox => edit; + public UIEdit TextBox => edit; private void Edit_Leave(object sender, EventArgs e) {