* UIDateTimeItem: 修改单击选择日期后立即刷新,双击可选择并关闭下拉框

This commit is contained in:
Sunny 2024-07-25 21:37:10 +08:00
parent f786f071f0
commit d06628903b

View File

@ -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;