* UINavMenu: 增加自定义TipsText显示的颜色

This commit is contained in:
Sunny 2021-08-27 10:38:48 +08:00
parent 013b5084e1
commit d87af00562
20 changed files with 82 additions and 21 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,4 @@
namespace Sunny.UI.Demo.Charts
namespace Sunny.UI.Demo
{
partial class FDoughnutChart
{

View File

@ -1,6 +1,6 @@
using System;
namespace Sunny.UI.Demo.Charts
namespace Sunny.UI.Demo
{
public partial class FDoughnutChart : UIPage
{

View File

@ -1,4 +1,4 @@
namespace Sunny.UI.Demo.Charts
namespace Sunny.UI.Demo
{
partial class FLineChart
{

View File

@ -2,7 +2,7 @@
using System.Drawing;
using System.Text;
namespace Sunny.UI.Demo.Charts
namespace Sunny.UI.Demo
{
public partial class FLineChart : UIPage
{

View File

@ -1,4 +1,4 @@
namespace Sunny.UI.Demo.Controls
namespace Sunny.UI.Demo
{
partial class FPieChart
{

View File

@ -1,6 +1,6 @@
using System;
namespace Sunny.UI.Demo.Controls
namespace Sunny.UI.Demo
{
public partial class FPieChart : UIPage
{

View File

@ -1,7 +1,5 @@
using Sunny.UI.Demo.Charts;
using Sunny.UI.Demo.Controls;
using Sunny.UI.Demo.Forms;
using System;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Sunny.UI.Demo
@ -39,7 +37,8 @@ namespace Sunny.UI.Demo
Aside.CreateChildNode(parent, AddPage(new FOther(), ++pageIndex));
//示例设置某个节点的小红点提示
Aside.ShowTips = true;
Aside.SetNodeTipsText(parent.Nodes[0], "6");
Aside.SetNodeTipsText(parent.Nodes[0], "6", Color.Red, Color.White);
Aside.SetNodeTipsText(parent.Nodes[1], " ", Color.Lime, Color.White);
pageIndex = 2000;
Header.SetNodePageIndex(Header.Nodes[1], pageIndex);

View File

@ -1,4 +1,4 @@
namespace Sunny.UI.Demo.Forms
namespace Sunny.UI.Demo
{
partial class FEdit
{

View File

@ -1,4 +1,4 @@
namespace Sunny.UI.Demo.Forms
namespace Sunny.UI.Demo
{
public partial class FEdit : UIEditForm
{

View File

@ -1,4 +1,4 @@
namespace Sunny.UI.Demo.Forms
namespace Sunny.UI.Demo
{
partial class FEditor
{

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
namespace Sunny.UI.Demo.Forms
namespace Sunny.UI.Demo
{
public partial class FEditor : UIPage
{

View File

@ -151,7 +151,7 @@ namespace Sunny.UI
private Color tipsColor = Color.Red;
[Description("角标文字颜色"), Category("SunnyUI")]
[Description("角标背景颜色"), Category("SunnyUI")]
[DefaultValue(typeof(Color), "Red")]
public Color TipsColor
{
@ -163,6 +163,19 @@ namespace Sunny.UI
}
}
private Color tipsForeColor = Color.White;
[DefaultValue(typeof(Color), "White"), Category("SunnyUI"), Description("角标文字颜色")]
public Color TipsForeColor
{
get => tipsForeColor;
set
{
tipsForeColor = value;
Invalidate();
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
@ -175,7 +188,7 @@ namespace Sunny.UI
float x = Width - 1 - 2 - sfMax;
float y = 1 + 1;
e.Graphics.FillEllipse(TipsColor, x, y, sfMax, sfMax);
e.Graphics.DrawString(TipsText, TipsFont, Color.White, x + sfMax / 2.0f - sf.Width / 2.0f, y + sfMax / 2.0f - sf.Height / 2.0f);
e.Graphics.DrawString(TipsText, TipsFont, TipsForeColor, x + sfMax / 2.0f - sf.Width / 2.0f, y + sfMax / 2.0f - sf.Height / 2.0f);
}
if (Focused && ShowFocusLine)

View File

@ -21,6 +21,7 @@
* 2020-03-12: V3.0.2
* 2021-06-14: V3.0.4
* 2021-08-07: V3.0.5 /
* 2021-08-27: V3.0.6 TipsText显示的颜色
******************************************************************************/
using System;
@ -453,6 +454,11 @@ namespace Sunny.UI
MenuHelper.SetTipsText(node, tipsText);
}
public void SetNodeTipsText(TreeNode node, string tipsText, Color tipsBackColor, Color tipsForeColor)
{
MenuHelper.SetTipsText(node, tipsText, tipsBackColor, tipsForeColor);
}
public void SetNodeSymbol(TreeNode node, int symbol, int symbolSize = 24)
{
MenuHelper.SetSymbol(node, symbol, symbolSize);
@ -610,15 +616,26 @@ namespace Sunny.UI
float tipsLeft = Width - (ScrollBarVisible ? 50 : 30) - 6 - sfMax;
float tipsTop = e.Bounds.Y + (ItemHeight - sfMax) / 2;
e.Graphics.FillEllipse(TipsColor, tipsLeft, tipsTop, sfMax, sfMax);
e.Graphics.DrawString(MenuHelper.GetTipsText(e.Node), TipsFont, Color.White, tipsLeft + sfMax / 2.0f - tipsSize.Width / 2.0f, tipsTop + 1 + sfMax / 2.0f - tipsSize.Height / 2.0f);
if (MenuHelper[e.Node] != null)
{
if (MenuHelper[e.Node].TipsCustom)
{
e.Graphics.FillEllipse(MenuHelper[e.Node].TipsBackColor, tipsLeft, tipsTop, sfMax, sfMax);
e.Graphics.DrawString(MenuHelper.GetTipsText(e.Node), TipsFont, MenuHelper[e.Node].TipsForeColor, tipsLeft + sfMax / 2.0f - tipsSize.Width / 2.0f, tipsTop + 1 + sfMax / 2.0f - tipsSize.Height / 2.0f);
}
else
{
e.Graphics.FillEllipse(TipsColor, tipsLeft, tipsTop, sfMax, sfMax);
e.Graphics.DrawString(MenuHelper.GetTipsText(e.Node), TipsFont, TipsForeColor, tipsLeft + sfMax / 2.0f - tipsSize.Width / 2.0f, tipsTop + 1 + sfMax / 2.0f - tipsSize.Height / 2.0f);
}
}
}
}
}
private Color tipsColor = Color.Red;
[DefaultValue(typeof(Color), "Red")]
[DefaultValue(typeof(Color), "Red"), Category("SunnyUI"), Description("节点提示圆点背景颜色")]
public Color TipsColor
{
get => tipsColor;
@ -629,7 +646,20 @@ namespace Sunny.UI
}
}
[Description("展开节点后选中第一个子节点"), Category("SunnyUI")]
private Color tipsForeColor = Color.White;
[DefaultValue(typeof(Color), "White"), Category("SunnyUI"), Description("节点提示圆点文字颜色")]
public Color TipsForeColor
{
get => tipsForeColor;
set
{
tipsForeColor = value;
Invalidate();
}
}
[Description("展开节点后选中第一个子节点"), Category("SunnyUI"), DefaultValue(true)]
public bool ExpandSelectFirst { get; set; } = true;
public string Version { get; }

View File

@ -80,10 +80,23 @@ namespace Sunny.UI
if (node == null) return;
CreateIfNotExist(node);
Items[node].TipsCustom = false;
Items[node].TipsText = tips;
node.TreeView.Invalidate();
}
public void SetTipsText(TreeNode node, string tips, Color tipsBackColor, Color tipsForeColor)
{
if (node == null) return;
CreateIfNotExist(node);
Items[node].TipsCustom = true;
Items[node].TipsText = tips;
Items[node].TipsBackColor = tipsBackColor;
Items[node].TipsForeColor = tipsForeColor;
node.TreeView.Invalidate();
}
public void SetPageIndex(TreeNode node, int index)
{
if (node == null) return;
@ -374,6 +387,12 @@ namespace Sunny.UI
public string TipsText { get; set; }
public bool TipsCustom { get; set; }
public Color TipsBackColor { get; set; }
public Color TipsForeColor { get; set; }
public bool Enabled { get; set; } = true;
public object Tag { get; set; }