* 重构主题
This commit is contained in:
parent
48f52bf290
commit
70c3a7d690
@ -1019,8 +1019,6 @@ namespace Sunny.UI
|
||||
scrollBarColor = UIStyles.Blue.GridBarForeColor;
|
||||
scrollBarBackColor = UIStyles.Blue.GridBarFillColor;
|
||||
scrollBarRectColor = VBar.RectColor = UIStyles.Blue.RectColor;
|
||||
scrollBarColor = UIStyles.Blue.GridBarForeColor;
|
||||
scrollBarBackColor = UIStyles.Blue.GridBarFillColor;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,9 +58,8 @@ namespace Sunny.UI
|
||||
Panel.ControlRemoved += Panel_ControlRemoved;
|
||||
Panel.Scroll += Panel_Scroll;
|
||||
Panel.MouseWheel += Panel_MouseWheel;
|
||||
Panel.MouseEnter += Panel_MouseEnter;
|
||||
Panel.MouseClick += Panel_MouseClick;
|
||||
Panel.ClientSizeChanged += Panel_ClientSizeChanged;
|
||||
Panel.BackColor = UIStyles.Blue.PlainColor;
|
||||
|
||||
VBar.ValueChanged += VBar_ValueChanged;
|
||||
HBar.ValueChanged += HBar_ValueChanged;
|
||||
@ -328,7 +327,7 @@ namespace Sunny.UI
|
||||
base.SetStyleColor(uiColor);
|
||||
Panel.BackColor = uiColor.PlainColor;
|
||||
|
||||
if (HBar != null)
|
||||
if (HBar != null && HBar.Style == UIStyle.Inherited)
|
||||
{
|
||||
HBar.ForeColor = uiColor.GridBarForeColor;
|
||||
HBar.HoverColor = uiColor.ButtonFillHoverColor;
|
||||
@ -338,7 +337,7 @@ namespace Sunny.UI
|
||||
scrollBarBackColor = uiColor.GridBarFillColor;
|
||||
}
|
||||
|
||||
if (VBar != null)
|
||||
if (VBar != null && VBar.Style == UIStyle.Inherited)
|
||||
{
|
||||
VBar.ForeColor = uiColor.GridBarForeColor;
|
||||
VBar.HoverColor = uiColor.ButtonFillHoverColor;
|
||||
@ -370,6 +369,7 @@ namespace Sunny.UI
|
||||
scrollBarColor = value;
|
||||
HBar.HoverColor = HBar.PressColor = HBar.ForeColor = value;
|
||||
VBar.HoverColor = VBar.PressColor = VBar.ForeColor = value;
|
||||
HBar.Style = VBar.Style = UIStyle.Custom;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
@ -389,18 +389,30 @@ namespace Sunny.UI
|
||||
scrollBarBackColor = value;
|
||||
HBar.FillColor = value;
|
||||
VBar.FillColor = value;
|
||||
HBar.Style = VBar.Style = UIStyle.Custom;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void Panel_MouseClick(object sender, MouseEventArgs e)
|
||||
/// <summary>
|
||||
/// 滚动条主题样式
|
||||
/// </summary>
|
||||
[DefaultValue(true), Description("滚动条主题样式"), Category("SunnyUI")]
|
||||
public bool ScrollBarStyleInherited
|
||||
{
|
||||
//Panel.Focus();
|
||||
get => HBar != null && HBar.Style == UIStyle.Inherited;
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (HBar != null) HBar.Style = UIStyle.Inherited;
|
||||
if (VBar != null) VBar.Style = UIStyle.Inherited;
|
||||
|
||||
scrollBarColor = UIStyles.Blue.GridBarForeColor;
|
||||
scrollBarBackColor = UIStyles.Blue.GridBarFillColor;
|
||||
}
|
||||
|
||||
private void Panel_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
//Panel.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
|
@ -53,7 +53,6 @@ namespace Sunny.UI
|
||||
bar.Width = SystemInformation.VerticalScrollBarWidth + 2;
|
||||
bar.Parent = this;
|
||||
bar.Dock = DockStyle.None;
|
||||
bar.Style = UIStyle.Custom;
|
||||
bar.Visible = false;
|
||||
|
||||
listbox.Parent = this;
|
||||
@ -93,6 +92,63 @@ namespace Sunny.UI
|
||||
listbox?.Dispose();
|
||||
}
|
||||
|
||||
private Color scrollBarColor = Color.FromArgb(80, 160, 255);
|
||||
|
||||
/// <summary>
|
||||
/// 填充颜色,当值为背景色或透明色或空值则不填充
|
||||
/// </summary>
|
||||
[Description("滚动条填充颜色"), Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "80, 160, 255")]
|
||||
public Color ScrollBarColor
|
||||
{
|
||||
get => scrollBarColor;
|
||||
set
|
||||
{
|
||||
scrollBarColor = value;
|
||||
bar.HoverColor = bar.PressColor = bar.ForeColor = value;
|
||||
bar.Style = UIStyle.Custom;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private Color scrollBarBackColor = Color.FromArgb(243, 249, 255);
|
||||
|
||||
/// <summary>
|
||||
/// 填充颜色,当值为背景色或透明色或空值则不填充
|
||||
/// </summary>
|
||||
[Description("滚动条背景颜色"), Category("SunnyUI")]
|
||||
[DefaultValue(typeof(Color), "243, 249, 255")]
|
||||
public Color ScrollBarBackColor
|
||||
{
|
||||
get => scrollBarBackColor;
|
||||
set
|
||||
{
|
||||
scrollBarBackColor = value;
|
||||
bar.FillColor = value;
|
||||
bar.Style = UIStyle.Custom;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 滚动条主题样式
|
||||
/// </summary>
|
||||
[DefaultValue(true), Description("滚动条主题样式"), Category("SunnyUI")]
|
||||
public bool ScrollBarStyleInherited
|
||||
{
|
||||
get => bar != null && bar.Style == UIStyle.Inherited;
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (bar != null) bar.Style = UIStyle.Inherited;
|
||||
|
||||
scrollBarColor = UIStyles.Blue.ListBarForeColor;
|
||||
scrollBarBackColor = UIStyles.Blue.ListBarFillColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int scrollBarWidth = 0;
|
||||
|
||||
[DefaultValue(0), Category("SunnyUI"), Description("垂直滚动条宽度,最小为原生滚动条宽度")]
|
||||
@ -246,9 +302,9 @@ namespace Sunny.UI
|
||||
{
|
||||
bar.Top = 2;
|
||||
bar.Height = Height - 4;
|
||||
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth(), ScrollBarWidth);
|
||||
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth() + Padding.Right, ScrollBarWidth);
|
||||
bar.Width = barWidth + 1;
|
||||
bar.Left = Width - barWidth - 2;
|
||||
bar.Left = Width - barWidth - 3;
|
||||
}
|
||||
|
||||
private void Listbox_BeforeDrawItem(object sender, ListBox.ObjectCollection items, DrawItemEventArgs e)
|
||||
@ -326,12 +382,15 @@ namespace Sunny.UI
|
||||
public override void SetStyleColor(UIBaseStyle uiColor)
|
||||
{
|
||||
base.SetStyleColor(uiColor);
|
||||
if (bar != null)
|
||||
if (bar != null && bar.Style == UIStyle.Inherited)
|
||||
{
|
||||
bar.ForeColor = uiColor.ListBarForeColor;
|
||||
bar.HoverColor = uiColor.ButtonFillHoverColor;
|
||||
bar.PressColor = uiColor.ButtonFillPressColor;
|
||||
bar.FillColor = uiColor.ListBarFillColor;
|
||||
|
||||
scrollBarColor = uiColor.ListBarForeColor;
|
||||
scrollBarBackColor = uiColor.ListBarFillColor;
|
||||
}
|
||||
|
||||
hoverColor = uiColor.ListItemHoverColor;
|
||||
@ -820,11 +879,7 @@ namespace Sunny.UI
|
||||
public Color HoverColor
|
||||
{
|
||||
get => hoverColor;
|
||||
set
|
||||
{
|
||||
hoverColor = value;
|
||||
Invalidate();
|
||||
}
|
||||
set => hoverColor = value;
|
||||
}
|
||||
|
||||
private int lastIndex = -1;
|
||||
|
@ -31,6 +31,7 @@
|
||||
* 2022-05-15: V3.1.8 增加滚动条颜色设置
|
||||
* 2022-09-05: V3.2.3 修复Click,DoubleClick事件
|
||||
* 2022-11-03: V3.2.6 增加了可设置垂直滚动条宽度的属性
|
||||
* 2023-11-16: V3.5.2 重构主题
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -60,7 +61,6 @@ namespace Sunny.UI
|
||||
bar.Width = SystemInformation.VerticalScrollBarWidth + 2;
|
||||
bar.Parent = this;
|
||||
bar.Dock = DockStyle.None;
|
||||
bar.Style = UIStyle.Custom;
|
||||
bar.Visible = false;
|
||||
|
||||
listbox.Parent = this;
|
||||
@ -150,7 +150,7 @@ namespace Sunny.UI
|
||||
{
|
||||
scrollBarColor = value;
|
||||
bar.HoverColor = bar.PressColor = bar.ForeColor = value;
|
||||
_style = UIStyle.Custom;
|
||||
bar.Style = UIStyle.Custom;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
@ -169,11 +169,30 @@ namespace Sunny.UI
|
||||
{
|
||||
scrollBarBackColor = value;
|
||||
bar.FillColor = value;
|
||||
_style = UIStyle.Custom;
|
||||
bar.Style = UIStyle.Custom;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 滚动条主题样式
|
||||
/// </summary>
|
||||
[DefaultValue(true), Description("滚动条主题样式"), Category("SunnyUI")]
|
||||
public bool ScrollBarStyleInherited
|
||||
{
|
||||
get => bar != null && bar.Style == UIStyle.Inherited;
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (bar != null) bar.Style = UIStyle.Inherited;
|
||||
|
||||
scrollBarColor = UIStyles.Blue.ListBarForeColor;
|
||||
scrollBarBackColor = UIStyles.Blue.ListBarFillColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Listbox_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
DrawItem?.Invoke(sender, e);
|
||||
@ -436,9 +455,9 @@ namespace Sunny.UI
|
||||
{
|
||||
bar.Top = 2;
|
||||
bar.Height = Height - 4;
|
||||
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth(), ScrollBarWidth);
|
||||
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth() + Padding.Right, ScrollBarWidth);
|
||||
bar.Width = barWidth + 1;
|
||||
bar.Left = Width - barWidth - 2;
|
||||
bar.Left = Width - barWidth - 3;
|
||||
}
|
||||
|
||||
private void Listbox_BeforeDrawItem(object sender, ObjectCollection items, DrawItemEventArgs e)
|
||||
@ -498,7 +517,7 @@ namespace Sunny.UI
|
||||
{
|
||||
base.SetStyleColor(uiColor);
|
||||
|
||||
if (bar != null)
|
||||
if (bar != null && bar.Style == UIStyle.Inherited)
|
||||
{
|
||||
bar.ForeColor = uiColor.ListBarForeColor;
|
||||
bar.HoverColor = uiColor.ButtonFillHoverColor;
|
||||
@ -627,7 +646,6 @@ namespace Sunny.UI
|
||||
{
|
||||
hoverColor = value;
|
||||
listbox.HoverColor = hoverColor;
|
||||
_style = UIStyle.Custom;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,6 @@ namespace Sunny.UI
|
||||
edit.Click += Edit_Click;
|
||||
|
||||
bar.Parent = this;
|
||||
bar.Style = UIStyle.Custom;
|
||||
bar.Visible = false;
|
||||
bar.ValueChanged += Bar_ValueChanged;
|
||||
bar.MouseEnter += Bar_MouseEnter;
|
||||
@ -320,7 +319,7 @@ namespace Sunny.UI
|
||||
edit.BackColor = GetFillColor();
|
||||
edit.ForeColor = GetForeColor();
|
||||
|
||||
if (bar != null)
|
||||
if (bar != null && bar.Style == UIStyle.Inherited)
|
||||
{
|
||||
bar.ForeColor = uiColor.PrimaryColor;
|
||||
bar.HoverColor = uiColor.ButtonFillHoverColor;
|
||||
@ -331,6 +330,25 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 滚动条主题样式
|
||||
/// </summary>
|
||||
[DefaultValue(true), Description("滚动条主题样式"), Category("SunnyUI")]
|
||||
public bool ScrollBarStyleInherited
|
||||
{
|
||||
get => bar != null && bar.Style == UIStyle.Inherited;
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (bar != null) bar.Style = UIStyle.Inherited;
|
||||
scrollBarColor = UIStyles.Blue.PrimaryColor;
|
||||
scrollBarBackColor = UIStyles.Blue.EditorBackColor;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private Color scrollBarColor = Color.FromArgb(80, 160, 255);
|
||||
|
||||
/// <summary>
|
||||
@ -345,6 +363,7 @@ namespace Sunny.UI
|
||||
{
|
||||
scrollBarColor = value;
|
||||
bar.HoverColor = bar.PressColor = bar.ForeColor = value;
|
||||
bar.Style = UIStyle.Custom;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
@ -363,6 +382,7 @@ namespace Sunny.UI
|
||||
{
|
||||
scrollBarBackColor = value;
|
||||
bar.FillColor = value;
|
||||
bar.Style = UIStyle.Custom;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
@ -451,13 +471,10 @@ namespace Sunny.UI
|
||||
|
||||
public void SetScrollInfo()
|
||||
{
|
||||
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth() + 1, ScrollBarWidth);
|
||||
bar.Width = barWidth;
|
||||
bar.Left = Width - bar.Width - 1;
|
||||
if (bar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth() + 2, ScrollBarWidth);
|
||||
if (bar == null) return;
|
||||
bar.Width = barWidth + 1;
|
||||
bar.Left = Width - barWidth - 3;
|
||||
|
||||
var si = ScrollBarInfo.GetInfo(edit.Handle);
|
||||
if (si.ScrollMax > 0)
|
||||
@ -475,9 +492,10 @@ namespace Sunny.UI
|
||||
|
||||
private void SizeChange()
|
||||
{
|
||||
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth() + 2, ScrollBarWidth);
|
||||
bar.Top = 2;
|
||||
bar.Width = ScrollBarInfo.VerticalScrollBarWidth() + 1;
|
||||
bar.Left = Width - bar.Width - 1;
|
||||
bar.Width = barWidth + 1;
|
||||
bar.Left = Width - barWidth - 3;
|
||||
bar.Height = Height - 4;
|
||||
bar.BringToFront();
|
||||
SetScrollInfo();
|
||||
|
@ -54,6 +54,7 @@
|
||||
* 2023-10-25: V3.5.1 修复在高DPI下,文字垂直不居中的问题
|
||||
* 2023-10-25: V3.5.1 修复在某些字体不显示下划线的问题
|
||||
* 2023-10-26: V3.5.1 字体图标增加旋转角度参数SymbolRotate
|
||||
* 2023-11-16: V3.5.2 重构主题
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -128,7 +129,6 @@ namespace Sunny.UI
|
||||
|
||||
bar.Parent = this;
|
||||
bar.Dock = DockStyle.None;
|
||||
bar.Style = UIStyle.Custom;
|
||||
bar.Visible = false;
|
||||
bar.ValueChanged += Bar_ValueChanged;
|
||||
bar.MouseEnter += Bar_MouseEnter;
|
||||
@ -767,10 +767,10 @@ namespace Sunny.UI
|
||||
edit.Left = 4;
|
||||
edit.Width = Width - 8;
|
||||
|
||||
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth() + 1, ScrollBarWidth);
|
||||
int barWidth = Math.Max(ScrollBarInfo.VerticalScrollBarWidth() + 2, ScrollBarWidth);
|
||||
bar.Top = 2;
|
||||
bar.Width = barWidth;
|
||||
bar.Left = Width - bar.Width - 2;
|
||||
bar.Width = barWidth + 1;
|
||||
bar.Left = Width - barWidth - 3;
|
||||
bar.Height = Height - 4;
|
||||
bar.BringToFront();
|
||||
|
||||
@ -920,7 +920,7 @@ namespace Sunny.UI
|
||||
edit.ForeColor = GetForeColor();
|
||||
edit.ForeDisableColor = uiColor.ForeDisableColor;
|
||||
|
||||
if (bar != null)
|
||||
if (bar != null && bar.Style == UIStyle.Inherited)
|
||||
{
|
||||
bar.ForeColor = uiColor.PrimaryColor;
|
||||
bar.HoverColor = uiColor.ButtonFillHoverColor;
|
||||
@ -946,6 +946,25 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 滚动条主题样式
|
||||
/// </summary>
|
||||
[DefaultValue(true), Description("滚动条主题样式"), Category("SunnyUI")]
|
||||
public bool ScrollBarStyleInherited
|
||||
{
|
||||
get => bar != null && bar.Style == UIStyle.Inherited;
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (bar != null) bar.Style = UIStyle.Inherited;
|
||||
scrollBarColor = UIStyles.Blue.PrimaryColor;
|
||||
scrollBarBackColor = UIStyles.Blue.EditorBackColor;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetForeDisableColor(Color color)
|
||||
{
|
||||
base.SetForeDisableColor(color);
|
||||
@ -966,6 +985,7 @@ namespace Sunny.UI
|
||||
{
|
||||
scrollBarColor = value;
|
||||
bar.HoverColor = bar.PressColor = bar.ForeColor = value;
|
||||
bar.Style = UIStyle.Custom;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
@ -984,7 +1004,7 @@ namespace Sunny.UI
|
||||
{
|
||||
scrollBarBackColor = value;
|
||||
bar.FillColor = value;
|
||||
_style = UIStyle.Custom;
|
||||
bar.Style = UIStyle.Custom;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user