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

* UIListBox: 增加了可设置垂直滚动条宽度的属性
* UITreeView: 增加了可设置垂直滚动条宽度的属性
This commit is contained in:
Sunny 2022-11-03 16:20:40 +08:00
parent 828cc082bc
commit 1f11be45fd
3 changed files with 101 additions and 4 deletions

View File

@ -23,6 +23,7 @@
* 2022-03-19: V3.1.1
* 2022-08-30: V3.2.3
* 2022-09-05: V3.2.3 ClickDoubleClick事件
* 2022-11-03: V3.2.6
******************************************************************************/
using System;
@ -78,6 +79,32 @@ namespace Sunny.UI
listbox.DrawItem += Listbox_DrawItem;
}
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;
}
}
public event DrawItemEventHandler DrawItem;
public new event EventHandler MouseLeave;
public new event EventHandler MouseEnter;
@ -199,9 +226,16 @@ namespace Sunny.UI
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
SetScrollInfo();
}
private void SetScrollInfo()
{
bar.Top = 2;
bar.Height = Height - 4;
bar.Left = Width - bar.Width - 2;
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth(), ScrollBarWidth);
bar.Width = barWidth + 1;
bar.Left = Width - barWidth - 2;
}
private void Listbox_BeforeDrawItem(object sender, ListBox.ObjectCollection items, DrawItemEventArgs e)

View File

@ -30,6 +30,7 @@
* 2022-03-19: V3.1.1
* 2022-05-15: V3.1.8
* 2022-09-05: V3.2.3 ClickDoubleClick事件
* 2022-11-03: V3.2.6
******************************************************************************/
using System;
@ -96,6 +97,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 (bar != null) bar.FillWidth = value;
}
}
public new event MouseEventHandler MouseDoubleClick;
private void Listbox_MouseDoubleClick(object sender, MouseEventArgs e)
@ -394,9 +421,16 @@ namespace Sunny.UI
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
SetScrollInfo();
}
private void SetScrollInfo()
{
bar.Top = 2;
bar.Height = Height - 4;
bar.Left = Width - bar.Width - 2;
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth(), ScrollBarWidth);
bar.Width = barWidth + 1;
bar.Left = Width - barWidth - 2;
}
private void Listbox_BeforeDrawItem(object sender, ObjectCollection items, DrawItemEventArgs e)

View File

@ -28,6 +28,7 @@
* 2022-05-15: V3.1.8
* 2022-05-15: V3.1.8 CheckBox状态的NodeClickChangeCheckBoxes
* 2022-10-28: V3.2.6 TreeNode支持imagekey绑定图标
* 2022-11-03: V3.2.6
******************************************************************************/
using System;
@ -87,6 +88,32 @@ namespace Sunny.UI
view.AfterLabelEdit += View_AfterLabelEdit;
}
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;
}
}
protected override void OnContextMenuStripChanged(EventArgs e)
{
base.OnContextMenuStripChanged(e);
@ -617,11 +644,13 @@ namespace Sunny.UI
view.Width = Width - 4;
view.Height = Height - 4;
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth(), ScrollBarWidth);
if (Bar != null)
{
Bar.Top = 2;
Bar.Left = Width - ScrollBarInfo.VerticalScrollBarWidth() - 2;
Bar.Width = ScrollBarInfo.VerticalScrollBarWidth();
Bar.Left = Width - barWidth - 2;
Bar.Width = barWidth;
Bar.Height = Height - 4;
}