From d06628903b308fcd7222873d64e1c47815b73123 Mon Sep 17 00:00:00 2001 From: Sunny Date: Thu, 25 Jul 2024 21:37:10 +0800 Subject: [PATCH] =?UTF-8?q?*=20UIDateTimeItem:=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=8D=95=E5=87=BB=E9=80=89=E6=8B=A9=E6=97=A5=E6=9C=9F=E5=90=8E?= =?UTF-8?q?=E7=AB=8B=E5=8D=B3=E5=88=B7=E6=96=B0=EF=BC=8C=E5=8F=8C=E5=87=BB?= =?UTF-8?q?=E5=8F=AF=E9=80=89=E6=8B=A9=E5=B9=B6=E5=85=B3=E9=97=AD=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/DropItem/UIDateTimeItem.cs | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/SunnyUI/Controls/DropItem/UIDateTimeItem.cs b/SunnyUI/Controls/DropItem/UIDateTimeItem.cs index cafdc06b..e6719c0d 100644 --- a/SunnyUI/Controls/DropItem/UIDateTimeItem.cs +++ b/SunnyUI/Controls/DropItem/UIDateTimeItem.cs @@ -21,6 +21,7 @@ * 2020-07-08: V2.2.6 重写下拉窗体,缩短创建时间 * 2023-05-13: V3.3.6 重构DrawString函数 * 2024-07-14: V3.6.7 修改时间界面水平分割线颜色和位置 + * 2024-07-25: V3.6.8 修改单击选择日期后立即刷新,双击可选择并关闭下拉框 ******************************************************************************/ using System; @@ -333,6 +334,7 @@ namespace Sunny.UI p3.MouseClick += p3_MouseClick; p3.MouseLeave += p3_MouseLeave; p3.MouseMove += p3_MouseMove; + p3.MouseDoubleClick += P3_MouseDoubleClick; // // sb // @@ -1352,9 +1354,33 @@ namespace Sunny.UI date = new DateTime(date.Year, date.Month, date.Day, Hour, Minute, Second); DoValueChanged(this, Date); + p3.Invalidate(); //CloseParent(); } + private void P3_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (e.Location.Y <= 30) return; + int width = p3.Width / 7; + int height = (p3.Height - 30) / 6; + int x = e.Location.X / width; + int y = (e.Location.Y - 30) / height; + int id = x + y * 7; + if (id < 0 || id >= 42) return; + date = days[id].Date; + if (ShowToday && e.Location.Y > p3.Height - height && e.Location.X > p3.Width - width * 4) + { + date = DateTime.Now.Date; + DoValueChanged(this, Date); + Close(); + } + + date = new DateTime(date.Year, date.Month, date.Day, Hour, Minute, Second); + DoValueChanged(this, Date); + p3.Invalidate(); + Close(); + } + private void p1_MouseLeave(object sender, EventArgs e) { activeYear = -1;