From 073c2dbf0bc45d240b139e6754777408e987ec01 Mon Sep 17 00:00:00 2001 From: Sunny Date: Tue, 27 Aug 2024 10:12:05 +0800 Subject: [PATCH] =?UTF-8?q?*=20UIIntegerUpDown:=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=A1=86=E5=AD=97=E4=BD=93=E4=B8=8E=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=AD=97=E4=BD=93=E4=B8=80=E8=87=B4=20*=20UIDoubleUpD?= =?UTF-8?q?own:=20=E4=BF=AE=E6=94=B9=E7=BC=96=E8=BE=91=E6=A1=86=E5=AD=97?= =?UTF-8?q?=E4=BD=93=E4=B8=8E=E6=98=BE=E7=A4=BA=E5=AD=97=E4=BD=93=E4=B8=80?= =?UTF-8?q?=E8=87=B4=20*=20UITextBox:=20AutoSize=E6=97=B6=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E5=AD=97=E4=BD=93=E8=87=AA=E5=8A=A8=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UIDoubleUpDown.cs | 2 ++ SunnyUI/Controls/UIIntegerUpDown.cs | 2 ++ SunnyUI/Controls/UITextBox.cs | 30 +++++++++++++++++++++-------- SunnyUI/Forms/UIFormHelper.cs | 1 + 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/SunnyUI/Controls/UIDoubleUpDown.cs b/SunnyUI/Controls/UIDoubleUpDown.cs index 5e0afffa..fd1f7157 100644 --- a/SunnyUI/Controls/UIDoubleUpDown.cs +++ b/SunnyUI/Controls/UIDoubleUpDown.cs @@ -30,6 +30,7 @@ * 2023-01-28: V3.3.1 修改文本框数据输入数据变更事件为MouseLeave * 2023-03-24: V3.3.3 删除ForbidInput属性,使用Inputable属性 * 2023-12-28: V3.6.2 修复设置Style时按钮颜色不一致 + * 2024-08-27: V3.6.9 修改编辑框字体与显示字体一致 ******************************************************************************/ using System; @@ -204,6 +205,7 @@ namespace Sunny.UI if (!Inputable) return; edit.Left = 1; + edit.Font = pnlValue.Font; edit.Top = (pnlValue.Height - edit.Height) / 2; edit.Width = pnlValue.Width - 2; pnlColor = pnlValue.FillColor; diff --git a/SunnyUI/Controls/UIIntegerUpDown.cs b/SunnyUI/Controls/UIIntegerUpDown.cs index ac97ddbb..02c929ce 100644 --- a/SunnyUI/Controls/UIIntegerUpDown.cs +++ b/SunnyUI/Controls/UIIntegerUpDown.cs @@ -29,6 +29,7 @@ * 2023-01-28: V3.3.1 修改文本框数据输入数据变更事件为MouseLeave * 2023-03-24: V3.3.3 删除ForbidInput属性,使用Inputable属性 * 2023-12-28: V3.6.2 修复设置Style时按钮颜色不一致 + * 2024-08-27: V3.6.9 修改编辑框字体与显示字体一致 ******************************************************************************/ using System; @@ -187,6 +188,7 @@ namespace Sunny.UI if (!Inputable) return; edit.Left = 1; + edit.Font = pnlValue.Font; edit.Top = (pnlValue.Height - edit.Height) / 2; edit.Width = pnlValue.Width - 2; pnlColor = pnlValue.FillColor; diff --git a/SunnyUI/Controls/UITextBox.cs b/SunnyUI/Controls/UITextBox.cs index 71b0c785..e4674fff 100644 --- a/SunnyUI/Controls/UITextBox.cs +++ b/SunnyUI/Controls/UITextBox.cs @@ -62,6 +62,7 @@ * 2024-06-11: V3.6.6 调整为可继承 * 2024-08-12: V3.6.8 解决原生控件字体在微软雅黑时,显示不完整的问题 * 2024-08-26: V3.6.9 修复微软雅黑字体显示不完整的问题 + * 2024-08-27: V3.6.9 AutoSize时根据字体自动调整控件高度 ******************************************************************************/ using System; @@ -90,7 +91,7 @@ namespace Sunny.UI ShowText = false; MinimumSize = new Size(1, 16); - edit.AutoSize = true; + edit.AutoSize = false; edit.Top = (Height - edit.Height) / 2; edit.Left = 4; edit.Width = Width - 8; @@ -188,6 +189,17 @@ namespace Sunny.UI set => edit.TouchPressClick = value; } + private bool _autoSize = false; + public new bool AutoSize + { + get => _autoSize; + set + { + _autoSize = value; + SizeChange(); + } + } + private UIButton tipsBtn; public void SetTipsText(ToolTip toolTip, string text) { @@ -732,14 +744,16 @@ namespace Sunny.UI if (!multiline) { - //if (Height < edit.Height + RectSize * 2 + 2) - //{ - // NoNeedChange = true; - // Height = edit.Height + RectSize * 2 + 2; - // edit.Top = (Height - edit.Height) / 2; - // NoNeedChange = false; - //} + //单行显示 + //AutoSize自动设置高度 + if (Dock == DockStyle.None && AutoSize) + { + if (Height != edit.Height + 5) + Height = edit.Height + 5; + } + + //根据字体大小编辑框垂直居中 if (edit.Top != (Height - edit.Height) / 2 + 1) { edit.Top = (Height - edit.Height) / 2 + 1; diff --git a/SunnyUI/Forms/UIFormHelper.cs b/SunnyUI/Forms/UIFormHelper.cs index a07aa4a7..9757e111 100644 --- a/SunnyUI/Forms/UIFormHelper.cs +++ b/SunnyUI/Forms/UIFormHelper.cs @@ -32,6 +32,7 @@ * 2024-05-30: V3.6.6 修复弹窗标题显示错误 * 2024-07-30: V3.6.8 弹窗默认修改为以当前窗体居中,showMask=true或者centerParent=false时以屏幕居中 * 2024-08-09: V3.6.8 重构弹窗,窗体扩展打开默认以窗体居中,取消TopMost参数,默认为true + * 2024-08-26: V3.6.9 修复一处ShowAskDialog2报错 #IAMA5A ******************************************************************************/ using System;