* UIDatePicker,UITimePicker,UIDateTimePicker:可编辑输入,日期范围控制
This commit is contained in:
parent
49416a6e96
commit
a13f3a96de
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
BIN
Bin/SunnyUI.pdb
BIN
Bin/SunnyUI.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
3
SunnyUI.Demo/Controls/FCombobox.Designer.cs
generated
3
SunnyUI.Demo/Controls/FCombobox.Designer.cs
generated
@ -69,7 +69,6 @@
|
||||
//
|
||||
// uiDatetimePicker1
|
||||
//
|
||||
this.uiDatetimePicker1.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList;
|
||||
this.uiDatetimePicker1.FillColor = System.Drawing.Color.White;
|
||||
this.uiDatetimePicker1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiDatetimePicker1.Location = new System.Drawing.Point(388, 136);
|
||||
@ -124,7 +123,6 @@
|
||||
//
|
||||
// uiTimePicker1
|
||||
//
|
||||
this.uiTimePicker1.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList;
|
||||
this.uiTimePicker1.FillColor = System.Drawing.Color.White;
|
||||
this.uiTimePicker1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiTimePicker1.Location = new System.Drawing.Point(188, 136);
|
||||
@ -165,7 +163,6 @@
|
||||
//
|
||||
// uiDatePicker1
|
||||
//
|
||||
this.uiDatePicker1.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList;
|
||||
this.uiDatePicker1.FillColor = System.Drawing.Color.White;
|
||||
this.uiDatePicker1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.uiDatePicker1.Location = new System.Drawing.Point(30, 136);
|
||||
|
@ -588,11 +588,8 @@ namespace Sunny.UI
|
||||
int x = e.Location.X / width;
|
||||
int y = e.Location.Y / height;
|
||||
int iy = x + y * 4;
|
||||
if (iy<0 ||iy>=12) return;
|
||||
if (years[iy] > 9999)
|
||||
Year = 9999;
|
||||
else
|
||||
Year = years[iy];
|
||||
if (iy < 0 || iy >= 12) return;
|
||||
Year = years[iy] > 9999 ? 9999 : years[iy];
|
||||
activeYear = -1;
|
||||
TabControl.SelectedTab = tabPage2;
|
||||
p2.Invalidate();
|
||||
@ -614,7 +611,7 @@ namespace Sunny.UI
|
||||
|
||||
e.Graphics.DrawLine(Color.DarkGray, 8, 26, 268, 26);
|
||||
|
||||
bool maxDrawed = false;
|
||||
bool maxDrawer = false;
|
||||
for (int i = 0; i < 42; i++)
|
||||
{
|
||||
int left = width * (i % 7);
|
||||
@ -624,14 +621,14 @@ namespace Sunny.UI
|
||||
Color color = (days[i].Month == Month) ? ForeColor : Color.DarkGray;
|
||||
color = (days[i].DateString() == date.DateString()) ? UIColor.Blue : color;
|
||||
|
||||
if (!maxDrawed)
|
||||
if (!maxDrawer)
|
||||
{
|
||||
e.Graphics.DrawString(days[i].Day.ToString(), Font, i == activeDay ? UIColor.Blue : color, left + (width - sf.Width) / 2, top + 30 + (height - sf.Height) / 2);
|
||||
}
|
||||
|
||||
if (!maxDrawed && days[i].Date.Equals(DateTime.MaxValue.Date))
|
||||
if (!maxDrawer && days[i].Date.Equals(DateTime.MaxValue.Date))
|
||||
{
|
||||
maxDrawed = true;
|
||||
maxDrawer = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -659,7 +656,6 @@ namespace Sunny.UI
|
||||
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;
|
||||
DoValueChanged(this, Date);
|
||||
|
@ -119,7 +119,7 @@ namespace Sunny.UI
|
||||
this.TopPanel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.TopPanel.Name = "TopPanel";
|
||||
this.TopPanel.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
|
||||
this.TopPanel.RectSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)(((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Top)
|
||||
this.TopPanel.RectSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)(((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Top)
|
||||
| System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)));
|
||||
this.TopPanel.Size = new System.Drawing.Size(284, 31);
|
||||
this.TopPanel.Style = Sunny.UI.UIStyle.Custom;
|
||||
@ -775,11 +775,31 @@ namespace Sunny.UI
|
||||
DateTime dt = new DateTime(iYear, iMonth, 1);
|
||||
int week = (int)dt.DayOfWeek;
|
||||
|
||||
bool maxToEnd = false;
|
||||
DateTime dtBegin = week == 0 ? dt.AddDays(-7) : dt.AddDays(-week);
|
||||
for (int i = 1; i <= 42; i++)
|
||||
{
|
||||
DateTime lblDate = dtBegin.AddDays(i - 1);
|
||||
days.Add(lblDate);
|
||||
try
|
||||
{
|
||||
if (!maxToEnd && dtBegin.AddDays(i - 1).Date.Equals(DateTime.MaxValue.Date))
|
||||
{
|
||||
maxToEnd = true;
|
||||
}
|
||||
|
||||
if (!maxToEnd)
|
||||
{
|
||||
DateTime lblDate = dtBegin.AddDays(i - 1);
|
||||
days.Add(lblDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
days.Add(DateTime.MaxValue.Date);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
|
||||
p3.Invalidate();
|
||||
@ -840,6 +860,7 @@ namespace Sunny.UI
|
||||
private void b3_Click(object sender, EventArgs e)
|
||||
{
|
||||
DateTime dt = new DateTime(Year, Month, 1);
|
||||
if (dt.Year == DateTime.MaxValue.Year && dt.Month == DateTime.MaxValue.Month) return;
|
||||
dt = dt.AddMonths(1);
|
||||
Year = dt.Year;
|
||||
Month = dt.Month;
|
||||
@ -852,16 +873,19 @@ namespace Sunny.UI
|
||||
{
|
||||
case 0:
|
||||
Year = year / 10 * 10;
|
||||
if (year == 9990) return;
|
||||
Year += 10;
|
||||
SetYears(Year);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (Year == DateTime.MaxValue.Year) return;
|
||||
Year += 1;
|
||||
TopPanel.Text = Year + "年";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (Year == DateTime.MaxValue.Year) return;
|
||||
Year += 1;
|
||||
SetYearMonth(Year, Month);
|
||||
break;
|
||||
@ -890,7 +914,7 @@ namespace Sunny.UI
|
||||
{
|
||||
if (e.Delta < 0)
|
||||
{
|
||||
if (new Rectangle(ht.Left,ht.Top,ht.Width,hb.Bottom-ht.Top).Contains(e.X, e.Y))
|
||||
if (new Rectangle(ht.Left, ht.Top, ht.Width, hb.Bottom - ht.Top).Contains(e.X, e.Y))
|
||||
{
|
||||
h1.PerformClick();
|
||||
}
|
||||
@ -1007,7 +1031,7 @@ namespace Sunny.UI
|
||||
|
||||
private void btnOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
DateTime time = new DateTime(Date.Year, Date.Month, Date.Day, Hour, Minute, Second);
|
||||
DateTime time = new DateTime(Date.Year, Date.Month, Date.Day, Hour, Minute, Second);
|
||||
DoValueChanged(this, time);
|
||||
CloseParent();
|
||||
}
|
||||
@ -1068,7 +1092,7 @@ namespace Sunny.UI
|
||||
int x = e.Location.X / width;
|
||||
int y = e.Location.Y / height;
|
||||
Month = x + y * 4 + 1;
|
||||
|
||||
if (Month <= 0 || Month > 12) return;
|
||||
SetYearMonth(Year, Month);
|
||||
activeMonth = -1;
|
||||
TabControl.SelectedTab = tabPage3;
|
||||
@ -1110,8 +1134,8 @@ namespace Sunny.UI
|
||||
int x = e.Location.X / width;
|
||||
int y = e.Location.Y / height;
|
||||
int iy = x + y * 4;
|
||||
|
||||
Year = years[iy];
|
||||
if (iy < 0 || iy >= 12) return;
|
||||
Year = years[iy] > 9999 ? 9999 : years[iy];
|
||||
activeYear = -1;
|
||||
TabControl.SelectedTab = tabPage2;
|
||||
p2.Invalidate();
|
||||
@ -1133,6 +1157,7 @@ namespace Sunny.UI
|
||||
|
||||
e.Graphics.DrawLine(Color.DarkGray, 8, 26, 268, 26);
|
||||
|
||||
bool maxDrawer = false;
|
||||
for (int i = 0; i < 42; i++)
|
||||
{
|
||||
int left = width * (i % 7);
|
||||
@ -1141,7 +1166,16 @@ namespace Sunny.UI
|
||||
sf = e.Graphics.MeasureString(days[i].Day.ToString(), Font);
|
||||
Color color = (days[i].Month == Month) ? ForeColor : Color.DarkGray;
|
||||
color = (days[i].DateString() == date.DateString()) ? UIColor.Blue : color;
|
||||
e.Graphics.DrawString(days[i].Day.ToString(), Font, i == activeDay ? UIColor.Blue : color, left + (width - sf.Width) / 2, top + 30 + (height - sf.Height) / 2);
|
||||
|
||||
if (!maxDrawer)
|
||||
{
|
||||
e.Graphics.DrawString(days[i].Day.ToString(), Font, i == activeDay ? UIColor.Blue : color, left + (width - sf.Width) / 2, top + 30 + (height - sf.Height) / 2);
|
||||
}
|
||||
|
||||
if (!maxDrawer && days[i].Date.Equals(DateTime.MaxValue.Date))
|
||||
{
|
||||
maxDrawer = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1166,7 +1200,7 @@ namespace Sunny.UI
|
||||
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;
|
||||
DoValueChanged(this, Date);
|
||||
CloseParent();
|
||||
|
@ -59,6 +59,7 @@ namespace Sunny.UI
|
||||
edit.KeyDown += EditOnKeyDown;
|
||||
edit.KeyUp += EditOnKeyUp;
|
||||
edit.KeyPress += EditOnKeyPress;
|
||||
edit.LostFocus += Edit_LostFocus;
|
||||
edit.Invalidate();
|
||||
Controls.Add(edit);
|
||||
|
||||
@ -67,12 +68,21 @@ namespace Sunny.UI
|
||||
edit.BackColor = Color.White;
|
||||
}
|
||||
|
||||
private void Edit_LostFocus(object sender, EventArgs e)
|
||||
{
|
||||
EditorLostFocus?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
public event EventHandler EditorLostFocus;
|
||||
|
||||
public new event KeyEventHandler KeyDown;
|
||||
|
||||
public new event KeyEventHandler KeyUp;
|
||||
|
||||
public new event KeyPressEventHandler KeyPress;
|
||||
|
||||
public new event EventHandler TextChanged;
|
||||
|
||||
private void EditOnKeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
KeyPress?.Invoke(sender, e);
|
||||
@ -203,6 +213,7 @@ namespace Sunny.UI
|
||||
private void EditTextChanged(object s, EventArgs e)
|
||||
{
|
||||
Text = edit.Text;
|
||||
TextChanged?.Invoke(s, e);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ namespace Sunny.UI
|
||||
|
||||
private int avatarSize = 60;
|
||||
|
||||
[DefaultValue(60)]
|
||||
[DefaultValue(60), Description("头像大小"), Category("SunnyUI")]
|
||||
public int AvatarSize
|
||||
{
|
||||
get => avatarSize;
|
||||
@ -84,7 +84,7 @@ namespace Sunny.UI
|
||||
/// <summary>
|
||||
/// 填充颜色,当值为背景色或透明色或空值则不填充
|
||||
/// </summary>
|
||||
[Description("填充颜色"), Category("自定义")]
|
||||
[Description("填充颜色"), Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "Silver")]
|
||||
public Color FillColor
|
||||
{
|
||||
@ -95,7 +95,7 @@ namespace Sunny.UI
|
||||
/// <summary>
|
||||
/// 字体颜色
|
||||
/// </summary>
|
||||
[Description("前景颜色"), Category("自定义")]
|
||||
[Description("前景颜色"), Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "80, 160, 255")]
|
||||
public override Color ForeColor
|
||||
{
|
||||
@ -122,7 +122,7 @@ namespace Sunny.UI
|
||||
/// <summary>
|
||||
/// 显示方式:图像(Image)、符号(Symbol)、文字(Text)
|
||||
/// </summary>
|
||||
[DefaultValue(UIIcon.Symbol), Description("显示方式:图像(Image)、符号(Symbol)、文字(Text)")]
|
||||
[DefaultValue(UIIcon.Symbol), Description("显示方式:图像(Image)、符号(Symbol)、文字(Text)"), Category("SunnyUI")]
|
||||
public UIIcon Icon
|
||||
{
|
||||
get => icon;
|
||||
@ -141,7 +141,7 @@ namespace Sunny.UI
|
||||
/// <summary>
|
||||
/// 显示形状:圆形,正方形
|
||||
/// </summary>
|
||||
[DefaultValue(UIShape.Circle), Description("显示形状:圆形,正方形")]
|
||||
[DefaultValue(UIShape.Circle), Description("显示形状:圆形,正方形"), Category("SunnyUI")]
|
||||
public UIShape Shape
|
||||
{
|
||||
get => sharpType;
|
||||
@ -160,7 +160,7 @@ namespace Sunny.UI
|
||||
/// <summary>
|
||||
/// 图片
|
||||
/// </summary>
|
||||
[DefaultValue(typeof(Image), "null")]
|
||||
[DefaultValue(typeof(Image), "null"), Description("图片"), Category("SunnyUI")]
|
||||
public Image Image
|
||||
{
|
||||
get => image;
|
||||
@ -179,7 +179,7 @@ namespace Sunny.UI
|
||||
/// <summary>
|
||||
/// 图标大小
|
||||
/// </summary>
|
||||
[DefaultValue(45)]
|
||||
[DefaultValue(45), Description("图标大小"), Category("SunnyUI")]
|
||||
public int SymbolSize
|
||||
{
|
||||
get => symbolSize;
|
||||
@ -201,7 +201,7 @@ namespace Sunny.UI
|
||||
/// </summary>
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
[Editor(typeof(UIImagePropertyEditor), typeof(UITypeEditor))]
|
||||
[DefaultValue(61447)]
|
||||
[DefaultValue(61447), Description("图标"), Category("SunnyUI")]
|
||||
public int Symbol
|
||||
{
|
||||
get => symbol;
|
||||
@ -223,7 +223,7 @@ namespace Sunny.UI
|
||||
protected override void OnPaintFill(Graphics g, GraphicsPath path)
|
||||
{
|
||||
int size = Math.Min(Width, Height) - 3;
|
||||
Rectangle rect = new Rectangle((Width-avatarSize)/2, (Height - avatarSize) / 2, avatarSize, avatarSize);
|
||||
Rectangle rect = new Rectangle((Width - avatarSize) / 2, (Height - avatarSize) / 2, avatarSize, avatarSize);
|
||||
|
||||
switch (Shape)
|
||||
{
|
||||
@ -288,13 +288,13 @@ namespace Sunny.UI
|
||||
|
||||
if (Icon == UIIcon.Symbol)
|
||||
{
|
||||
e.Graphics.DrawFontImage(symbol, symbolSize, ForeColor, new Rectangle((Width - avatarSize) / 2+1, (Height - avatarSize) / 2+1, avatarSize, avatarSize));
|
||||
e.Graphics.DrawFontImage(symbol, symbolSize, ForeColor, new Rectangle((Width - avatarSize) / 2 + 1, (Height - avatarSize) / 2 + 1, avatarSize, avatarSize));
|
||||
}
|
||||
|
||||
if (Icon == UIIcon.Text)
|
||||
{
|
||||
SizeF sf = e.Graphics.MeasureString(Text, Font);
|
||||
e.Graphics.DrawString(Text, Font, foreColor, 2 + (Width - sf.Width ) / 2.0f, (Height- sf.Height ) / 2.0f);
|
||||
e.Graphics.DrawString(Text, Font, foreColor, 2 + (Width - sf.Width) / 2.0f, (Height - sf.Height) / 2.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ namespace Sunny.UI
|
||||
Height = 24;
|
||||
}
|
||||
|
||||
[DefaultValue(100)]
|
||||
[DefaultValue(100), Description("电量"), Category("SunnyUI")]
|
||||
public int Power
|
||||
{
|
||||
get => power;
|
||||
@ -61,7 +61,7 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(36)]
|
||||
[DefaultValue(36), Description("图标大小"), Category("SunnyUI")]
|
||||
public int SymbolSize
|
||||
{
|
||||
get => symbolSize;
|
||||
@ -73,7 +73,7 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(true)]
|
||||
[DefaultValue(true), Description("多种颜色"), Category("SunnyUI")]
|
||||
public bool MultiColor
|
||||
{
|
||||
get => multiColor;
|
||||
@ -84,7 +84,7 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "230, 80, 80")]
|
||||
[DefaultValue(typeof(Color), "230, 80, 80"), Description("电量为空颜色"), Category("SunnyUI")]
|
||||
public Color ColorEmpty
|
||||
{
|
||||
get => colorEmpty;
|
||||
@ -95,7 +95,7 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "220, 155, 40")]
|
||||
[DefaultValue(typeof(Color), "220, 155, 40"), Description("电量少时颜色"), Category("SunnyUI")]
|
||||
public Color ColorDanger
|
||||
{
|
||||
get => colorDanger;
|
||||
@ -106,7 +106,7 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "110, 190, 40")]
|
||||
[DefaultValue(typeof(Color), "110, 190, 40"), Description("电量安全颜色"), Category("SunnyUI")]
|
||||
public Color ColorSafe
|
||||
{
|
||||
get => colorSafe;
|
||||
@ -121,7 +121,7 @@ namespace Sunny.UI
|
||||
/// 字体颜色
|
||||
/// </summary>
|
||||
[Description("字体颜色")]
|
||||
[Category("自定义")]
|
||||
[Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "White")]
|
||||
public override Color ForeColor
|
||||
{
|
||||
@ -133,7 +133,7 @@ namespace Sunny.UI
|
||||
/// 填充颜色,当值为背景色或透明色或空值则不填充
|
||||
/// </summary>
|
||||
[Description("填充颜色")]
|
||||
[Category("自定义")]
|
||||
[Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "235, 243, 255")]
|
||||
public Color FillColor
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ namespace Sunny.UI
|
||||
|
||||
private bool showTips = false;
|
||||
|
||||
[Description("是否显示角标"), Category("自定义")]
|
||||
[Description("是否显示角标"), Category("SunnyUI")]
|
||||
[DefaultValue(false)]
|
||||
public bool ShowTips
|
||||
{
|
||||
@ -98,7 +98,7 @@ namespace Sunny.UI
|
||||
|
||||
private string tipsText = "";
|
||||
|
||||
[Description("角标文字"), Category("自定义")]
|
||||
[Description("角标文字"), Category("SunnyUI")]
|
||||
[DefaultValue("")]
|
||||
public string TipsText
|
||||
{
|
||||
@ -118,7 +118,7 @@ namespace Sunny.UI
|
||||
|
||||
private Font tipsFont = new Font("Microsoft Sans Serif", 9);
|
||||
|
||||
[Description("角标文字字体"), Category("自定义")]
|
||||
[Description("角标文字字体"), Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Font), "Microsoft Sans Serif, 9pt")]
|
||||
public Font TipsFont
|
||||
{
|
||||
@ -141,7 +141,7 @@ namespace Sunny.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
g.FillPath(FillSelectedColor,path);
|
||||
g.FillPath(FillSelectedColor, path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ namespace Sunny.UI
|
||||
path.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否选中
|
||||
/// </summary>
|
||||
@ -214,7 +214,7 @@ namespace Sunny.UI
|
||||
/// <summary>
|
||||
/// 填充颜色,当值为背景色或透明色或空值则不填充
|
||||
/// </summary>
|
||||
[Description("填充颜色"), Category("自定义")]
|
||||
[Description("填充颜色"), Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "80, 160, 255")]
|
||||
public Color FillColor
|
||||
{
|
||||
@ -225,7 +225,7 @@ namespace Sunny.UI
|
||||
/// <summary>
|
||||
/// 边框颜色
|
||||
/// </summary>
|
||||
[Description("边框颜色"), Category("自定义")]
|
||||
[Description("边框颜色"), Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "80, 160, 255")]
|
||||
public Color RectColor
|
||||
{
|
||||
@ -236,7 +236,7 @@ namespace Sunny.UI
|
||||
/// <summary>
|
||||
/// 字体颜色
|
||||
/// </summary>
|
||||
[Description("字体颜色"), Category("自定义")]
|
||||
[Description("字体颜色"), Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "White")]
|
||||
public override Color ForeColor
|
||||
{
|
||||
@ -244,84 +244,84 @@ namespace Sunny.UI
|
||||
set => SetForeColor(value);
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "244, 244, 244")]
|
||||
[DefaultValue(typeof(Color), "244, 244, 244"), Category("SunnyUI")]
|
||||
public Color FillDisableColor
|
||||
{
|
||||
get => fillDisableColor;
|
||||
set => SetFillDisableColor(value);
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "173, 178, 181")]
|
||||
[DefaultValue(typeof(Color), "173, 178, 181"), Category("SunnyUI")]
|
||||
public Color RectDisableColor
|
||||
{
|
||||
get => rectDisableColor;
|
||||
set => SetRectDisableColor(value);
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "109, 109, 103")]
|
||||
[DefaultValue(typeof(Color), "109, 109, 103"), Category("SunnyUI")]
|
||||
public Color ForeDisableColor
|
||||
{
|
||||
get => foreDisableColor;
|
||||
set => SetForeDisableColor(value);
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "111, 168, 255")]
|
||||
[DefaultValue(typeof(Color), "111, 168, 255"), Category("SunnyUI")]
|
||||
public Color FillHoverColor
|
||||
{
|
||||
get => fillHoverColor;
|
||||
set => SetFillHoveColor(value);
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "74, 131, 229")]
|
||||
[DefaultValue(typeof(Color), "74, 131, 229"), Category("SunnyUI")]
|
||||
public Color FillPressColor
|
||||
{
|
||||
get => fillPressColor;
|
||||
set => SetFillPressColor(value);
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "White")]
|
||||
[DefaultValue(typeof(Color), "White"), Category("SunnyUI")]
|
||||
public Color ForeHoverColor
|
||||
{
|
||||
get => foreHoverColor;
|
||||
set => SetForeHoveColor(value);
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "White")]
|
||||
[DefaultValue(typeof(Color), "White"), Category("SunnyUI")]
|
||||
public Color ForePressColor
|
||||
{
|
||||
get => forePressColor;
|
||||
set => SetForePressColor(value);
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "111, 168, 255")]
|
||||
[DefaultValue(typeof(Color), "111, 168, 255"), Category("SunnyUI")]
|
||||
public Color RectHoverColor
|
||||
{
|
||||
get => rectHoverColor;
|
||||
set => SetRectHoveColor(value);
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "74, 131, 229")]
|
||||
[DefaultValue(typeof(Color), "74, 131, 229"), Category("SunnyUI")]
|
||||
public Color RectPressColor
|
||||
{
|
||||
get => rectPressColor;
|
||||
set => SetRectPressColor(value);
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "74, 131, 229")]
|
||||
[DefaultValue(typeof(Color), "74, 131, 229"), Category("SunnyUI")]
|
||||
public Color FillSelectedColor
|
||||
{
|
||||
get => fillSelectedColor;
|
||||
set => SetFillSelectedColor(value);
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "White")]
|
||||
[DefaultValue(typeof(Color), "White"), Category("SunnyUI")]
|
||||
public Color ForeSelectedColor
|
||||
{
|
||||
get => foreSelectedColor;
|
||||
set => SetForeSelectedColor(value);
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Color), "74, 131, 229")]
|
||||
[DefaultValue(typeof(Color), "74, 131, 229"), Category("SunnyUI")]
|
||||
public Color RectSelectedColor
|
||||
{
|
||||
get => rectSelectedColor;
|
||||
|
1
SunnyUI/Controls/UIDatePicker.Designer.cs
generated
1
SunnyUI/Controls/UIDatePicker.Designer.cs
generated
@ -33,7 +33,6 @@
|
||||
// UIDatePicker
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList;
|
||||
this.Name = "UIDatePicker";
|
||||
this.Padding = new System.Windows.Forms.Padding(0, 0, 30, 0);
|
||||
this.SymbolDropDown = 61555;
|
||||
|
@ -35,6 +35,38 @@ namespace Sunny.UI
|
||||
{
|
||||
InitializeComponent();
|
||||
Value = DateTime.Now;
|
||||
MaxLength = 10;
|
||||
EditorLostFocus += UIDatePicker_LostFocus;
|
||||
TextChanged += UIDatePicker_TextChanged;
|
||||
}
|
||||
|
||||
private void UIDatePicker_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Text.Length == MaxLength)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime dt = Text.ToDateTime(DateFormat);
|
||||
Value = dt;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Value = DateTime.Now.Date;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UIDatePicker_LostFocus(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime dt = Text.ToDateTime(DateFormat);
|
||||
Value = dt;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Value = DateTime.Now.Date;
|
||||
}
|
||||
}
|
||||
|
||||
public event OnDateTimeChanged ValueChanged;
|
||||
@ -59,8 +91,8 @@ namespace Sunny.UI
|
||||
get => item.Date;
|
||||
set
|
||||
{
|
||||
if (value< new DateTime(1753,1,1))
|
||||
value = new DateTime(1753,1,1);
|
||||
if (value < new DateTime(1753, 1, 1))
|
||||
value = new DateTime(1753, 1, 1);
|
||||
Text = value.ToString(dateFormat);
|
||||
item.Date = value;
|
||||
}
|
||||
@ -83,6 +115,7 @@ namespace Sunny.UI
|
||||
{
|
||||
dateFormat = value;
|
||||
Text = Value.ToString(dateFormat);
|
||||
MaxLength = dateFormat.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
{
|
||||
@ -35,21 +34,55 @@ namespace Sunny.UI
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// UIDateTimePicker
|
||||
// UIDatetimePicker
|
||||
//
|
||||
this.Name = "UIDatetimePicker";
|
||||
this.Padding = new System.Windows.Forms.Padding(0, 0, 30, 0);
|
||||
this.SymbolDropDown = 61555;
|
||||
this.SymbolNormal = 61555;
|
||||
this.ButtonClick += new System.EventHandler(this.UIDatetimePicker_ButtonClick);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
DropDownStyle = UIDropDownStyle.DropDownList;
|
||||
}
|
||||
|
||||
public UIDatetimePicker()
|
||||
{
|
||||
InitializeComponent();
|
||||
Width = 200;
|
||||
Value = DateTime.Now;
|
||||
EditorLostFocus += UIDatePicker_LostFocus;
|
||||
TextChanged += UIDatePicker_TextChanged;
|
||||
MaxLength = 19;
|
||||
}
|
||||
|
||||
private void UIDatePicker_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Text.Length == MaxLength)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime dt = Text.ToDateTime(DateFormat);
|
||||
Value = dt;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Value = DateTime.Now.Date;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UIDatePicker_LostFocus(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime dt = Text.ToDateTime(DateFormat);
|
||||
Value = dt;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Value = DateTime.Now.Date;
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void OnDateTimeChanged(object sender, DateTime value);
|
||||
@ -77,6 +110,8 @@ namespace Sunny.UI
|
||||
get => item.Date;
|
||||
set
|
||||
{
|
||||
if (value < new DateTime(1753, 1, 1))
|
||||
value = new DateTime(1753, 1, 1);
|
||||
Text = value.ToString(dateFormat);
|
||||
item.Date = value;
|
||||
}
|
||||
@ -90,7 +125,7 @@ namespace Sunny.UI
|
||||
|
||||
private string dateFormat = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
[Description("日期格式化掩码"), Category("自定义")]
|
||||
[Description("日期格式化掩码"), Category("SunnyUI")]
|
||||
[DefaultValue("yyyy-MM-dd HH:mm:ss")]
|
||||
public string DateFormat
|
||||
{
|
||||
@ -99,6 +134,7 @@ namespace Sunny.UI
|
||||
{
|
||||
dateFormat = value;
|
||||
Text = Value.ToString(dateFormat);
|
||||
MaxLength = dateFormat.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
120
SunnyUI/Controls/UIDateTimePicker.resx
Normal file
120
SunnyUI/Controls/UIDateTimePicker.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -21,7 +21,6 @@
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
{
|
||||
@ -36,7 +35,6 @@ namespace Sunny.UI
|
||||
//
|
||||
// UITimePicker
|
||||
//
|
||||
this.DropDownStyle = Sunny.UI.UIDropDownStyle.DropDownList;
|
||||
this.Name = "UITimePicker";
|
||||
this.Padding = new System.Windows.Forms.Padding(0, 0, 30, 0);
|
||||
this.SymbolDropDown = 61555;
|
||||
@ -50,6 +48,39 @@ namespace Sunny.UI
|
||||
{
|
||||
InitializeComponent();
|
||||
Value = DateTime.Now;
|
||||
|
||||
EditorLostFocus += UIDatePicker_LostFocus;
|
||||
TextChanged += UIDatePicker_TextChanged;
|
||||
MaxLength = 8;
|
||||
}
|
||||
|
||||
private void UIDatePicker_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Text.Length == MaxLength)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime dt = (DateTime.Now.DateString() + " " + Text).ToDateTime(DateTimeEx.DateFormat + " " + timeFormat);
|
||||
Value = dt;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Value = DateTime.Now.Date;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UIDatePicker_LostFocus(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime dt = (DateTime.Now.DateString() + " " + Text).ToDateTime(DateTimeEx.DateFormat + " " + timeFormat);
|
||||
Value = dt;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Value = DateTime.Now.Date;
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void OnDateTimeChanged(object sender, DateTime value);
|
||||
@ -92,6 +123,7 @@ namespace Sunny.UI
|
||||
{
|
||||
timeFormat = value;
|
||||
Text = Value.ToString(timeFormat);
|
||||
MaxLength = timeFormat.Length;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user