* UIRichTextBox: 增加了可设置垂直滚动条宽度的属性

* UITextBox: 增加了可设置垂直滚动条宽度的属性
This commit is contained in:
Sunny 2022-11-03 21:31:40 +08:00
parent 9b7d27be4c
commit 04a1e69233
2 changed files with 58 additions and 2 deletions

View File

@ -21,6 +21,7 @@
* 2021-07-29: V3.0.5
* 2022-02-23: V3.1.1
* 2022-03-14: V3.1.1
* 2022-11-03: V3.2.6
******************************************************************************/
using System;
@ -93,6 +94,32 @@ namespace Sunny.UI
public new event MouseEventHandler MouseMove;
public new event EventHandler MouseLeave;
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 (bar != null) bar.FillWidth = value;
}
}
private void Edit_MouseMove(object sender, MouseEventArgs e)
{
MouseMove?.Invoke(this, e);
@ -418,7 +445,8 @@ namespace Sunny.UI
public void SetScrollInfo()
{
bar.Width = ScrollBarInfo.VerticalScrollBarWidth() + 1;
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth() + 1, ScrollBarWidth);
bar.Width = barWidth;
bar.Left = Width - bar.Width - 1;
if (bar == null)
{

View File

@ -40,6 +40,7 @@
* 2022-09-05: V3.2.3
* 2022-09-16: V3.2.4
* 2022-09-16: V3.2.4 Button可能不显示的问题
* 2022-11-03: V3.2.6
******************************************************************************/
using System;
@ -128,6 +129,32 @@ namespace Sunny.UI
TextAlignmentChange += UITextBox_TextAlignmentChange;
}
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 (bar != null) bar.FillWidth = value;
}
}
private void Edit_SelectionChanged(object sender, UITextBoxSelectionArgs e)
{
SelectionChanged?.Invoke(this, e);
@ -627,8 +654,9 @@ namespace Sunny.UI
edit.Left = 1;
edit.Width = Width - 2;
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth() + 1, ScrollBarWidth);
bar.Top = 2;
bar.Width = ScrollBarInfo.VerticalScrollBarWidth();
bar.Width = barWidth;
bar.Left = Width - bar.Width - 1;
bar.Height = Height - 4;
bar.BringToFront();