From 9b7d27be4c99017c84ab88ec8ef82e2935ae0d05 Mon Sep 17 00:00:00 2001 From: Sunny Date: Thu, 3 Nov 2022 20:55:53 +0800 Subject: [PATCH] =?UTF-8?q?*=20UIFlowLayoutPanel:=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E5=8F=AF=E8=AE=BE=E7=BD=AE=E5=9E=82=E7=9B=B4=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E6=9D=A1=E5=AE=BD=E5=BA=A6=E7=9A=84=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UIFlowLayoutPanel.cs | 32 +++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/SunnyUI/Controls/UIFlowLayoutPanel.cs b/SunnyUI/Controls/UIFlowLayoutPanel.cs index d82895e2..2742a695 100644 --- a/SunnyUI/Controls/UIFlowLayoutPanel.cs +++ b/SunnyUI/Controls/UIFlowLayoutPanel.cs @@ -22,6 +22,7 @@ * 2021-08-11: V3.0.5 删除点击的Focus事件 * 2021-10-18: V3.0.8 增加Scroll事件 * 2021-11-05: V3.0.8 修改不同DPI缩放滚动条未覆盖的问题 + * 2022-11-03: V3.2.6 增加了可设置垂直滚动条宽度的属性 ******************************************************************************/ using System; @@ -64,6 +65,32 @@ namespace Sunny.UI timer.Start(); } + private int scrollBarWidth = 0; + + [DefaultValue(0), Category("SunnyUI"), Description("垂直滚动条宽度,最小为原生滚动条宽度")] + public int ScrollBarWidth + { + get => scrollBarWidth; + set + { + scrollBarWidth = value; + SetScrollInfo(); + } + } + + private int scrollBarHandleWidth = 6; + + [DefaultValue(6), Category("SunnyUI"), Description("垂直滚动条滑块宽度,最小为原生滚动条宽度")] + public int ScrollBarHandleWidth + { + get => scrollBarHandleWidth; + set + { + scrollBarHandleWidth = value; + if (VBar != null) VBar.FillWidth = value; + } + } + protected override void OnContextMenuStripChanged(EventArgs e) { base.OnContextMenuStripChanged(e); @@ -485,8 +512,9 @@ namespace Sunny.UI added = Radius / 2; } - VBar.Width = ScrollBarInfo.VerticalScrollBarWidth(); - VBar.Left = Width - VBar.Width - added; + int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth(), ScrollBarWidth); + VBar.Width = barWidth; + VBar.Left = Width - barWidth - added; VBar.Top = added; VBar.Height = Height - added * 2;