* UISplitContainer: 增加主题样式

This commit is contained in:
Sunny 2022-04-03 16:03:23 +08:00
parent 93e10483d3
commit d11e4d4a5e
3 changed files with 84 additions and 2 deletions

Binary file not shown.

View File

@ -17,6 +17,7 @@
* : 2021-10-30
*
* 2021-10-30: V3.0.8
* 2022-04-03: V3.1.3
******************************************************************************/
using System;
using System.ComponentModel;
@ -25,7 +26,7 @@ using System.Windows.Forms;
namespace Sunny.UI
{
public class UISplitContainer : SplitContainer
public class UISplitContainer : SplitContainer, IStyleInterface
{
private enum UIMouseType
{
@ -75,6 +76,13 @@ namespace Sunny.UI
_lastDistance = SplitterDistance;
SplitterWidth = 10;
MinimumSize = new Size(20, 20);
Version = UIGlobal.Version;
}
protected void SetStyleCustom(bool needRefresh = true)
{
_style = UIStyle.Custom;
if (needRefresh) Invalidate();
}
private Color barColor = Color.FromArgb(56, 56, 56);
@ -129,7 +137,7 @@ namespace Sunny.UI
set
{
arrowColor = value;
Invalidate();
SetStyleCustom();
}
}
@ -219,6 +227,46 @@ namespace Sunny.UI
}
}
protected UIStyle _style = UIStyle.Blue;
/// <summary>
/// 主题样式
/// </summary>
[DefaultValue(UIStyle.Blue), Description("主题样式"), Category("SunnyUI")]
public UIStyle Style
{
get => _style;
set => SetStyle(value);
}
/// <summary>
/// 自定义主题风格
/// </summary>
[DefaultValue(false)]
[Description("获取或设置可以自定义主题风格"), Category("SunnyUI")]
public bool StyleCustomMode { get; set; }
/// <summary>
/// 版本
/// </summary>
public string Version
{
get;
}
/// <summary>
/// Tag字符串
/// </summary>
[DefaultValue(null)]
[Description("获取或设置包含有关控件的数据的对象字符串"), Category("SunnyUI")]
public string TagString
{
get; set;
}
[Browsable(false), DefaultValue(false)]
public bool IsScaled { get; set; }
public void Collapse()
{
if (_collapsePanel != UICollapsePanel.None && SplitPanelState == UISplitPanelState.Expanded)
@ -536,5 +584,30 @@ namespace Sunny.UI
DefaultArrowWidth);
}
}
public void SetStyleColor(UIBaseStyle uiColor)
{
arrowColor = uiColor.SplitContainerArrowColor;
}
/// <summary>
/// 设置主题样式
/// </summary>
/// <param name="style">主题样式</param>
public void SetStyle(UIStyle style)
{
if (!style.IsCustom())
{
SetStyleColor(style.Colors());
Invalidate();
}
_style = style;
}
public void SetDPIScale()
{
//
}
}
}

View File

@ -224,6 +224,9 @@ namespace Sunny.UI
public virtual Color FlowLayoutPanelBarFillColor { get; protected set; }
public virtual Color FlowLayoutPanelBarForeColor { get; protected set; }
//SplitContainer
public virtual Color SplitContainerArrowColor { get; protected set; }
protected Color ForeColor { get; set; }
public UIBaseStyle DropDownStyle { get; protected set; }
@ -246,6 +249,8 @@ namespace Sunny.UI
SecondaryColor = colors[5];
RegularColor = colors[10];
SplitContainerArrowColor = PrimaryColor;
GridSelectedColor = colors[3];
GridSelectedForeColor = foreColor;
GridStripeEvenColor = colors[0];
@ -589,6 +594,8 @@ namespace Sunny.UI
DropDownPanelForeColor = UIFontColor.Primary;
DropDownStyle = UIStyles.Blue;
SplitContainerArrowColor = UIColor.Blue;
}
}
@ -704,6 +711,8 @@ namespace Sunny.UI
DropDownPanelForeColor = UIFontColor.Primary;
DropDownStyle = UIStyles.Blue;
SplitContainerArrowColor = UIColor.Blue;
}
}
}