Kintai.Windows.Forms 2023.12.29.1-preview

窗体控件库主题风格使用说明

1. 引用 Kintai.Windows 命名空间;

2. 所有窗体(Form)继承改为:ThemeForm

3. 所有用户控件(UserControl)继承改为:ThemeUserControl

4. 所有消息框(MessageBox.Show)改为:this.ShowMsg

5. 设置主题

  Theme.CurrentTheme = new Themes.Dark();//设置主题 深色
  或者
  Theme.CurrentTheme = new Themes.Light();//设置主题 浅色

##(以下设置位置任选其一)

5.1. 程序启动时

Program.cs 调用方法示例:

static class Program
{
    /// <summary>
    ///  The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        Application.SetHighDpiMode(HighDpiMode.SystemAware);
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Theme.CurrentTheme = new Themes.Dark();//设置主题 深色
        Application.Run(new FrmTheme());
    }
}

5.2. 窗体加载时

Form_Load 调用方法示例:

public partial class FrmTheme : ThemeForm
{
    public FrmTheme()
    {
        InitializeComponent();
    }

    private void ThemeForm_Load(object sender, EventArgs e)
    {
        ThisTheme = new Themes.Dark();//设置主题 深色
        // 示例带主题风格的消息框
        var res = this.ShowMsg("当前是深色主题模式", "警告", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
        this.Text = res.ToString();
    }
}

5.3. 按钮点击时

Button_Click 调用方法示例:

private void button1_Click(object sender, EventArgs e)
{
    Theme.CurrentTheme = new Themes.Light();//设置主题 浅色
    // 示例带主题风格的消息框
    var res = this.ShowMsg("当前是浅色主题模式", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
    this.Text = res.ToString();
}

6. 如果需要主题可配置化,只需要在程序运行目录放置theme.json文件,则其中设置就会自动加载。

theme.json示例:

{
"ButtonBorderSize": 3,
"FormBackColor": {"A": 255,"R": 35,"G": 45,"B": 65}//注意:DataGridView控件BackgroundColor和BackColor不支持透明的背景色,会自动将A值设为255。
}

7. 如果需要设置字体大小,只需要调用窗体或控件的设置字体接口SetFont,则其字体就会自动调整。

SetFont示例:

this.SetFont(new Font("黑体", 9f));

Showing the top 20 packages that depend on Kintai.Windows.Forms.

Packages Downloads
Kintai.Dispenser.Core.WinForm
Dispenser基础库
143
Kintai.Dispenser.Core.WinForm
Dispenser基础库
134
Kintai.Dispenser.Core.WinForm
Dispenser基础库
103
Kintai.Dispenser.OperationLogs.WinForm
Dispenser操作日志
101
Kintai.Dispenser.EQPStatuses.WinForm
Dispenser设备状态
98
Kintai.CIM.Common.CCLink.WinForm
CIM通用库
96
Kintai.Dispenser.User.WinForm
Dispenser用户管理
96
Kintai.CIM.Common.CCLink.WinForm
CIM通用库
95
Kintai.Dispenser.core.WinForm
Dispenser基础库
91
Kintai.Dispenser.Core.WinForm
Dispenser基础库
82
Kintai.Dispenser.User.WinForm
Dispenser用户管理
79
Kintai.Dispenser.LinkWaits.WinForm
Dispenser上下游待机
74
Kintai.Dispenser.ProcessDatas.WinForm
Dispenser生产数据
70
Kintai.Dispenser.Core.WinForm
Dispenser基础库
68
Kintai.Dispenser.User.WinForm
Dispenser用户管理
67
Kintai.Dispenser.User.WinForm
Dispenser用户管理
63
Kintai.Dispenser.LinkWaits.WinForm
Dispenser上下游待机
63
Kintai.CIM.Common.CCLink.WinForm
CIM通用库
63
Kintai.Dispenser.Alarms.Statistics
Dispenser上下游待机
62
Kintai.Dispenser.Alarms.Statistics
Dispenser报警模块——报警统计
61

.NET Framework 4.8

.NET 5.0

Version Downloads Last updated
2025.2.27.1 81 02/27/2025
2025.2.25.1 7 02/25/2025
2025.2.17.1 34 02/17/2025
2025.2.12.1 15 02/12/2025
2024.12.6.1 40 12/06/2024
2024.1.17.1 228 01/17/2024
2024.1.16.1 58 01/16/2024
2024.1.2.2 38 01/02/2024
2024.1.2.1 47 01/02/2024
2024.1.2.1-preview 37 01/02/2024
2023.12.29.5-preview 37 12/29/2023
2023.12.29.4-preview 8 12/29/2023
2023.12.29.3-preview 9 12/29/2023
2023.12.29.2-preview 11 12/29/2023
2023.12.29.1-preview 9 12/29/2023
2023.8.15.1-preview 150 08/15/2023
2023.7.7.1-preview 105 07/07/2023
2023.7.4.1-priview 153 07/04/2023
2023.7.4.1-preview 9 07/04/2023
2023.6.29.2 31 06/29/2023
2023.6.25.4 39 06/25/2023
2021.12.2.1 1,504 12/02/2021
2021.11.18.1-preview 49 11/18/2021
2021.11.15.1-preview 8 11/15/2021
2021.9.29.1 58 11/01/2021
2021.9.29.1-preview 31 09/29/2021
2021.9.28.1-preview 9 09/28/2021
2021.9.27.2-preview 9 09/27/2021
2021.9.27.1-preview 11 09/27/2021
2021.8.30.1-preview 9 08/30/2021
2021.8.27.6-preview 6 08/27/2021
2021.8.27.5-preview 10 08/27/2021
2021.8.27.4-preview 8 08/27/2021
2021.8.27.3-preview 6 08/27/2021
2021.8.27.2-preview 7 08/27/2021
2021.8.27.1-preview 7 08/27/2021