Kintai.Windows.Forms 2024.1.2.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基础库
168
Kintai.Dispenser.Core.WinForm
Dispenser基础库
158
Kintai.Dispenser.Core.WinForm
Dispenser基础库
133
Kintai.Dispenser.Core.App
Dispenser基础库
129
Kintai.Dispenser.User.WinForm
Dispenser用户管理
128
Kintai.Dispenser.Core.WinForm
Dispenser基础库
126
Kintai.Dispenser.OperationLogs.WinForm
Dispenser操作日志
124
Kintai.Dispenser.EQPStatuses.WinForm
Dispenser设备状态
118
Kintai.CIM.Common.CCLink.WinForm
CIM通用库
117
Kintai.Dispenser.core.WinForm
Dispenser基础库
117
Kintai.CIM.Common.CCLink.WinForm
CIM通用库
114
Kintai.Dispenser.User.WinForm
Dispenser用户管理
102
Kintai.Dispenser.Core.App
Dispenser基础库
101
Kintai.Dispenser.Core.WinForm
Dispenser基础库
100
Kintai.Dispenser.Product.WinForm
Dispenser产品管理——用户界面
100
Kintai.Dispenser.Core.WinForm
Dispenser基础库
99
Kintai.CIM.Common.CCLink.WinForm
CIM通用库
95
Kintai.Dispenser.Reports.WinForm
Dispenser生产数据——用户界面
95
Kintai.Dispenser.EQPStatuses.WinForm
Dispenser设备状态
93

.NET Framework 4.8

.NET 5.0

Version Downloads Last updated
2026.4.29.1 7 04/29/2026
2026.4.20.1 10 04/20/2026
2025.2.27.1 251 02/27/2025
2025.2.25.1 23 02/25/2025
2025.2.17.1 57 02/17/2025
2025.2.12.1 33 02/12/2025
2024.12.6.1 62 12/06/2024
2024.1.17.1 270 01/17/2024
2024.1.16.1 80 01/16/2024
2024.1.2.2 56 01/02/2024
2024.1.2.1 66 01/02/2024
2024.1.2.1-preview 55 01/02/2024
2023.12.29.5-preview 57 12/29/2023
2023.12.29.4-preview 23 12/29/2023
2023.12.29.3-preview 25 12/29/2023
2023.12.29.2-preview 26 12/29/2023
2023.12.29.1-preview 27 12/29/2023
2023.8.15.1-preview 178 08/15/2023
2023.7.7.1-preview 129 07/07/2023
2023.7.4.1-priview 181 07/04/2023
2023.7.4.1-preview 31 07/04/2023
2023.6.29.2 47 06/29/2023
2023.6.25.4 58 06/25/2023
2021.12.2.1 1,581 12/02/2021
2021.11.18.1-preview 68 11/18/2021
2021.11.15.1-preview 26 11/15/2021
2021.9.29.1 77 11/01/2021
2021.9.29.1-preview 50 09/29/2021
2021.9.28.1-preview 26 09/28/2021
2021.9.27.2-preview 23 09/27/2021
2021.9.27.1-preview 27 09/27/2021
2021.8.30.1-preview 24 08/30/2021
2021.8.27.6-preview 22 08/27/2021
2021.8.27.5-preview 29 08/27/2021
2021.8.27.4-preview 23 08/27/2021
2021.8.27.3-preview 22 08/27/2021
2021.8.27.2-preview 24 08/27/2021
2021.8.27.1-preview 23 08/27/2021