SunnyUI/SunnyUI/Style/UIStyleManager.cs
Sunny 4c8d722ce6 * UIStyle: 增加系统DPI缩放自适应
* UIStyleManager: 增加系统DPI缩放自适应
2021-10-16 20:39:12 +08:00

79 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/******************************************************************************
* SunnyUI 开源控件库、工具类库、扩展类库、多页面开发框架。
* CopyRight (C) 2012-2021 ShenYongHua(沈永华).
* QQ群56829229 QQ17612584 EMailSunnyUI@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.
* 如果您使用此代码,请保留此说明。
******************************************************************************
* 文件名称: UIStyleManager.cs
* 文件说明: 主题样式管理类
* 当前版本: V3.0
* 创建日期: 2020-01-01
*
* 2020-01-01: V2.2.0 增加文件说明
* 2021-10-16: V3.0.8 增加系统DPI缩放自适应
******************************************************************************/
using System.ComponentModel;
namespace Sunny.UI
{
/// <summary>
/// 主题样式管理类
/// </summary>
public class UIStyleManager : Component
{
/// <summary>
/// 主题样式
/// </summary>
[DefaultValue(UIStyle.Blue), Description("主题样式"), Category("SunnyUI")]
public UIStyle Style
{
get => UIStyles.Style;
set
{
if (UIStyles.Style != value && value != UIStyle.Custom)
{
UIStyles.SetStyle(value);
}
}
}
public void Render()
{
if (Style != UIStyle.Custom)
{
UIStyles.SetStyle(Style);
}
}
/// <summary>
/// 构造函数
/// </summary>
public UIStyleManager()
{
}
/// <summary>
/// 构造函数
/// </summary>
/// <param name="container"></param>
public UIStyleManager(IContainer container) : this()
{
container.Add(this);
}
[DefaultValue(false), Description("DPI缩放"), Category("SunnyUI")]
public bool DPIScale
{
get => UIStyles.DPIScale;
set => UIStyles.DPIScale = value;
}
}
}