Compare commits

...

4 Commits

4 changed files with 71 additions and 28 deletions

View File

@ -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];
}

View File

@ -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);
}
//画右侧图标

View File

@ -205,6 +205,13 @@ namespace Sunny.UI
}
}
public enum NodeTextAlign
{
Left,
Center,
TextAreaCenter
}
public class NavMenuItem : ISymbol
{
public string Text { get; set; }

View File

@ -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);