* UINavMenu: 修复TipsText显示位置

This commit is contained in:
Sunny 2022-03-24 15:38:45 +08:00
parent a1ea6aaaaf
commit 4c96acd2c6
5 changed files with 5 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View File

@ -38,7 +38,7 @@ namespace Sunny.UI.Demo
Aside.CreateChildNode(parent, AddPage(new FOther(), ++pageIndex)); Aside.CreateChildNode(parent, AddPage(new FOther(), ++pageIndex));
//示例设置某个节点的小红点提示 //示例设置某个节点的小红点提示
Aside.ShowTips = true; Aside.ShowTips = true;
Aside.SetNodeTipsText(parent.Nodes[0], "6", Color.Red, Color.White); Aside.SetNodeTipsText(Aside.Nodes[0], "6", Color.Red, Color.White);
Aside.SetNodeTipsText(parent.Nodes[1], " ", Color.Lime, Color.White); Aside.SetNodeTipsText(parent.Nodes[1], " ", Color.Lime, Color.White);
pageIndex = 2000; pageIndex = 2000;

View File

@ -25,6 +25,7 @@
* 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显示位置
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -734,6 +735,7 @@ namespace Sunny.UI
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 ? ScrollBarInfo.VerticalScrollBarWidth() : 0) - sfMax - sfMax; float tipsLeft = Width - (ScrollBarVisible ? ScrollBarInfo.VerticalScrollBarWidth() : 0) - sfMax - sfMax;
if (e.Node.Nodes.Count > 0) tipsLeft -= 24;
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)

View File

@ -80,6 +80,8 @@ namespace Sunny.UI
TipsTexts[tabPage] = tipsText; TipsTexts[tabPage] = tipsText;
else else
TipsTexts.TryAdd(tabPage, tipsText); TipsTexts.TryAdd(tabPage, tipsText);
Invalidate();
} }
private string GetTipsText(TabPage tabPage) private string GetTipsText(TabPage tabPage)