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

This commit is contained in:
Sunny 2022-11-03 19:50:41 +08:00
parent 94ad1bad69
commit 183fa9d420

View File

@ -1,34 +1,35 @@
/****************************************************************************** /******************************************************************************
* SunnyUI * SunnyUI
* CopyRight (C) 2012-2022 ShenYongHua(). * CopyRight (C) 2012-2022 ShenYongHua().
* QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com * QQ群56829229 QQ17612584 EMailSunnyUI@QQ.Com
* *
* Blog: https://www.cnblogs.com/yhuse * Blog: https://www.cnblogs.com/yhuse
* Gitee: https://gitee.com/yhuse/SunnyUI * Gitee: https://gitee.com/yhuse/SunnyUI
* GitHub: https://github.com/yhuse/SunnyUI * GitHub: https://github.com/yhuse/SunnyUI
* *
* SunnyUI.dll can be used for free under the GPL-3.0 license. * SunnyUI.dll can be used for free under the GPL-3.0 license.
* If you use this code, please keep this note. * If you use this code, please keep this note.
* 使 * 使
****************************************************************************** ******************************************************************************
* : UINavMenu.cs * : UINavMenu.cs
* : * :
* : V3.1 * : V3.1
* : 2020-01-01 * : 2020-01-01
* *
* 2020-01-01: V2.2.0 * 2020-01-01: V2.2.0
* 2020-07-01: V2.2.6 * 2020-07-01: V2.2.6
* 2020-03-12: V3.0.2 * 2020-03-12: V3.0.2
* 2021-06-14: V3.0.4 * 2021-06-14: V3.0.4
* 2021-08-07: V3.0.5 / * 2021-08-07: V3.0.5 /
* 2021-08-27: V3.0.6 TipsText显示的颜色 * 2021-08-27: V3.0.6 TipsText显示的颜色
* 2021-12-13: V3.0.9 * 2021-12-13: V3.0.9
* 2022-01-02: V3.0.9 * 2022-01-02: V3.0.9
* 2022-03-19: V3.1.1 * 2022-03-19: V3.1.1
* 2022-03-24: V3.1.1 TipsText显示位置 * 2022-03-24: V3.1.1 TipsText显示位置
* 2022-04-14: V3.1.3 * 2022-04-14: V3.1.3
* 2022-06-23: V3.2.0 SymbolOffset * 2022-06-23: V3.2.0 SymbolOffset
* 2022-08-19: V3.2.3 * 2022-08-19: V3.2.3
* 2022-11-03: V3.2.6
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -689,7 +690,7 @@ namespace Sunny.UI
if (TreeNodeSymbols.ContainsKey(e.Node) && TreeNodeSymbols[e.Node].Count > 0) if (TreeNodeSymbols.ContainsKey(e.Node) && TreeNodeSymbols[e.Node].Count > 0)
{ {
int symbolRight = Width - (ScrollBarVisible ? Bar.Width : 0) - 3; int symbolRight = Width - (ScrollBarVisible ? ScrollBarInfo.VerticalScrollBarWidth() : 0) - 3;
if (e.Node.Nodes.Count > 0) symbolRight -= 32; if (e.Node.Nodes.Count > 0) symbolRight -= 32;
int firstLeft = symbolRight - TreeNodeSymbols[e.Node].Count * 32; int firstLeft = symbolRight - TreeNodeSymbols[e.Node].Count * 32;
@ -706,7 +707,7 @@ namespace Sunny.UI
if (TreeNodeSymbols.ContainsKey(e.Node) && TreeNodeSymbols[e.Node].Count > 0) if (TreeNodeSymbols.ContainsKey(e.Node) && TreeNodeSymbols[e.Node].Count > 0)
{ {
int symbolRight = Width - (ScrollBarVisible ? Bar.Width : 0) - 3; int symbolRight = Width - (ScrollBarVisible ? ScrollBarInfo.VerticalScrollBarWidth() : 0) - 3;
if (e.Node.Nodes.Count > 0) symbolRight -= 32; if (e.Node.Nodes.Count > 0) symbolRight -= 32;
int firstLeft = symbolRight - TreeNodeSymbols[e.Node].Count * 32; int firstLeft = symbolRight - TreeNodeSymbols[e.Node].Count * 32;
@ -746,17 +747,22 @@ namespace Sunny.UI
} }
} }
//显示右侧下拉箭头
if (ShowItemsArrow && e.Node.Nodes.Count > 0) if (ShowItemsArrow && e.Node.Nodes.Count > 0)
{ {
e.Graphics.DrawFontImage(e.Node.IsExpanded ? 61702 : 61703, 24, ForeColor, Width - (Bar.Visible ? 50 : 30), e.Bounds.Y + (ItemHeight - 24) / 2); int size = 24;
int left = Width - size - 6;
if (Bar.Visible) left -= Bar.Width;
e.Graphics.DrawFontImage(e.Node.IsExpanded ? 61702 : 61703, 24, ForeColor, left, e.Bounds.Y + (ItemHeight - 24) / 2);
} }
if (ShowTips && MenuHelper.GetTipsText(e.Node).IsValid() && TreeNodeSymbols.NotContainsKey(e.Node)) if (ShowTips && MenuHelper.GetTipsText(e.Node).IsValid() && TreeNodeSymbols.NotContainsKey(e.Node))
{ {
SizeF tipsSize = e.Graphics.MeasureString(MenuHelper.GetTipsText(e.Node), TempFont); SizeF tipsSize = e.Graphics.MeasureString(MenuHelper.GetTipsText(e.Node), TempFont);
float sfMax = Math.Max(tipsSize.Width, tipsSize.Height) + 1; float sfMax = Math.Max(tipsSize.Width, tipsSize.Height) + 1;
float tipsLeft = Width - (ScrollBarVisible ? Bar.Width : 0) - sfMax - sfMax; float tipsLeft = Width - sfMax - 16;
if (e.Node.Nodes.Count > 0) tipsLeft -= 24; if (e.Node.Nodes.Count > 0) tipsLeft -= 24;
if (Bar.Visible) tipsLeft -= Bar.Width;
float tipsTop = e.Bounds.Y + (ItemHeight - sfMax) / 2; float tipsTop = e.Bounds.Y + (ItemHeight - sfMax) / 2;
if (MenuHelper[e.Node] != null) if (MenuHelper[e.Node] != null)
@ -855,7 +861,7 @@ namespace Sunny.UI
if (e.Node != null && TreeNodeSymbols.ContainsKey(e.Node) && TreeNodeSymbols[e.Node].Count > 0) if (e.Node != null && TreeNodeSymbols.ContainsKey(e.Node) && TreeNodeSymbols[e.Node].Count > 0)
{ {
int symbolRight = Width - (ScrollBarVisible ? Bar.Width : 0) - 3; int symbolRight = Width - (ScrollBarVisible ? ScrollBarInfo.VerticalScrollBarWidth() : 0) - 3;
if (e.Node.Nodes.Count > 0) symbolRight -= 32; if (e.Node.Nodes.Count > 0) symbolRight -= 32;
int firstLeft = symbolRight - TreeNodeSymbols[e.Node].Count * 32; int firstLeft = symbolRight - TreeNodeSymbols[e.Node].Count * 32;
if (e.X >= firstLeft && e.X < symbolRight) if (e.X >= firstLeft && e.X < symbolRight)
@ -941,7 +947,7 @@ namespace Sunny.UI
Bar.Maximum = si.ScrollMax; Bar.Maximum = si.ScrollMax;
Bar.Visible = si.ScrollMax > 0 && si.nMax > 0 && si.nPage > 0; Bar.Visible = si.ScrollMax > 0 && si.nMax > 0 && si.nPage > 0;
Bar.Value = si.nPos; Bar.Value = si.nPos;
Bar.Width = barWidth + 1; Bar.Width = barWidth;
Bar.BringToFront(); Bar.BringToFront();
if (ScrollBarVisible != Bar.Visible) if (ScrollBarVisible != Bar.Visible)