Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
42a042beb3 | ||
![]() |
123427892e | ||
![]() |
0b7f218b3c | ||
![]() |
c5e5a11188 |
@ -50,6 +50,7 @@
|
||||
* 2024-06-19: V3.6.7 增加AddDateTimeColumn,解决默认时间列不显示秒数的问题
|
||||
* 2024-08-27: V3.7.0 增加属性AutoScrollToBottom,数据更新时是否自动滚动到最后一行
|
||||
* 2024-09-04: V3.7.0 解决有隐藏行时,滚动条滚动时出错的问题
|
||||
* 2025-04-21: V3.8.3 修复数据更新时是否自动滚动到最后一行
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -1096,7 +1097,7 @@ namespace Sunny.UI
|
||||
//选中最后一行
|
||||
this.Rows[this.RowCount - 1].Selected = true;
|
||||
//滚动到最后一行
|
||||
SetRowHeight(this.RowCount - 1);
|
||||
this.FirstDisplayedScrollingRowIndex = this.RowCount - 1;
|
||||
//如果需要滚动到底部(右侧),使用下面的代码
|
||||
//this.FirstDisplayedCell = this.Rows[this.RowCount - 1].Cells[this.Columns.Count - 1];
|
||||
}
|
||||
|
@ -39,6 +39,7 @@
|
||||
* 2023-11-16: V3.5.2 重构主题
|
||||
* 2024-04-13: V3.6.5 修复通过代码设置背景色无效的问题
|
||||
* 2024-05-17: V3.6.6 防止控件闪烁
|
||||
* 2025-04-17: V3.8.3 增加节点文字居中的属性
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -106,6 +107,22 @@ namespace Sunny.UI
|
||||
selectedHighColor = UIStyles.Blue.NavMenuMenuSelectedColor;
|
||||
}
|
||||
|
||||
private NodeTextAlign _nodeTextAlign = NodeTextAlign.Left;
|
||||
|
||||
[DefaultValue(NodeTextAlign.Left), Category("SunnyUI"), Description("节点文字显示位置")]
|
||||
public NodeTextAlign NodeTextAlign
|
||||
{
|
||||
get => _nodeTextAlign;
|
||||
set
|
||||
{
|
||||
if (_nodeTextAlign != value)
|
||||
{
|
||||
_nodeTextAlign = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnHandleCreated(EventArgs e)
|
||||
{
|
||||
base.OnHandleCreated(e);
|
||||
@ -697,13 +714,25 @@ namespace Sunny.UI
|
||||
e.Graphics.FillRectangle(SelectedColor, new Rectangle(new Point(0, e.Node.Bounds.Y), new Size(Width, e.Node.Bounds.Height)));
|
||||
}
|
||||
|
||||
if (NodeTextAlign == NodeTextAlign.Left)
|
||||
e.Graphics.DrawString(e.Node.Text, Font, SelectedForeColor, new Rectangle(drawLeft, e.Bounds.Y, e.Bounds.Width - drawLeft, ItemHeight), ContentAlignment.MiddleLeft);
|
||||
if (NodeTextAlign == NodeTextAlign.TextAreaCenter)
|
||||
e.Graphics.DrawString(e.Node.Text, Font, SelectedForeColor, new Rectangle(drawLeft, e.Bounds.Y, e.Bounds.Width - drawLeft, ItemHeight), ContentAlignment.MiddleCenter);
|
||||
if (NodeTextAlign == NodeTextAlign.Center)
|
||||
e.Graphics.DrawString(e.Node.Text, Font, SelectedForeColor, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, ItemHeight), ContentAlignment.MiddleCenter);
|
||||
|
||||
e.Graphics.FillRectangle(SelectedHighColor, new Rectangle(0, e.Bounds.Y, 4, e.Bounds.Height));
|
||||
}
|
||||
else if (e.Node == CurrentNode && (e.State & TreeNodeStates.Hot) != 0)
|
||||
{
|
||||
e.Graphics.FillRectangle(HoverColor, new Rectangle(new Point(0, e.Node.Bounds.Y), new Size(Width, e.Node.Bounds.Height)));
|
||||
|
||||
if (NodeTextAlign == NodeTextAlign.Left)
|
||||
e.Graphics.DrawString(e.Node.Text, Font, ForeColor, new Rectangle(drawLeft, e.Bounds.Y, e.Bounds.Width - drawLeft, ItemHeight), ContentAlignment.MiddleLeft);
|
||||
if (NodeTextAlign == NodeTextAlign.TextAreaCenter)
|
||||
e.Graphics.DrawString(e.Node.Text, Font, ForeColor, new Rectangle(drawLeft, e.Bounds.Y, e.Bounds.Width - drawLeft, ItemHeight), ContentAlignment.MiddleCenter);
|
||||
if (NodeTextAlign == NodeTextAlign.Center)
|
||||
e.Graphics.DrawString(e.Node.Text, Font, ForeColor, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, ItemHeight), ContentAlignment.MiddleCenter);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -714,7 +743,13 @@ namespace Sunny.UI
|
||||
}
|
||||
|
||||
e.Graphics.FillRectangle(color, new Rectangle(new Point(0, e.Node.Bounds.Y), new Size(Width, e.Node.Bounds.Height)));
|
||||
|
||||
if (NodeTextAlign == NodeTextAlign.Left)
|
||||
e.Graphics.DrawString(e.Node.Text, Font, ForeColor, new Rectangle(drawLeft, e.Bounds.Y, e.Bounds.Width - drawLeft, ItemHeight), ContentAlignment.MiddleLeft);
|
||||
if (NodeTextAlign == NodeTextAlign.TextAreaCenter)
|
||||
e.Graphics.DrawString(e.Node.Text, Font, ForeColor, new Rectangle(drawLeft, e.Bounds.Y, e.Bounds.Width - drawLeft, ItemHeight), ContentAlignment.MiddleCenter);
|
||||
if (NodeTextAlign == NodeTextAlign.Center)
|
||||
e.Graphics.DrawString(e.Node.Text, Font, ForeColor, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, ItemHeight), ContentAlignment.MiddleCenter);
|
||||
}
|
||||
|
||||
//画右侧图标
|
||||
|
@ -205,6 +205,13 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
public enum NodeTextAlign
|
||||
{
|
||||
Left,
|
||||
Center,
|
||||
TextAreaCenter
|
||||
}
|
||||
|
||||
public class NavMenuItem : ISymbol
|
||||
{
|
||||
public string Text { get; set; }
|
||||
|
@ -38,6 +38,8 @@
|
||||
* 2024-12-12: V3.8.0 增加未选页签颜色 #IB7U69
|
||||
* 2025-02-07: V3.8.1 修复切换主题色时,TabPage 未设置背景色,#IBKDR7
|
||||
* 2025-02-13: V3.8.1 增加标签页分割线属性 ShowTabDivider,#IBLERL
|
||||
* 2025-04-17: V3.8.3 修复不可关闭的主页被关闭了 #IC1XIU
|
||||
* 2025-04-21: V3.8.3 更新部分注释
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -377,9 +379,9 @@ namespace Sunny.UI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 边框颜色
|
||||
/// 标签页默认背景颜色
|
||||
/// </summary>
|
||||
[Description("边框颜色"), Category("SunnyUI")]
|
||||
[Description("标签页默认背景颜色"), Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "56, 56, 56")]
|
||||
public Color TabBackColor
|
||||
{
|
||||
@ -398,7 +400,7 @@ namespace Sunny.UI
|
||||
private Color tabSelectedColor = Color.FromArgb(36, 36, 36);
|
||||
|
||||
/// <summary>
|
||||
/// 边框颜色
|
||||
/// 选中Tab页背景色
|
||||
/// </summary>
|
||||
[Description("选中Tab页背景色"), Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "36, 36, 36")]
|
||||
@ -419,9 +421,9 @@ namespace Sunny.UI
|
||||
private Color tabUnSelectedColor = Color.FromArgb(56, 56, 56);
|
||||
|
||||
/// <summary>
|
||||
/// 边框颜色
|
||||
/// 未选中Tab页背景色
|
||||
/// </summary>
|
||||
[Description("选中Tab页背景色"), Category("SunnyUI")]
|
||||
[Description("未选中Tab页背景色"), Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "56, 56, 56")]
|
||||
public Color TabUnSelectedColor
|
||||
{
|
||||
@ -440,7 +442,7 @@ namespace Sunny.UI
|
||||
private Color tabSelectedForeColor = UIColor.Blue;
|
||||
|
||||
/// <summary>
|
||||
/// 边框颜色
|
||||
/// 选中Tab页字体色
|
||||
/// </summary>
|
||||
[Description("选中Tab页字体色"), Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "80, 160, 255")]
|
||||
@ -460,7 +462,7 @@ namespace Sunny.UI
|
||||
private Color tabUnSelectedForeColor = Color.FromArgb(240, 240, 240);
|
||||
|
||||
/// <summary>
|
||||
/// 边框颜色
|
||||
/// 未选中Tab页字体色
|
||||
/// </summary>
|
||||
[Description("未选中Tab页字体色"), Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "240, 240, 240")]
|
||||
@ -481,7 +483,7 @@ namespace Sunny.UI
|
||||
private Color tabSelectedHighColor = UIColor.Blue;
|
||||
|
||||
/// <summary>
|
||||
/// 边框颜色
|
||||
/// 选中Tab页高亮
|
||||
/// </summary>
|
||||
[Description("选中Tab页高亮"), Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "80, 160, 255")]
|
||||
@ -819,7 +821,6 @@ namespace Sunny.UI
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
int removeIndex = -1;
|
||||
for (int index = 0; index <= TabCount - 1; index++)
|
||||
{
|
||||
@ -838,12 +839,12 @@ namespace Sunny.UI
|
||||
}
|
||||
|
||||
TabPage tabPage = TabPages[removeIndex];
|
||||
if (tabPage.Text == MainPage) return;
|
||||
UIPage uiPage = Helper.GetPage(tabPage);
|
||||
bool show1 = tabPage.Text != MainPage;
|
||||
bool show2 = uiPage == null || !uiPage.AlwaysOpen;
|
||||
bool showButton = show1 && show2;
|
||||
if (showButton)
|
||||
{
|
||||
if (uiPage == null) return;
|
||||
if (uiPage.Text == MainPage) return;
|
||||
if (uiPage.AlwaysOpen) return;
|
||||
|
||||
if (ShowCloseButton)
|
||||
{
|
||||
if (BeforeRemoveTabPage == null || BeforeRemoveTabPage.Invoke(this, removeIndex))
|
||||
@ -862,7 +863,6 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public delegate bool OnBeforeRemoveTabPage(object sender, int index);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user