From 9c3d9003ac22e6b92ea46a8b7ce47f86d3b0ae19 Mon Sep 17 00:00:00 2001 From: wpfly Date: Wed, 12 May 2021 12:22:11 +0800 Subject: [PATCH 1/7] =?UTF-8?q?textbox=E6=94=AF=E6=8C=81=E5=B7=A6=E5=8F=B3?= =?UTF-8?q?padding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UITextBox.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/SunnyUI/Controls/UITextBox.cs b/SunnyUI/Controls/UITextBox.cs index 19842ca3..d66a0126 100644 --- a/SunnyUI/Controls/UITextBox.cs +++ b/SunnyUI/Controls/UITextBox.cs @@ -46,10 +46,11 @@ namespace Sunny.UI Height = MinHeight; ShowText = false; Font = UIFontColor.Font; + Padding = new Padding(0, 0, 0, 0); edit.Top = (Height - edit.Height) / 2; - edit.Left = 4; - edit.Width = Width - 8; + edit.Left = 4 + Padding.Left; + edit.Width = Width - 8 - Padding.Left - Padding.Right; edit.Text = String.Empty; edit.BorderStyle = BorderStyle.None; edit.TextChanged += EditTextChanged; @@ -330,6 +331,11 @@ namespace Sunny.UI SizeChange(); } + protected override void OnPaddingChanged(EventArgs e) + { + base.OnPaddingChanged(e); + } + public void SetScrollInfo() { if (bar == null) @@ -370,8 +376,8 @@ namespace Sunny.UI if (Height > MaxHeight) Height = MaxHeight; edit.Top = (Height - edit.Height) / 2; - edit.Left = 4; - edit.Width = Width - 8; + edit.Left = 4 + Padding.Left; + edit.Width = Width - 8 - Padding.Left - Padding.Right; } else { From 620bd8cf7e4fd5a95c636ee628a78cc79afd09b1 Mon Sep 17 00:00:00 2001 From: wpfly Date: Wed, 12 May 2021 14:44:39 +0800 Subject: [PATCH 2/7] =?UTF-8?q?textbox=E6=94=AF=E6=8C=81=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UITextBox.cs | 61 ++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/SunnyUI/Controls/UITextBox.cs b/SunnyUI/Controls/UITextBox.cs index d66a0126..0f0fc543 100644 --- a/SunnyUI/Controls/UITextBox.cs +++ b/SunnyUI/Controls/UITextBox.cs @@ -44,13 +44,14 @@ namespace Sunny.UI SetStyleFlags(); CalcEditHeight(); Height = MinHeight; + iconSize = MinHeight; ShowText = false; Font = UIFontColor.Font; Padding = new Padding(0, 0, 0, 0); edit.Top = (Height - edit.Height) / 2; - edit.Left = 4 + Padding.Left; - edit.Width = Width - 8 - Padding.Left - Padding.Right; + edit.Left = 4; + edit.Width = Width - 8; edit.Text = String.Empty; edit.BorderStyle = BorderStyle.None; edit.TextChanged += EditTextChanged; @@ -334,6 +335,7 @@ namespace Sunny.UI protected override void OnPaddingChanged(EventArgs e) { base.OnPaddingChanged(e); + SizeChange(); } public void SetScrollInfo() @@ -376,8 +378,16 @@ namespace Sunny.UI if (Height > MaxHeight) Height = MaxHeight; edit.Top = (Height - edit.Height) / 2; - edit.Left = 4 + Padding.Left; - edit.Width = Width - 8 - Padding.Left - Padding.Right; + if (icon == null) + { + edit.Left = 4 + Padding.Left; + edit.Width = Width - 8 - Padding.Left - Padding.Right; + } + else + { + edit.Left = 4 + iconSize + Padding.Left; + edit.Width = Width - 8 - iconSize - Padding.Left - Padding.Right; + } } else { @@ -813,5 +823,48 @@ namespace Sunny.UI { edit.Undo(); } + + private Image icon; + [Description("图标"), Category("SunnyUI")] + [DefaultValue(null)] + public Image Icon + { + get => icon; + set + { + icon = value; + SizeChange(); + Invalidate(); + } + } + + private int iconSize; + [Description("图标大小(方形)"), Category("SunnyUI")] + public int IconSize + { + get => iconSize; + set + { + if (value > Height - 8) + { + iconSize = Height - 8; + } + else + { + iconSize = value; + } + SizeChange(); + Invalidate(); + } + } + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + if (!multiline && icon != null) + { + e.Graphics.DrawImage(icon, new Rectangle(4, (Height - iconSize) / 2, iconSize, iconSize), new Rectangle(0, 0, iconSize, iconSize), GraphicsUnit.Pixel); + } + } } } \ No newline at end of file From abd32c20bd8b2f2ce1f438a2923c969a165ea1c1 Mon Sep 17 00:00:00 2001 From: wpfly Date: Wed, 12 May 2021 15:29:10 +0800 Subject: [PATCH 3/7] =?UTF-8?q?UIDropControl=E6=94=AF=E6=8C=81=E5=B7=A6pad?= =?UTF-8?q?ding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/DropItem/UIDropControl.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/SunnyUI/Controls/DropItem/UIDropControl.cs b/SunnyUI/Controls/DropItem/UIDropControl.cs index 3ab01518..84a5b55c 100644 --- a/SunnyUI/Controls/DropItem/UIDropControl.cs +++ b/SunnyUI/Controls/DropItem/UIDropControl.cs @@ -48,6 +48,7 @@ namespace Sunny.UI { InitializeComponent(); SetStyleFlags(); + Padding = new Padding(0, 0, 0, 0); edit.Font = UIFontColor.Font; edit.Left = 3; @@ -266,6 +267,12 @@ namespace Sunny.UI Invalidate(); } + protected override void OnPaddingChanged(EventArgs e) + { + base.OnPaddingChanged(e); + SizeChange(); + } + protected override void OnSizeChanged(EventArgs e) { SizeChange(); @@ -280,8 +287,8 @@ namespace Sunny.UI edt.Dispose(); edit.Top = (Height - edit.Height) / 2; - edit.Left = 3; - edit.Width = Width - 30; + edit.Left = 3 + Padding.Left; + edit.Width = Width - 30 - Padding.Left; } protected override void OnPaintFore(Graphics g, GraphicsPath path) @@ -295,7 +302,7 @@ namespace Sunny.UI g.DrawRoundRectangle(rectColor, new Rectangle(0, 0, Width, Height), Radius, true); } - Padding = new Padding(0, 0, 30, 2); + Padding = new Padding(Padding.Left, 0, 30, 2); g.FillRoundRectangle(GetFillColor(), new Rectangle(Width - 27, edit.Top, 25, edit.Height), Radius); Color color = GetRectColor(); SizeF sf = g.GetFontImageSize(dropSymbol, 24); From e36a92db5c8b35800c8cf5f995e7b50ee5ceedaa Mon Sep 17 00:00:00 2001 From: wpfly Date: Fri, 14 May 2021 23:20:29 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BF=AE=E6=AD=A3combobox=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E6=94=B9=E5=8F=98=E9=AB=98=E5=BA=A6=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E6=94=AF=E6=8C=81=E5=8F=B3padding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/DropItem/UIDropControl.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/SunnyUI/Controls/DropItem/UIDropControl.cs b/SunnyUI/Controls/DropItem/UIDropControl.cs index 84a5b55c..e95e1f74 100644 --- a/SunnyUI/Controls/DropItem/UIDropControl.cs +++ b/SunnyUI/Controls/DropItem/UIDropControl.cs @@ -280,15 +280,9 @@ namespace Sunny.UI private void SizeChange() { - TextBox edt = new TextBox(); - edt.Font = edit.Font; - edt.Invalidate(); - Height = edt.Height; - edt.Dispose(); - edit.Top = (Height - edit.Height) / 2; edit.Left = 3 + Padding.Left; - edit.Width = Width - 30 - Padding.Left; + edit.Width = Width - 30 - Padding.Left - Padding.Right; } protected override void OnPaintFore(Graphics g, GraphicsPath path) @@ -302,7 +296,7 @@ namespace Sunny.UI g.DrawRoundRectangle(rectColor, new Rectangle(0, 0, Width, Height), Radius, true); } - Padding = new Padding(Padding.Left, 0, 30, 2); + Padding = new Padding(Padding.Left, 0, 30 + Padding.Right, 2); g.FillRoundRectangle(GetFillColor(), new Rectangle(Width - 27, edit.Top, 25, edit.Height), Radius); Color color = GetRectColor(); SizeF sf = g.GetFontImageSize(dropSymbol, 24); From c015e40db440bd845bcd22f0a2a6208ebb2693af Mon Sep 17 00:00:00 2001 From: wpfly Date: Fri, 14 May 2021 23:22:03 +0800 Subject: [PATCH 5/7] =?UTF-8?q?IconSize=E9=AB=98=E5=BA=A6=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UITextBox.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/SunnyUI/Controls/UITextBox.cs b/SunnyUI/Controls/UITextBox.cs index 0f0fc543..dabd6bd3 100644 --- a/SunnyUI/Controls/UITextBox.cs +++ b/SunnyUI/Controls/UITextBox.cs @@ -845,14 +845,7 @@ namespace Sunny.UI get => iconSize; set { - if (value > Height - 8) - { - iconSize = Height - 8; - } - else - { - iconSize = value; - } + iconSize = value; SizeChange(); Invalidate(); } From e281b51b4c2ecd4cb4e5e3934ee00c5525e4ff75 Mon Sep 17 00:00:00 2001 From: wpfly Date: Sat, 15 May 2021 11:07:36 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcombobox=E7=9A=84padding?= =?UTF-8?q?=E5=80=BC=E8=87=AA=E5=8A=A8=E7=B4=AF=E5=8A=A0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/DropItem/UIDropControl.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/SunnyUI/Controls/DropItem/UIDropControl.cs b/SunnyUI/Controls/DropItem/UIDropControl.cs index e95e1f74..86f18ed5 100644 --- a/SunnyUI/Controls/DropItem/UIDropControl.cs +++ b/SunnyUI/Controls/DropItem/UIDropControl.cs @@ -269,6 +269,10 @@ namespace Sunny.UI protected override void OnPaddingChanged(EventArgs e) { + if (Padding.Right < 30 || Padding.Bottom < 2) + { + Padding = new Padding(Padding.Left, Padding.Top, Padding.Right < 30 ? 30 : Padding.Right, Padding.Bottom < 2 ? 2 : Padding.Bottom); + } base.OnPaddingChanged(e); SizeChange(); } @@ -282,7 +286,7 @@ namespace Sunny.UI { edit.Top = (Height - edit.Height) / 2; edit.Left = 3 + Padding.Left; - edit.Width = Width - 30 - Padding.Left - Padding.Right; + edit.Width = Width - Padding.Left - Padding.Right; } protected override void OnPaintFore(Graphics g, GraphicsPath path) @@ -296,7 +300,6 @@ namespace Sunny.UI g.DrawRoundRectangle(rectColor, new Rectangle(0, 0, Width, Height), Radius, true); } - Padding = new Padding(Padding.Left, 0, 30 + Padding.Right, 2); g.FillRoundRectangle(GetFillColor(), new Rectangle(Width - 27, edit.Top, 25, edit.Height), Radius); Color color = GetRectColor(); SizeF sf = g.GetFontImageSize(dropSymbol, 24); From 1d5e7ade10c4377daa185a9acf07e0c4dbe3be4d Mon Sep 17 00:00:00 2001 From: wpfly Date: Sat, 15 May 2021 11:14:22 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/DropItem/UIDropControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SunnyUI/Controls/DropItem/UIDropControl.cs b/SunnyUI/Controls/DropItem/UIDropControl.cs index 86f18ed5..e1c70a0d 100644 --- a/SunnyUI/Controls/DropItem/UIDropControl.cs +++ b/SunnyUI/Controls/DropItem/UIDropControl.cs @@ -48,7 +48,7 @@ namespace Sunny.UI { InitializeComponent(); SetStyleFlags(); - Padding = new Padding(0, 0, 0, 0); + Padding = new Padding(0, 0, 30, 2); edit.Font = UIFontColor.Font; edit.Left = 3;