* UIComboDataGridView: 有过滤输入框时默认Focus
This commit is contained in:
parent
f53b3a56a0
commit
fe2e06f506
Binary file not shown.
@ -57,6 +57,26 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Size Size(this SizeF size)
|
||||||
|
{
|
||||||
|
return new Size(size.Width.RoundEx(), size.Height.RoundEx());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Point Point(this PointF point)
|
||||||
|
{
|
||||||
|
return new Point(point.X.RoundEx(), point.Y.RoundEx());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Size Add(this Size size, int width, int height)
|
||||||
|
{
|
||||||
|
return new Size(size.Width + width, size.Height + height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SizeF Add(this SizeF size, float width, float height)
|
||||||
|
{
|
||||||
|
return new SizeF(size.Width + width, size.Height + height);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 点是否在区域内
|
/// 点是否在区域内
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -126,7 +146,7 @@ namespace Sunny.UI
|
|||||||
/// 提供一个Graphics,常用于需要计算文字大小时
|
/// 提供一个Graphics,常用于需要计算文字大小时
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>大小</returns>
|
/// <returns>大小</returns>
|
||||||
public static Graphics Graphics()
|
private static Graphics Graphics()
|
||||||
{
|
{
|
||||||
if (TempGraphics == null)
|
if (TempGraphics == null)
|
||||||
{
|
{
|
||||||
|
@ -578,13 +578,13 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
private void btnCancel_Click(object sender, EventArgs e)
|
private void btnCancel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnOK_Click(object sender, EventArgs e)
|
private void btnOK_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DoValueChanged(this, SelectedColor);
|
DoValueChanged(this, SelectedColor);
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void m_colorSample_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
|
private void m_colorSample_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
|
||||||
|
@ -44,7 +44,7 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
private void ListBox_Click(object sender, EventArgs e)
|
private void ListBox_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -74,7 +74,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
if (e.KeyCode == System.Windows.Forms.Keys.Enter || e.KeyCode == System.Windows.Forms.Keys.Space)
|
if (e.KeyCode == System.Windows.Forms.Keys.Enter || e.KeyCode == System.Windows.Forms.Keys.Space)
|
||||||
{
|
{
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,12 +262,12 @@ namespace Sunny.UI
|
|||||||
DoValueChanged(this, dataGridView.SelectedIndex);
|
DoValueChanged(this, dataGridView.SelectedIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCancel_Click(object sender, System.EventArgs e)
|
private void btnCancel_Click(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ShowFilter
|
public bool ShowFilter
|
||||||
@ -317,5 +317,18 @@ namespace Sunny.UI
|
|||||||
btnSearch.PerformClick();
|
btnSearch.PerformClick();
|
||||||
DoValueChanged(this, null);
|
DoValueChanged(this, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void InitShow()
|
||||||
|
{
|
||||||
|
if (ShowFilter)
|
||||||
|
{
|
||||||
|
edtFilter.Focus();
|
||||||
|
edtFilter.SelectAll();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
btnOK.Focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ namespace Sunny.UI
|
|||||||
if (e.Node.Nodes.Count == 0 || CanSelectRootNode)
|
if (e.Node.Nodes.Count == 0 || CanSelectRootNode)
|
||||||
{
|
{
|
||||||
DoValueChanged(this, e.Node);
|
DoValueChanged(this, e.Node);
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,13 +159,13 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
private void btnCancel_Click(object sender, System.EventArgs e)
|
private void btnCancel_Click(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnOK_Click(object sender, System.EventArgs e)
|
private void btnOK_Click(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
DoValueChanged(this, treeView.Nodes);
|
DoValueChanged(this, treeView.Nodes);
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -592,7 +592,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
date = new DateTime(Year, Month, 1);
|
date = new DateTime(Year, Month, 1);
|
||||||
DoValueChanged(this, Date);
|
DoValueChanged(this, Date);
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -667,7 +667,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
date = new DateTime(Year, 1, 1);
|
date = new DateTime(Year, 1, 1);
|
||||||
DoValueChanged(this, Date);
|
DoValueChanged(this, Date);
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -771,7 +771,7 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
DoValueChanged(this, Date);
|
DoValueChanged(this, Date);
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color PrimaryColor { get; set; } = UIColor.Blue;
|
public Color PrimaryColor { get; set; } = UIColor.Blue;
|
||||||
|
@ -1089,14 +1089,14 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
private void btnCancel_Click(object sender, EventArgs e)
|
private void btnCancel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnOK_Click(object sender, EventArgs e)
|
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);
|
DoValueChanged(this, time);
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hc_DoubleClick(object sender, EventArgs e)
|
private void hc_DoubleClick(object sender, EventArgs e)
|
||||||
|
@ -301,6 +301,7 @@ namespace Sunny.UI
|
|||||||
protected override void OnOpened(EventArgs e)
|
protected override void OnOpened(EventArgs e)
|
||||||
{
|
{
|
||||||
Item.Focus();
|
Item.Focus();
|
||||||
|
Item.InitShow();
|
||||||
base.OnOpened(e);
|
base.OnOpened(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,19 +88,19 @@ namespace Sunny.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 关闭弹出窗口
|
/// 关闭弹出窗口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void CloseParent()
|
public void Close()
|
||||||
{
|
{
|
||||||
UIDropDown parent = (UIDropDown)Parent;
|
UIDropDown parent = (UIDropDown)Parent;
|
||||||
parent?.Close();
|
parent?.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
|
||||||
{
|
|
||||||
CloseParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void SetStyle(UIBaseStyle style)
|
public virtual void SetStyle(UIBaseStyle style)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void InitShow()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -587,12 +587,12 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
time = new DateTime(DateTime.MinValue.Year, DateTime.MinValue.Month, DateTime.MinValue.Day, Hour, Minute, Second);
|
time = new DateTime(DateTime.MinValue.Year, DateTime.MinValue.Month, DateTime.MinValue.Day, Hour, Minute, Second);
|
||||||
DoValueChanged(this, time);
|
DoValueChanged(this, time);
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCancel_Click(object sender, EventArgs e)
|
private void btnCancel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
CloseParent();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetStyle(UIBaseStyle style)
|
public override void SetStyle(UIBaseStyle style)
|
||||||
|
@ -174,32 +174,27 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var bmp = new Bitmap(e.ToolTipSize.Width, e.ToolTipSize.Height);
|
|
||||||
var g = Graphics.FromImage(bmp);
|
|
||||||
int symbolWidth = tooltip.Symbol > 0 ? tooltip.SymbolSize : 0;
|
int symbolWidth = tooltip.Symbol > 0 ? tooltip.SymbolSize : 0;
|
||||||
|
|
||||||
|
|
||||||
SizeF titleSize = new SizeF(0, 0);
|
SizeF titleSize = new SizeF(0, 0);
|
||||||
if (tooltip.Title.IsValid())
|
if (tooltip.Title.IsValid())
|
||||||
{
|
{
|
||||||
titleSize = g.MeasureString(tooltip.Title, TempTitleFont);
|
titleSize = GDI.MeasureString(tooltip.Title, TempTitleFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
SizeF textSize = g.MeasureString(tooltip.ToolTipText, TempTitleFont);
|
SizeF textSize = GDI.MeasureString(tooltip.ToolTipText, TempFont);
|
||||||
int allWidth = (int)Math.Max(textSize.Width, titleSize.Width) + 10;
|
int allWidth = (int)Math.Max(textSize.Width, titleSize.Width) + 10;
|
||||||
if (symbolWidth > 0) allWidth = allWidth + symbolWidth + 5;
|
if (symbolWidth > 0) allWidth = allWidth + symbolWidth + 5;
|
||||||
int allHeight = titleSize.Height > 0 ?
|
int allHeight = titleSize.Height > 0 ?
|
||||||
(int)titleSize.Height + (int)textSize.Height + 15 :
|
(int)titleSize.Height + (int)textSize.Height + 15 :
|
||||||
(int)textSize.Height + 10;
|
(int)textSize.Height + 10;
|
||||||
e.ToolTipSize = new Size(allWidth, allHeight);
|
e.ToolTipSize = new Size(allWidth, allHeight);
|
||||||
bmp.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SizeF sf = GDI.MeasureString(GetToolTip(e.AssociatedControl), TempTitleFont);
|
SizeF sf = GDI.MeasureString(GetToolTip(e.AssociatedControl), TempFont);
|
||||||
e.ToolTipSize = new Size((int)sf.Width + 10, (int)sf.Height + 10);
|
e.ToolTipSize = sf.Size().Add(10, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,13 +264,13 @@ namespace Sunny.UI
|
|||||||
e.Bounds.Width - 5, 5 + titleSize.Height + 3);
|
e.Bounds.Width - 5, 5 + titleSize.Height + 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
e.Graphics.DrawString(e.ToolTipText, TempTitleFont, ForeColor,
|
e.Graphics.DrawString(e.ToolTipText, TempFont, ForeColor,
|
||||||
tooltip.Symbol > 0 ? tooltip.SymbolSize + 5 : 5,
|
tooltip.Symbol > 0 ? tooltip.SymbolSize + 5 : 5,
|
||||||
titleSize.Height > 0 ? 10 + titleSize.Height : 5);
|
titleSize.Height > 0 ? 10 + titleSize.Height : 5);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
e.Graphics.DrawString(e.ToolTipText, TempTitleFont, ForeColor, 5, 5);
|
e.Graphics.DrawString(e.ToolTipText, TempFont, ForeColor, 5, 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user