* UITextBox: 调整Radius时,自动调整文本框的位置

This commit is contained in:
Sunny 2024-01-13 11:35:46 +08:00
parent 989645ec97
commit 61ea69f2ff

View File

@ -58,6 +58,7 @@
* 2023-12-18: V3.6.2 * 2023-12-18: V3.6.2
* 2023-12-18: V3.6.2 Tips小红点的位置 * 2023-12-18: V3.6.2 Tips小红点的位置
* 2023-12-25: V3.6.2 Text的属性编辑器 * 2023-12-25: V3.6.2 Text的属性编辑器
* 2024-01-13: V3.6.3 Radius时
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -705,7 +706,11 @@ namespace Sunny.UI
} }
} }
//private bool NoNeedChange = false; protected override void OnRadiusChanged(int value)
{
base.OnRadiusChanged(value);
SizeChange();
}
private void SizeChange() private void SizeChange()
{ {
@ -728,40 +733,44 @@ namespace Sunny.UI
edit.Top = (Height - edit.Height) / 2 + 1; edit.Top = (Height - edit.Height) / 2 + 1;
} }
int added = Radius <= 5 ? 0 : (Radius - 5) / 2;
if (icon == null && Symbol == 0) if (icon == null && Symbol == 0)
{ {
edit.Left = 4; edit.Left = 4;
edit.Width = Width - 8; edit.Width = Width - 8;
edit.Left = edit.Left + added;
edit.Width = edit.Width - added * 2;
} }
else else
{ {
if (icon != null) if (icon != null)
{ {
edit.Left = 4 + iconSize; edit.Left = 4 + iconSize;
edit.Width = Width - 8 - iconSize; edit.Width = Width - 8 - iconSize - added;
} }
else if (Symbol > 0) else if (Symbol > 0)
{ {
edit.Left = 4 + SymbolSize; edit.Left = 4 + SymbolSize;
edit.Width = Width - 8 - SymbolSize; edit.Width = Width - 8 - SymbolSize - added;
} }
} }
btn.Left = Width - 2 - ButtonWidth; btn.Left = Width - 2 - ButtonWidth - added;
btn.Top = 2; btn.Top = 2;
btn.Height = Height - 4; btn.Height = Height - 4;
if (ShowButton) if (ShowButton)
{ {
edit.Width = edit.Width - btn.Width - 3; edit.Width = edit.Width - btn.Width - 3 - added;
} }
if (tipsBtn != null) if (tipsBtn != null)
{ {
if (ShowButton) if (ShowButton)
tipsBtn.Location = new System.Drawing.Point(Width - btn.Width - 10, 2); tipsBtn.Location = new System.Drawing.Point(Width - btn.Width - 10 - added, 2);
else else
tipsBtn.Location = new System.Drawing.Point(Width - 8, 2); tipsBtn.Location = new System.Drawing.Point(Width - 8 - added, 2);
} }
} }
else else