102 lines
2.9 KiB
C#
102 lines
2.9 KiB
C#
/******************************************************************************
|
||
* SunnyUI 开源控件库、工具类库、扩展类库、多页面开发框架。
|
||
* CopyRight (C) 2012-2023 ShenYongHua(沈永华).
|
||
* QQ群:56829229 QQ:17612584 EMail:SunnyUI@QQ.Com
|
||
*
|
||
* Blog: https://www.cnblogs.com/yhuse
|
||
* Gitee: https://gitee.com/yhuse/SunnyUI
|
||
* GitHub: https://github.com/yhuse/SunnyUI
|
||
*
|
||
* SunnyUI.dll can be used for free under the GPL-3.0 license.
|
||
* If you use this code, please keep this note.
|
||
* 如果您使用此代码,请保留此说明。
|
||
******************************************************************************
|
||
* 文件名称: UITableLayoutPanel.cs
|
||
* 文件说明: 动态布局面板
|
||
* 当前版本: V3.1
|
||
* 创建日期: 2021-07-18
|
||
*
|
||
* 2021-07-18: V3.0.5 增加文件说明
|
||
* 2021-07-18: V3.0.5 更新了放在TableLayoutPanel里控件的自定义颜色问题
|
||
* 2023-11-12: V3.5.2 重构主题
|
||
******************************************************************************/
|
||
|
||
using System.ComponentModel;
|
||
using System.Windows.Forms;
|
||
|
||
namespace Sunny.UI
|
||
{
|
||
public sealed class UITableLayoutPanel : TableLayoutPanel, IStyleInterface
|
||
{
|
||
public UITableLayoutPanel()
|
||
{
|
||
Version = UIGlobal.Version;
|
||
}
|
||
|
||
private float DefaultFontSize = -1;
|
||
|
||
public void SetDPIScale()
|
||
{
|
||
if (DesignMode) return;
|
||
if (!UIDPIScale.NeedSetDPIFont()) return;
|
||
if (DefaultFontSize < 0) DefaultFontSize = this.Font.Size;
|
||
this.SetDPIScaleFont(DefaultFontSize);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 自定义主题风格
|
||
/// </summary>
|
||
[DefaultValue(false), Browsable(false)]
|
||
[Description("获取或设置可以自定义主题风格"), Category("SunnyUI")]
|
||
public bool StyleCustomMode { get; set; }
|
||
|
||
private UIStyle _style = UIStyle.Inherited;
|
||
|
||
/// <summary>
|
||
/// 主题样式
|
||
/// </summary>
|
||
[DefaultValue(UIStyle.Inherited), Description("主题样式"), Category("SunnyUI")]
|
||
public UIStyle Style
|
||
{
|
||
get => _style;
|
||
set => SetStyle(value);
|
||
}
|
||
|
||
public string Version
|
||
{
|
||
get;
|
||
}
|
||
|
||
public string TagString
|
||
{
|
||
get; set;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设置主题样式
|
||
/// </summary>
|
||
/// <param name="style">主题样式</param>
|
||
private void SetStyle(UIStyle style)
|
||
{
|
||
if (!style.IsCustom())
|
||
{
|
||
SetStyleColor(style.Colors());
|
||
Invalidate();
|
||
}
|
||
|
||
_style = style == UIStyle.Inherited ? UIStyle.Inherited : UIStyle.Custom;
|
||
}
|
||
|
||
public void SetInheritedStyle(UIStyle style)
|
||
{
|
||
SetStyle(style);
|
||
_style = UIStyle.Inherited;
|
||
}
|
||
|
||
public void SetStyleColor(UIBaseStyle uiColor)
|
||
{
|
||
//
|
||
}
|
||
}
|
||
}
|