* UITextBox:增加按钮
This commit is contained in:
parent
78065f4d00
commit
c78c54b8c7
Binary file not shown.
Binary file not shown.
6
SunnyUI.Demo/Controls/FTextBox.Designer.cs
generated
6
SunnyUI.Demo/Controls/FTextBox.Designer.cs
generated
@ -52,6 +52,7 @@ namespace Sunny.UI.Demo
|
||||
//
|
||||
// uiTextBox6
|
||||
//
|
||||
this.uiTextBox6.ButtonWidth = 100;
|
||||
this.uiTextBox6.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||
this.uiTextBox6.FillColor = System.Drawing.Color.White;
|
||||
this.uiTextBox6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
@ -70,6 +71,7 @@ namespace Sunny.UI.Demo
|
||||
//
|
||||
// uiTextBox5
|
||||
//
|
||||
this.uiTextBox5.ButtonWidth = 100;
|
||||
this.uiTextBox5.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||
this.uiTextBox5.FillColor = System.Drawing.Color.White;
|
||||
this.uiTextBox5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
@ -88,6 +90,7 @@ namespace Sunny.UI.Demo
|
||||
//
|
||||
// uiTextBox4
|
||||
//
|
||||
this.uiTextBox4.ButtonWidth = 100;
|
||||
this.uiTextBox4.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||
this.uiTextBox4.FillColor = System.Drawing.Color.White;
|
||||
this.uiTextBox4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
@ -206,6 +209,7 @@ namespace Sunny.UI.Demo
|
||||
//
|
||||
// uiTextBox3
|
||||
//
|
||||
this.uiTextBox3.ButtonWidth = 100;
|
||||
this.uiTextBox3.CanEmpty = true;
|
||||
this.uiTextBox3.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||
this.uiTextBox3.FillColor = System.Drawing.Color.White;
|
||||
@ -236,6 +240,7 @@ namespace Sunny.UI.Demo
|
||||
//
|
||||
// uiTextBox2
|
||||
//
|
||||
this.uiTextBox2.ButtonWidth = 100;
|
||||
this.uiTextBox2.CanEmpty = true;
|
||||
this.uiTextBox2.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||
this.uiTextBox2.DoubleValue = 5D;
|
||||
@ -279,6 +284,7 @@ namespace Sunny.UI.Demo
|
||||
this.uiTextBox1.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.uiTextBox1.Name = "uiTextBox1";
|
||||
this.uiTextBox1.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.uiTextBox1.ShowButton = true;
|
||||
this.uiTextBox1.Size = new System.Drawing.Size(221, 29);
|
||||
this.uiTextBox1.TabIndex = 0;
|
||||
this.uiTextBox1.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
|
@ -26,6 +26,7 @@
|
||||
* 2021-07-18: V3.0.5 修改Focus可用
|
||||
* 2021-08-03: V3.0.5 增加GotFocus和LostFocus事件
|
||||
* 2021-08-15: V3.0.6 重写了水印文字的画法,并增加水印文字颜色
|
||||
* 2021-09-07: V3.0.6 增加按钮
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -43,6 +44,7 @@ namespace Sunny.UI
|
||||
{
|
||||
private readonly UIEdit edit = new UIEdit();
|
||||
private readonly UIScrollBar bar = new UIScrollBar();
|
||||
private readonly UISymbolButton btn = new UISymbolButton();
|
||||
|
||||
public UITextBox()
|
||||
{
|
||||
@ -77,6 +79,15 @@ namespace Sunny.UI
|
||||
edit.MouseUp += Edit_MouseUp;
|
||||
edit.MouseMove += Edit_MouseMove;
|
||||
|
||||
btn.Parent = this;
|
||||
btn.Visible = false;
|
||||
btn.Text = "";
|
||||
btn.Symbol = 61761;
|
||||
btn.Top = 1;
|
||||
btn.Height = 25;
|
||||
btn.Width = 29;
|
||||
btn.Click += Btn_Click;
|
||||
|
||||
edit.Invalidate();
|
||||
Controls.Add(edit);
|
||||
fillColor = Color.White;
|
||||
@ -96,6 +107,35 @@ namespace Sunny.UI
|
||||
TextAlignmentChange += UITextBox_TextAlignmentChange;
|
||||
}
|
||||
|
||||
private void Btn_Click(object sender, EventArgs e)
|
||||
{
|
||||
ButtonClick?.Invoke(this, e);
|
||||
}
|
||||
|
||||
public event EventHandler ButtonClick;
|
||||
|
||||
[DefaultValue(29), Category("SunnyUI"), Description("按钮宽度")]
|
||||
public int ButtonWidth { get => btn.Width; set { btn.Width = Math.Max(20, value); SizeChange(); } }
|
||||
|
||||
[DefaultValue(false), Category("SunnyUI"), Description("显示按钮")]
|
||||
public bool ShowButton
|
||||
{
|
||||
get => btn.Visible;
|
||||
set
|
||||
{
|
||||
if (Multiline)
|
||||
{
|
||||
btn.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn.Visible = value;
|
||||
}
|
||||
|
||||
SizeChange();
|
||||
}
|
||||
}
|
||||
|
||||
private void Edit_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
MouseMove?.Invoke(this, e);
|
||||
@ -470,13 +510,23 @@ namespace Sunny.UI
|
||||
edit.Width = Width - 8 - SymbolSize - Padding.Left - Padding.Right;
|
||||
}
|
||||
}
|
||||
|
||||
if (ShowButton)
|
||||
{
|
||||
btn.Left = Width - 2 - ButtonWidth;
|
||||
btn.Top = 2;
|
||||
btn.Height = Height - 4;
|
||||
edit.Width = edit.Width - btn.Width - 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
btn.Visible = false;
|
||||
edit.Top = 3;
|
||||
edit.Height = Height - 6;
|
||||
edit.Left = 1;
|
||||
edit.Width = Width - 2;
|
||||
|
||||
bar.Top = 2;
|
||||
bar.Width = ScrollBarInfo.VerticalScrollBarWidth();
|
||||
bar.Left = Width - bar.Width - 1;
|
||||
@ -1021,5 +1071,31 @@ namespace Sunny.UI
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
[Editor(typeof(UIImagePropertyEditor), typeof(UITypeEditor))]
|
||||
[DefaultValue(0)]
|
||||
[Description("按钮字体图标"), Category("SunnyUI")]
|
||||
public int ButtonSymbol
|
||||
{
|
||||
get => btn.Symbol;
|
||||
set => btn.Symbol = value;
|
||||
}
|
||||
|
||||
[DefaultValue(24)]
|
||||
[Description("按钮字体图标大小"), Category("SunnyUI")]
|
||||
public int ButtonSymbolSize
|
||||
{
|
||||
get => btn.SymbolSize;
|
||||
set => btn.SymbolSize = value;
|
||||
}
|
||||
|
||||
[DefaultValue(typeof(Point), "0, 0")]
|
||||
[Description("按钮字体图标的偏移位置"), Category("SunnyUI")]
|
||||
public Point ButtonSymbolOffset
|
||||
{
|
||||
get => btn.SymbolOffset;
|
||||
set => btn.SymbolOffset = value;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user