* UICheckBoxGroup: 2024-09-09: V3.7.0 更改计算节点位置的方法,解决问题:#IAPY94

* UIRadioButtonGroup: 2024-09-09: V3.7.0 更改计算节点位置的方法,解决问题:#IAPY94
This commit is contained in:
Sunny 2024-09-09 15:47:06 +08:00
parent 7fb69265ee
commit 6543a103a4
3 changed files with 53 additions and 11 deletions

View File

@ -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;
}
}
/// <summary>
/// 重载绘图
/// </summary>
@ -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();
}
}

View File

@ -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;
}
}
/// <summary>
/// 重载绘图
/// </summary>
@ -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();
}
}

View File

@ -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)
{