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基础库
144
Kintai.Dispenser.Core.WinForm
Dispenser基础库
136
Kintai.Dispenser.Core.WinForm
Dispenser基础库
108
Kintai.Dispenser.OperationLogs.WinForm
Dispenser操作日志
103
Kintai.Dispenser.User.WinForm
Dispenser用户管理
101
Kintai.Dispenser.EQPStatuses.WinForm
Dispenser设备状态
100
Kintai.CIM.Common.CCLink.WinForm
CIM通用库
98
Kintai.CIM.Common.CCLink.WinForm
CIM通用库
97
Kintai.Dispenser.core.WinForm
Dispenser基础库
93
Kintai.Dispenser.Core.App
Dispenser基础库
84
Kintai.Dispenser.Core.WinForm
Dispenser基础库
84
Kintai.Dispenser.Core.WinForm
Dispenser基础库
83
Kintai.Dispenser.User.WinForm
Dispenser用户管理
83
Kintai.Dispenser.LinkWaits.WinForm
Dispenser上下游待机
76
Kintai.Dispenser.Product.WinForm
Dispenser产品管理——用户界面
75
Kintai.Dispenser.Core.WinForm
Dispenser基础库
74
Kintai.Dispenser.ProcessDatas.WinForm
Dispenser生产数据
72
Kintai.Dispenser.User.WinForm
Dispenser用户管理
70
Kintai.Dispenser.Product.WinForm
Dispenser产品管理
66
Kintai.CIM.Common.CCLink.WinForm
CIM通用库
66

.NET Framework 4.8

.NET 5.0

Version Downloads Last updated
2025.2.27.1 118 02/27/2025
2025.2.25.1 9 02/25/2025
2025.2.17.1 39 02/17/2025
2025.2.12.1 17 02/12/2025
2024.12.6.1 44 12/06/2024
2024.1.17.1 237 01/17/2024
2024.1.16.1 60 01/16/2024
2024.1.2.2 40 01/02/2024
2024.1.2.1 49 01/02/2024
2024.1.2.1-preview 38 01/02/2024
2023.12.29.5-preview 40 12/29/2023
2023.12.29.4-preview 9 12/29/2023
2023.12.29.3-preview 11 12/29/2023
2023.12.29.2-preview 13 12/29/2023
2023.12.29.1-preview 11 12/29/2023
2023.8.15.1-preview 155 08/15/2023
2023.7.7.1-preview 107 07/07/2023
2023.7.4.1-priview 156 07/04/2023
2023.7.4.1-preview 12 07/04/2023
2023.6.29.2 33 06/29/2023
2023.6.25.4 41 06/25/2023
2021.12.2.1 1,516 12/02/2021
2021.11.18.1-preview 53 11/18/2021
2021.11.15.1-preview 10 11/15/2021
2021.9.29.1 60 11/01/2021
2021.9.29.1-preview 33 09/29/2021
2021.9.28.1-preview 11 09/28/2021
2021.9.27.2-preview 11 09/27/2021
2021.9.27.1-preview 12 09/27/2021
2021.8.30.1-preview 11 08/30/2021
2021.8.27.6-preview 8 08/27/2021
2021.8.27.5-preview 12 08/27/2021
2021.8.27.4-preview 10 08/27/2021
2021.8.27.3-preview 8 08/27/2021
2021.8.27.2-preview 9 08/27/2021
2021.8.27.1-preview 9 08/27/2021